Linear BVP

A boundary value problem is linear iff

y′′=p(x)y′+q(x)y+r(x),a≤x≤b,y(a)=α, y(b)=βy'' = p(x)y' + q(x)y + r(x), \quad a \leq x \leq b, \quad y(a) = \alpha,\ y(b) = \beta

for continuous functions pp, qq, and rr.

Linear Shooting Method

Solves a linear BVP by combining solutions to 2 initial value problems.

A unique solution exists if

  • pp, qq, and rr are continuous on [a,b][a,b]
  • q(x)>0q(x) > 0 for x∈[a,b]x \in [a,b]

Superposition Idea

If y1y_1 solves

y1′′=p(x)y1′+q(x)y1+r(x)y_1'' = p(x)y_1' + q(x)y_1 + r(x)

and y2y_2 solves the homogeneous equation

y2′′=p(x)y2′+q(x)y2y_2'' = p(x)y_2' + q(x)y_2

then y=y1+c y2y = y_1 + c\,y_2 solves the ODE for any constant cc.

Auxiliary IVPs

Fix

y1(a)=α, y1′(a)=0,y2(a)=0, y2′(a)=1y_1(a) = \alpha,\ y_1'(a) = 0, \qquad y_2(a) = 0,\ y_2'(a) = 1

Solve

y1′′=p(x)y1′+q(x)y1+r(x),y1(a)=α, y1′(a)=0y2′′=p(x)y2′+q(x)y2,y2(a)=0, y2′(a)=1y_1'' = p(x)y_1' + q(x)y_1 + r(x), \quad y_1(a) = \alpha,\ y_1'(a) = 0 \\[8pt] y_2'' = p(x)y_2' + q(x)y_2, \quad y_2(a) = 0,\ y_2'(a) = 1

with order 4 Runge-Kutta.

Combining Solutions

Choose cc so that y(b)=βy(b) = \beta.

c=β−y1(b)y2(b)y(x)=y1(x)+c y2(x)\begin{aligned} c &= \frac{\beta - y_1(b)}{y_2(b)} \\ y(x) &= y_1(x) + c\,y_2(x) \end{aligned}

Linear Finite-Difference Method

Replace derivatives with centered differences at mesh points and solve the resulting linear system.

Mesh Points

Partition [a,b][a,b] into N+1N+1 subintervals of length h=b−aN+1h = \dfrac{b-a}{N+1}.

xi=a+ih,i=0,1,…,N+1x_i = a + ih, \quad i = 0, 1, \ldots, N+1

Centered Difference Formulas

y′′(xi)=y(xi+1)−2y(xi)+y(xi−1)h2+O(h2),y′(xi)=y(xi+1)−y(xi−1)2h+O(h2)y''(x_i) = \frac{y(x_{i+1}) - 2y(x_i) + y(x_{i-1})}{h^2} + O(h^2), \qquad y'(x_i) = \frac{y(x_{i+1}) - y(x_{i-1})}{2h} + O(h^2)

Linear Difference Equation

With y(xi)≈wiy(x_i) \approx w_i, w0=αw_0 = \alpha, and wN+1=βw_{N+1} = \beta,

(1+h2p(xi))wi−1−(2+h2q(xi))wi+(1−h2p(xi))wi+1=h2r(xi)\left(1 + \frac{h}{2}p(x_i)\right)w_{i-1} - \big(2 + h^2 q(x_i)\big)w_i + \left(1 - \frac{h}{2}p(x_i)\right)w_{i+1} = h^2 r(x_i)

for i=1,…,Ni = 1, \ldots, N, with truncation error O(h2)O(h^2).

Matrix Form

Aw=bAw = b

where AA is tridiagonal, with

ai=−1−h2p(xi),di=2+h2q(xi),ci=−1+h2p(xi)A=(d1c1a2d2c2⋱⋱⋱aNdN)w=(w1w2⋮wN),b=(−h2r(x1)−a1α−h2r(x2)⋮−h2r(xN)−cNβ)a_i = -1 - \frac{h}{2}p(x_i), \quad d_i = 2 + h^2q(x_i), \quad c_i = -1 + \frac{h}{2}p(x_i) \\[8pt] A = \begin{pmatrix} d_1 & c_1 & & \\ a_2 & d_2 & c_2 & \\ & \ddots & \ddots & \ddots \\ & & a_N & d_N \end{pmatrix} \\[8pt] w = \begin{pmatrix}w_1\\w_2\\\vdots\\w_N\end{pmatrix}, \quad b = \begin{pmatrix}-h^2r(x_1)-a_1\alpha\\-h^2r(x_2)\\\vdots\\-h^2r(x_N)-c_N\beta\end{pmatrix}

Solve for ww with LU decomposition or another linear solver.

If pp, qq, and rr are continuous on [a,b][a,b] and q(x)≥0q(x) \geq 0, the linear system has a unique solution whenever h<2Lh < \dfrac{2}{L}, where L=max⁡a≤x≤b∣p(x)∣L = \max_{a \leq x \leq b}|p(x)|.

Worked Examples

Example 1

Solve y′′=yy'' = y, 0≤x≤10 \leq x \leq 1, y(0)=0y(0) = 0, and y(1)=1y(1) = 1 with the linear shooting method.

Solution Reveal Hide

p=0p = 0, q=1q = 1, and r=0r = 0.

Use step size h=0.25h=0.25. For the shooting method, solve the auxiliary IVPs with order 4 Runge-Kutta:

y1′′=y1,y1(0)=0, y1′(0)=0y_1'' = y_1, \quad y_1(0) = 0,\ y_1'(0) = 0

and

y2′′=y2,y2(0)=0, y2′(0)=1y_2'' = y_2, \quad y_2(0) = 0,\ y_2'(0) = 1

The first IVP has y1(x)=0y_1(x)=0. Applying order 4 Runge-Kutta to the second IVP gives

xy2(x)y2′(x)0010.250.2526041.0314130.500.5210781.1276210.750.8222891.2946691.001.1751581.543052\begin{array}{c|cc} x & y_2(x) & y_2'(x) \\\hline 0 & 0 & 1 \\ 0.25 & 0.252604 & 1.031413 \\ 0.50 & 0.521078 & 1.127621 \\ 0.75 & 0.822289 & 1.294669 \\ 1.00 & 1.175158 & 1.543052 \end{array}

Therefore,

c=1−y1(1)y2(1)=1−01.175158=0.8509c = \frac{1-y_1(1)}{y_2(1)} = \frac{1-0}{1.175158} = 0.8509

Combining the auxiliary solutions gives

y(x)=y1(x)+cy2(x)≈0.8509y2(x)y(x) = y_1(x) + c y_2(x) \approx 0.8509y_2(x)

Example 2

Solve y′′=y+1y'' = y+1, 0≤x≤10 \leq x \leq 1, y(0)=0y(0) = 0, and y(1)=1y(1) = 1 with the linear shooting method. Use order 4 Runge-Kutta with h=0.25h=0.25.

Solution Reveal Hide

Here p=0p=0, q=1q=1, and r=1r=1. The auxiliary IVPs are

y1′′=y1+1,y1(0)=0, y1′(0)=0y_1''=y_1+1, \quad y_1(0)=0,\ y_1'(0)=0

and

y2′′=y2,y2(0)=0, y2′(0)=1y_2''=y_2, \quad y_2(0)=0,\ y_2'(0)=1

Order 4 Runge-Kutta gives

y1(1)≈0.543052,y2(1)≈1.175158y_1(1)\approx0.543052, \qquad y_2(1)\approx1.175158

Therefore,

c=1−y1(1)y2(1)=1−0.5430521.175158≈0.38884c=\frac{1-y_1(1)}{y_2(1)}=\frac{1-0.543052}{1.175158}\approx0.38884

The shooting approximation is

y(x)≈y1(x)+0.38884y2(x)y(x)\approx y_1(x)+0.38884y_2(x)

Wolfram Mathematica notebook

The summary notebook defines every function used in this module, with documentation and no examples, as a starting point for your own problems.

Written by November 5, 2026 2 min read
Was this helpful?