# §3.7 Ordinary Differential Equations

## §3.7(i) Introduction

Consideration will be limited to ordinary linear second-order differential equations

 3.7.1 $\frac{{\mathrm{d}}^{2}w}{{\mathrm{d}z}^{2}}+f(z)\frac{\mathrm{d}w}{\mathrm{d}z% }+g(z)w=h(z),$ ⓘ Defines: $f(z)$: function (locally), $g(z)$: function (locally) and $h(z)$: function (locally) Symbols: $\frac{\mathrm{d}\NVar{f}}{\mathrm{d}\NVar{x}}$: derivative of $f$ with respect to $x$ and $w(z)$: function Referenced by: §3.7(i), §3.7(ii), §3.7(ii), §3.7(ii) Permalink: http://dlmf.nist.gov/3.7.E1 Encodings: TeX, pMML, png See also: Annotations for §3.7(i), §3.7 and Ch.3

where $f$, $g$, and $h$ are analytic functions in a domain $D\subset\mathbb{C}$. If $h=0$ the differential equation is homogeneous, otherwise it is inhomogeneous. For applications to special functions $f$, $g$, and $h$ are often simple rational functions.

For general information on solutions of equation (3.7.1) see §1.13. For classification of singularities of (3.7.1) and expansions of solutions in the neighborhoods of singularities, see §2.7. For an introduction to numerical methods for ordinary differential equations, see Ascher and Petzold (1998), Hairer et al. (1993), and Iserles (1996).

## §3.7(ii) Taylor-Series Method: Initial-Value Problems

Assume that we wish to integrate (3.7.1) along a finite path $\mathscr{P}$ from $z=a$ to $z=b$ in a domain $D$. The path is partitioned at $P+1$ points labeled successively $z_{0},z_{1},\dots,z_{P}$, with $z_{0}=a$, $z_{P}=b$.

By repeated differentiation of (3.7.1) all derivatives of $w(z)$ can be expressed in terms of $w(z)$ and $w^{\prime}(z)$ as follows. Write

 3.7.2 $w^{(s)}(z)=f_{s}(z)w(z)+g_{s}(z)w^{\prime}(z)+h_{s}(z),$ $s=0,1,2,\dots$, ⓘ Symbols: $w(z)$: function, $g_{s}(z)$: coefficient, $h(z)$: function and $f_{s}(z)$: coefficient Referenced by: §3.7(ii) Permalink: http://dlmf.nist.gov/3.7.E2 Encodings: TeX, pMML, png See also: Annotations for §3.7(ii), §3.7 and Ch.3

with

 3.7.3 $\displaystyle f_{0}(z)$ $\displaystyle=1,$ $\displaystyle g_{0}(z)$ $\displaystyle=0,$ $\displaystyle h_{0}(z)$ $\displaystyle=0,$ $\displaystyle f_{1}(z)$ $\displaystyle=0,$ $\displaystyle g_{1}(z)$ $\displaystyle=1,$ $\displaystyle h_{1}(z)$ $\displaystyle=0.$ ⓘ Defines: $g_{s}(z)$: coefficient (locally) and $f_{s}(z)$: coefficient (locally) Symbols: $h(z)$: function Permalink: http://dlmf.nist.gov/3.7.E3 Encodings: TeX, TeX, TeX, TeX, TeX, TeX, pMML, pMML, pMML, pMML, pMML, pMML, png, png, png, png, png, png See also: Annotations for §3.7(ii), §3.7 and Ch.3

Then for $s=2,3,\dots$,

 3.7.4 $\displaystyle f_{s}(z)$ $\displaystyle=f^{\prime}_{s-1}(z)-g(z)g_{s-1}(z),$ $\displaystyle g_{s}(z)$ $\displaystyle=f_{s-1}(z)-f(z)g_{s-1}(z)+g^{\prime}_{s-1}(z),$ $\displaystyle h_{s}(z)$ $\displaystyle=h(z)g_{s-1}(z)+h^{\prime}_{s-1}(z).$ ⓘ Symbols: $g_{s}(z)$: coefficient, $f(z)$: function, $g(z)$: function, $h(z)$: function and $f_{s}(z)$: coefficient Permalink: http://dlmf.nist.gov/3.7.E4 Encodings: TeX, TeX, TeX, pMML, pMML, pMML, png, png, png See also: Annotations for §3.7(ii), §3.7 and Ch.3

Write $\tau_{j}=z_{j+1}-z_{j}$, $j=0,1,\dots,P$, expand $w(z)$ and $w^{\prime}(z)$ in Taylor series (§1.10(i)) centered at $z=z_{j}$, and apply (3.7.2). Then

 3.7.5 $\begin{bmatrix}w(z_{j+1})\\ w^{\prime}(z_{j+1})\end{bmatrix}=\mathbf{A}(\tau_{j},z_{j})\begin{bmatrix}w(z_% {j})\\ w^{\prime}(z_{j})\end{bmatrix}+\mathbf{b}(\tau_{j},z_{j}),$ ⓘ Symbols: $(\NVar{a},\NVar{b})$: open interval, $w(z)$: function and $\mathbf{A}$: matrix Referenced by: §3.7(ii), §3.7(iii) Permalink: http://dlmf.nist.gov/3.7.E5 Encodings: TeX, pMML, png See also: Annotations for §3.7(ii), §3.7 and Ch.3

where $\mathbf{A}(\tau,z)$ is the matrix

 3.7.6 $\mathbf{A}(\tau,z)=\begin{bmatrix}A_{11}(\tau,z)&A_{12}(\tau,z)\\ A_{21}(\tau,z)&A_{22}(\tau,z)\end{bmatrix},$ ⓘ Defines: $\mathbf{A}$: matrix (locally) and $\mathbf{A}$: matrix (locally) Symbols: $(\NVar{a},\NVar{b})$: open interval Permalink: http://dlmf.nist.gov/3.7.E6 Encodings: TeX, pMML, png See also: Annotations for §3.7(ii), §3.7 and Ch.3

and $\mathbf{b}(\tau,z)$ is the vector

 3.7.7 $\mathbf{b}(\tau,z)=\begin{bmatrix}b_{1}(\tau,z)\\ b_{2}(\tau,z)\end{bmatrix},$ ⓘ Defines: $\mathbf{b}(\tau,z)$: function (locally) Symbols: $(\NVar{a},\NVar{b})$: open interval Permalink: http://dlmf.nist.gov/3.7.E7 Encodings: TeX, pMML, png See also: Annotations for §3.7(ii), §3.7 and Ch.3

with

 3.7.8 $\displaystyle A_{11}(\tau,z)$ $\displaystyle=\sum_{s=0}^{\infty}\frac{\tau^{s}}{s!}f_{s}(z),$ $\displaystyle A_{12}(\tau,z)$ $\displaystyle=\sum_{s=0}^{\infty}\frac{\tau^{s}}{s!}g_{s}(z),$ $\displaystyle A_{21}(\tau,z)$ $\displaystyle=\sum_{s=0}^{\infty}\frac{\tau^{s}}{s!}f_{s+1}(z),$ $\displaystyle A_{22}(\tau,z)$ $\displaystyle=\sum_{s=0}^{\infty}\frac{\tau^{s}}{s!}g_{s+1}(z),$
 3.7.9 $\displaystyle b_{1}(\tau,z)$ $\displaystyle=\sum_{s=0}^{\infty}\frac{\tau^{s}}{s!}h_{s}(z),$ $\displaystyle b_{2}(\tau,z)$ $\displaystyle=\sum_{s=0}^{\infty}\frac{\tau^{s}}{s!}h_{s+1}(z).$ ⓘ Symbols: $!$: factorial (as in $n!$), $\mathbf{b}(\tau,z)$: function and $h(z)$: function Permalink: http://dlmf.nist.gov/3.7.E9 Encodings: TeX, TeX, pMML, pMML, png, png See also: Annotations for §3.7(ii), §3.7 and Ch.3

If the solution $w(z)$ that we are seeking grows in magnitude at least as fast as all other solutions of (3.7.1) as we pass along $\mathscr{P}$ from $a$ to $b$, then $w(z)$ and $w^{\prime}(z)$ may be computed in a stable manner for $z=z_{0},z_{1},\dots,z_{P}$ by successive application of (3.7.5) for $j=0,1,\dots,P-1$, beginning with initial values $w(a)$ and $w^{\prime}(a)$.

Similarly, if $w(z)$ is decaying at least as fast as all other solutions along $\mathscr{P}$, then we may reverse the labeling of the $z_{j}$ along $\mathscr{P}$ and begin with initial values $w(b)$ and $w^{\prime}(b)$.

## §3.7(iii) Taylor-Series Method: Boundary-Value Problems

Now suppose the path $\mathscr{P}$ is such that the rate of growth of $w(z)$ along $\mathscr{P}$ is intermediate to that of two other solutions. (This can happen only for inhomogeneous equations.) Then to compute $w(z)$ in a stable manner we solve the set of equations (3.7.5) simultaneously for $j=0,1,\dots,P$, as follows. Let $\mathbf{A}$ be the $(2P)\times(2P+2)$ band matrix

 3.7.10 $\mathbf{A}=\begin{bmatrix}-\mathbf{A}(\tau_{0},z_{0})&\mathbf{I}&\boldsymbol{{% 0}}&\cdots&\boldsymbol{{0}}&\boldsymbol{{0}}\\ \boldsymbol{{0}}&-\mathbf{A}(\tau_{1},z_{1})&\mathbf{I}&\cdots&\boldsymbol{{0}% }&\boldsymbol{{0}}\\ \vdots&\vdots&\ddots&\ddots&\vdots&\vdots\\ \boldsymbol{{0}}&\boldsymbol{{0}}&\cdots&-\mathbf{A}(\tau_{P-2},z_{P-2})&% \mathbf{I}&\boldsymbol{{0}}\\ \boldsymbol{{0}}&\boldsymbol{{0}}&\cdots&\boldsymbol{{0}}&-\mathbf{A}(\tau_{P-% 1},z_{P-1})&\mathbf{I}\end{bmatrix}$ ⓘ Symbols: $(\NVar{a},\NVar{b})$: open interval, $\tau_{j}$: change of variable and $P$: partitioning point Permalink: http://dlmf.nist.gov/3.7.E10 Encodings: TeX, pMML, png See also: Annotations for §3.7(iii), §3.7 and Ch.3

($\mathbf{I}$ and $\boldsymbol{{0}}$ being the identity and zero matrices of order $2\times 2$.) Also let $\mathbf{w}$ denote the $(2P+2)\times 1$ vector

 3.7.11 $\mathbf{w}=\left[w(z_{0}),w^{\prime}(z_{0}),w(z_{1}),w^{\prime}(z_{1}),\dots,w% (z_{P}),w^{\prime}(z_{P})\right]^{\rm T},$ ⓘ Symbols: $w(z)$: function and $P$: partitioning point Permalink: http://dlmf.nist.gov/3.7.E11 Encodings: TeX, pMML, png See also: Annotations for §3.7(iii), §3.7 and Ch.3

and $\mathbf{b}$ the $(2P)\times 1$ vector

 3.7.12 $\mathbf{b}=\left[b_{1}(\tau_{0},z_{0}),b_{2}(\tau_{0},z_{0}),b_{1}(\tau_{1},z_% {1}),b_{2}(\tau_{1},z_{1}),\ldots,b_{1}(\tau_{P-1},z_{P-1}),b_{2}(\tau_{P-1},z% _{P-1})\right]^{\rm T}.$ ⓘ Symbols: $(\NVar{a},\NVar{b})$: open interval, $\tau_{j}$: change of variable and $P$: partitioning point Permalink: http://dlmf.nist.gov/3.7.E12 Encodings: TeX, pMML, png See also: Annotations for §3.7(iii), §3.7 and Ch.3

Then

 3.7.13 $\mathbf{A}\mathbf{w}=\mathbf{b}.$ ⓘ Referenced by: §3.7(iii), §3.7(iv) Permalink: http://dlmf.nist.gov/3.7.E13 Encodings: TeX, pMML, png See also: Annotations for §3.7(iii), §3.7 and Ch.3

This is a set of $2P$ equations for the $2P+2$ unknowns, $w(z_{j})$ and $w^{\prime}(z_{j})$, $j=0,1,\dots,P$. The remaining two equations are supplied by boundary conditions of the form

 3.7.14 $\displaystyle\alpha_{0}w(z_{0})+\beta_{0}w^{\prime}(z_{0})$ $\displaystyle=\gamma_{0},$ $\displaystyle\alpha_{1}w(z_{P})+\beta_{1}w^{\prime}(z_{P})$ $\displaystyle=\gamma_{1},$ ⓘ Symbols: $w(z)$: function, $\alpha$: constant, $\beta$: constant, $\gamma$: constant and $P$: partitioning point Permalink: http://dlmf.nist.gov/3.7.E14 Encodings: TeX, TeX, pMML, pMML, png, png See also: Annotations for §3.7(iii), §3.7 and Ch.3

where the $\alpha$’s, $\beta$’s, and $\gamma$’s are constants.

If, for example, $\beta_{0}=\beta_{1}=0$, then on moving the contributions of $w(z_{0})$ and $w(z_{P})$ to the right-hand side of (3.7.13) the resulting system of equations is not tridiagonal, but can readily be made tridiagonal by annihilating the elements of $\mathbf{A}$ that lie below the main diagonal and its two adjacent diagonals. The equations can then be solved by the method of §3.2(ii), if the differential equation is homogeneous, or by Olver’s algorithm (§3.6(v)). The latter is especially useful if the endpoint $b$ of $\mathscr{P}$ is at $\infty$, or if the differential equation is inhomogeneous.

It will be observed that the present formulation of the Taylor-series method permits considerable parallelism in the computation, both for initial-value and boundary-value problems.

For further information and examples, see Olde Daalhuis and Olver (1998, §7) and Lozier and Olver (1993). General methods for boundary-value problems for ordinary differential equations are given in Ascher et al. (1995).

## §3.7(iv) Sturm–Liouville Eigenvalue Problems

Let $(a,b)$ be a finite or infinite interval and $q(x)$ be a real-valued continuous (or piecewise continuous) function on the closure of $(a,b)$. The Sturm–Liouville eigenvalue problem is the construction of a nontrivial solution of the system

 3.7.15 $\frac{{\mathrm{d}}^{2}w_{k}}{{\mathrm{d}x}^{2}}+(\lambda_{k}-q(x))w_{k}=0,$
 3.7.16 $w_{k}(a)=w_{k}(b)=0,$ ⓘ Symbols: $w(z)$: function Referenced by: §3.7(iv) Permalink: http://dlmf.nist.gov/3.7.E16 Encodings: TeX, pMML, png See also: Annotations for §3.7(iv), §3.7 and Ch.3

with limits taken in (3.7.16) when $a$ or $b$, or both, are infinite. The values $\lambda_{k}$ are the eigenvalues and the corresponding solutions $w_{k}$ of the differential equation are the eigenfunctions. The eigenvalues $\lambda_{k}$ are simple, that is, there is only one corresponding eigenfunction (apart from a normalization factor), and when ordered increasingly the eigenvalues satisfy

 3.7.17 $\lambda_{1}<\lambda_{2}<\lambda_{3}<\cdots,$ $\lim_{k\to\infty}\lambda_{k}=\infty$. ⓘ Symbols: $\lambda_{k}$: eigenvalues Permalink: http://dlmf.nist.gov/3.7.E17 Encodings: TeX, pMML, png See also: Annotations for §3.7(iv), §3.7 and Ch.3

If $q(x)$ is $C^{\infty}$ on the closure of $(a,b)$, then the discretized form (3.7.13) of the differential equation can be used. This converts the problem into a tridiagonal matrix problem in which the elements of the matrix are polynomials in $\lambda$; compare §3.2(vi). The larger the absolute values of the eigenvalues $\lambda_{k}$ that are being sought, the smaller the integration steps $\left|\tau_{j}\right|$ need to be.

For further information, including other methods and examples, see Pryce (1993, §2.5.1).

## §3.7(v) Runge–Kutta Method

The Runge–Kutta method applies to linear or nonlinear differential equations. The method consists of a set of rules each of which is equivalent to a truncated Taylor-series expansion, but the rules avoid the need for analytic differentiations of the differential equation.

### First-Order Equations

For $w^{\prime}=f(z,w)$ the standard fourth-order rule reads

 3.7.18 $w_{n+1}=w_{n}+\tfrac{1}{6}(k_{1}+2k_{2}+2k_{3}+k_{4})+O\left(h^{5}\right),$ ⓘ Symbols: $O\left(\NVar{x}\right)$: order not exceeding, $w(z)$: function and $h(z)$: function Permalink: http://dlmf.nist.gov/3.7.E18 Encodings: TeX, pMML, png See also: Annotations for §3.7(v), §3.7(v), §3.7 and Ch.3

where $h=z_{n+1}-z_{n}$ and

 3.7.19 $\displaystyle k_{1}$ $\displaystyle=hf(z_{n},w_{n}),$ $\displaystyle k_{2}$ $\displaystyle=hf(z_{n}+\tfrac{1}{2}h,w_{n}+\tfrac{1}{2}k_{1}),$ $\displaystyle k_{3}$ $\displaystyle=hf(z_{n}+\tfrac{1}{2}h,w_{n}+\tfrac{1}{2}k_{2}),$ $\displaystyle k_{4}$ $\displaystyle=hf(z_{n}+h,w_{n}+k_{3}).$ ⓘ Symbols: $w(z)$: function, $f(z)$: function and $h(z)$: function Permalink: http://dlmf.nist.gov/3.7.E19 Encodings: TeX, TeX, TeX, TeX, pMML, pMML, pMML, pMML, png, png, png, png See also: Annotations for §3.7(v), §3.7(v), §3.7 and Ch.3

The order estimate $O\left(h^{5}\right)$ holds if the solution $w(z)$ has five continuous derivatives.

### Second-Order Equations

For $w^{\prime\prime}=f(z,w,w^{\prime})$ the standard fourth-order rule reads

 3.7.20 $\displaystyle w_{n+1}$ $\displaystyle=w_{n}+\tfrac{1}{6}h(6w^{\prime}_{n}+k_{1}+k_{2}+k_{3})+O\left(h^% {5}\right),$ $\displaystyle w^{\prime}_{n+1}$ $\displaystyle=w^{\prime}_{n}+\tfrac{1}{6}(k_{1}+2k_{2}+2k_{3}+k_{4})+O\left(h^% {5}\right),$ ⓘ Symbols: $O\left(\NVar{x}\right)$: order not exceeding, $w(z)$: function and $h(z)$: function Permalink: http://dlmf.nist.gov/3.7.E20 Encodings: TeX, TeX, pMML, pMML, png, png See also: Annotations for §3.7(v), §3.7(v), §3.7 and Ch.3

where

 3.7.21 $\displaystyle k_{1}$ $\displaystyle=hf(z_{n},w_{n},w^{\prime}_{n}),$ $\displaystyle k_{2}$ $\displaystyle=hf(z_{n}+\tfrac{1}{2}h,w_{n}+\tfrac{1}{2}hw^{\prime}_{n}+\tfrac{% 1}{8}hk_{1},w^{\prime}_{n}+\tfrac{1}{2}k_{1}),$ $\displaystyle k_{3}$ $\displaystyle=hf(z_{n}+\tfrac{1}{2}h,w_{n}+\tfrac{1}{2}hw^{\prime}_{n}+\tfrac{% 1}{8}hk_{2},w^{\prime}_{n}+\tfrac{1}{2}k_{2}),$ $\displaystyle k_{4}$ $\displaystyle=hf(z_{n}+h,w_{n}+hw^{\prime}_{n}+\tfrac{1}{2}hk_{3},w^{\prime}_{% n}+k_{3}).$ ⓘ Symbols: $w(z)$: function, $f(z)$: function and $h(z)$: function Permalink: http://dlmf.nist.gov/3.7.E21 Encodings: TeX, TeX, TeX, TeX, pMML, pMML, pMML, pMML, png, png, png, png See also: Annotations for §3.7(v), §3.7(v), §3.7 and Ch.3

The order estimates $O\left(h^{5}\right)$ hold if the solution $w(z)$ has five continuous derivatives.

An extensive literature exists on the numerical solution of ordinary differential equations by Runge–Kutta, multistep, or other methods. See, for example, Butcher (1987), Dekker and Verwer (1984, Chapter 3), Hairer et al. (1993, Chapter 2), and Hairer and Wanner (1996, Chapter 4).