Linear BVP

Work in progress. This note is still being written and incomplete.

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)+β−y1(b)y2(b) y2(x)c = \frac{\beta - y_1(b)}{y_2(b)}, \qquad y(x) = y_1(x) + \frac{\beta - y_1(b)}{y_2(b)}\,y_2(x)

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.

For the shooting method, solve the auxiliary IVPs

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 the zero solution, so y1(x)=0y_1(x) = 0. The second IVP has the solution y2(x)=sinh⁡xy_2(x) = \sinh x. Therefore,

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

Combining the auxiliary solutions gives

y(x)=y1(x)+cy2(x)=0+sinh⁡xsinh⁡1y(x) = y_1(x) + c y_2(x) = 0 + \frac{\sinh x}{\sinh 1}

Example 2

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 finite-difference method for N=3N = 3.

Solution Reveal Hide

For the finite-difference method,

h=b−aN+1=1−03+1=0.25,x1=0.25, x2=0.50, x3=0.75h = \frac{b-a}{N+1} = \frac{1-0}{3+1} = 0.25, \qquad x_1=0.25,\ x_2=0.50,\ x_3=0.75

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

−wi−1+(2+h2)wi−wi+1=0,2+h2=2+0.252=2.0625-w_{i-1} + (2+h^2)w_i-w_{i+1}=0, \qquad 2+h^2=2+0.25^2=2.0625

Using w0=0w_0=0 and w4=1w_4=1 gives

(2.0625−10−12.0625−10−12.0625)(w1w2w3)=(001)\begin{pmatrix}2.0625&-1&0\\-1&2.0625&-1\\0&-1&2.0625\end{pmatrix}\begin{pmatrix}w_1\\w_2\\w_3\end{pmatrix}=\begin{pmatrix}0\\0\\1\end{pmatrix}

The 1st and 3rd equations give

w1=w22.0625,w3=1+w22.0625w_1 = \frac{w_2}{2.0625}, \qquad w_3 = \frac{1+w_2}{2.0625}

Substitute these into the 2nd equation:

−w22.0625+2.0625w2−1+w22.0625=0-\frac{w_2}{2.0625}+2.0625w_2-\frac{1+w_2}{2.0625}=0(2.0625−22.0625)w2=12.0625  ⟹  w2=0.4437\left(2.0625-\frac{2}{2.0625}\right)w_2=\frac{1}{2.0625} \implies w_2=0.4437

Back-substitution gives

w1=0.44372.0625=0.2151,w3=1+0.44372.0625=0.6999w_1=\frac{0.4437}{2.0625}=0.2151, \qquad w_3=\frac{1+0.4437}{2.0625}=0.6999
xix_iwiw_iExact valueError
0.250.250.21510.21510.21500.21500.00020.0002
0.500.500.44370.44370.44340.44340.00030.0003
0.750.750.69990.69990.69970.69970.00020.0002

Example 3

Solve y′′=6xy'' = 6x, 0≤x≤10 \leq x \leq 1, y(0)=0y(0) = 0, y(1)=1y(1) = 1 with the linear finite-difference method for N=1N = 1.

Solution Reveal Hide

Here p=q=0p = q = 0 and r(x)=6xr(x)=6x. Calculate the mesh size and interior point:

h=b−aN+1=1−01+1=0.5,x1=a+h=0.5h=\frac{b-a}{N+1}=\frac{1-0}{1+1}=0.5, \qquad x_1=a+h=0.5

Evaluate the forcing term at the interior point:

r(x1)=r(0.5)=6(0.5)=3r(x_1)=r(0.5)=6(0.5)=3

Since p=q=0p=q=0, the difference equation is

−w0+2w1−w2=−h2r(x1)=−(0.5)2(3)=−0.75-w_0+2w_1-w_2=-h^2r(x_1)=-(0.5)^2(3)=-0.75

Apply the boundary values w0=y(0)=0w_0=y(0)=0 and w2=y(1)=1w_2=y(1)=1:

−0+2w1−1=−0.75-0+2w_1-1=-0.752w1=0.25  ⟹  w1=0.1252w_1=0.25 \implies w_1=0.125

The exact solution is y=x3y=x^3, so

y(0.5)=(0.5)3=0.125y(0.5)=(0.5)^3=0.125

The finite-difference method gives the exact value at the interior point.

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 4, 2026 2 min read
Was this helpful?