Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Jim Lambers

MAT 461/561
Spring Semester 2009-10
Lecture 26 Notes

These notes correspond to Sections 11.3 and 11.4 in the text.

Finite Difference Methods for Two-Point Boundary Value Prob-


lems
The shooting method for a two-point boundary value problem of the form

𝑦 ′′ = 𝑓 (𝑥, 𝑦, 𝑦 ′ ), 𝑎 < 𝑥 < 𝑏, 𝑦(𝑎) = 𝛼, 𝑦(𝑏) = 𝛽,

while taking advantage of effective methods for initial value problems, can not readily be generalized
to boundary value problems in higher spatial dimensions. We therefore consider an alternative
approach, in which the first and second derivatives of the solution 𝑦(𝑥) are approximated by finite
differences.
We discretize the problem by dividing the interval [𝑎, 𝑏] into 𝑁 + 1 subintervals of equal width
ℎ = (𝑏 − 𝑎)/(𝑁 + 1). Each subinterval is of the form [𝑥𝑖−1 , 𝑥𝑖 ], for 𝑖 = 1, 2, . . . , 𝑁 , where 𝑥𝑖 = 𝑎 + 𝑖ℎ.
We denote by 𝑦𝑖 an approximation of the solution at 𝑥𝑖 ; that is, 𝑦𝑖 ≈ 𝑦(𝑥𝑖 ). Then, assuming 𝑦(𝑥) is
at least four times continuously differentiable, we approximate 𝑦 ′ and 𝑦 ′′ at each 𝑥𝑖 , 𝑖 = 1, 2, . . . , 𝑁 ,
by the finite differences
𝑦(𝑥𝑖+1 ) − 𝑦(𝑥𝑖 ) ℎ2 ′′′
𝑦 ′ (𝑥𝑖 ) = − 𝑦 (𝜂𝑖 ),
2ℎ 6
𝑦(𝑥𝑖+1 ) − 2𝑦(𝑥𝑖 ) + 𝑦(𝑥𝑖−1 ) ℎ2 (4)
𝑦 ′′ (𝑥𝑖 ) = − 𝑦 (𝜉𝑖 ),
ℎ2 12
where 𝜂𝑖 and 𝜉𝑖 lie in [𝑥𝑖−1 , 𝑥𝑖+1 ].
If we substitute these finite differences into the boundary value problem, and apply the boundary
conditions to impose
𝑦0 = 𝛼, 𝑦𝑁 +1 = 𝛽,
then we obtain a system of equations
( )
𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1 𝑦𝑖+1 − 𝑦𝑖−1
=𝑓 𝑥𝑖 , 𝑦𝑖 , , 𝑖 = 1, 2, . . . , 𝑁,
ℎ2 2ℎ

for the values of the solution at each 𝑥𝑖 , in which the local truncation error is 𝑂(ℎ2 ).
We first consider the case in which the boundary value problem includes a linear ODE of the
form
𝑦 ′′ = 𝑝(𝑥)𝑦 ′ + 𝑞(𝑥)𝑦 + 𝑟(𝑥).

1
Then, the above system of equations is also linear, and can therefore be expressed in matrix-vector
form
𝐴y = r,
where 𝐴 is a tridiagonal matrix, since the approximations of 𝑦 ′ and 𝑦 ′′ at 𝑥𝑖 only use 𝑦𝑖−1 , 𝑦𝑖 and
𝑦𝑖+1 , and r is a vector that includes the values of 𝑟(𝑥) at the grid points, as well as additional terms
that account for the boundary conditions.
Specifically,

𝑎𝑖𝑖 = 2 + ℎ2 𝑞(𝑥𝑖 ), 𝑖 = 1, 2, . . . , 𝑁,

𝑎𝑖,𝑖+1 = −1 + 𝑝(𝑥𝑖 ), 𝑖 = 1, 2, . . . , 𝑁 − 1,
2

𝑎𝑖+1,𝑖 = −1 − 𝑝(𝑥𝑖+1 ), 𝑖 = 1, 2, . . . , 𝑁 − 1,
2 ( )
2 ℎ
𝑟1 = −ℎ 𝑟(𝑥1 ) + 1 + 𝑝(𝑥1 ) 𝛼,
2
𝑟𝑖 = −ℎ2 𝑟(𝑥𝑖 ), 𝑖 = 2, 3, . . . , 𝑁 − 1,
( )
2 ℎ
𝑟𝑁 = −ℎ 𝑟(𝑥𝑛 ) + 1 − 𝑝(𝑥𝑁 ) 𝛽.
2
This system of equations is guaranteed to have a unique solution if 𝐴 is diagonally dominaint,
which is the case if 𝑞(𝑥) ≥ 0 and ℎ < 2/𝐿, where 𝐿 is an upper bound on ∣𝑝(𝑥)∣.
If the ODE is nonlinear, then we must solve a system of nonlinear equations of the form

𝐹 (y) = 0,

where 𝐹 (y) is a vector-valued function with coordinate functions 𝑓𝑖 (y), for 𝑖 = 1, 2, . . . , 𝑁 . These
coordinate functions are defined as follows:
( )
2 𝑦2 − 𝛼
𝑓1 (y) = 𝑦2 − 2𝑦1 + 𝛼 − ℎ 𝑓 𝑥1 , 𝑦1 , ,
2ℎ
( )
𝑦3 − 𝑦1
𝑓2 (y) = 𝑦3 − 2𝑦2 + 𝑦1 − ℎ2 𝑓 𝑥2 , 𝑦2 , ,
2ℎ
..
. ( )
𝑦𝑁 − 𝑦𝑁 −2
𝑓𝑁 −1 (y) = 𝑦𝑁 − 2𝑦𝑁 −1 + 𝑦𝑁 −2 − ℎ2 𝑥𝑁 −1 , 𝑦𝑁 −1 , ,
2ℎ
( )
2 𝛽 − 𝑦𝑁 −1
𝑓𝑁 (y) = 𝛽 − 2𝑦𝑁 − 𝑦𝑁 −1 − ℎ 𝑥𝑁 , 𝑦𝑁 , .
2ℎ
This system of equations can be solved approximately using an iterative method such as Fixed-point
Iteration, Newton’s Method, or the Secant Method.

2
For example, if Newton’s Method is used, then, by the Chain Rule, the entries of the Jacobian
matrix 𝐽F (y), a tridiagonal matrix, are defined as follows:
( )
∂𝑓𝑖 𝑦𝑖+1 − 𝑦𝑖−1
𝐽F (y)𝑖𝑖 = (y) = −2 − ℎ2 𝑓𝑦 𝑥𝑖 , 𝑦𝑖 , , 𝑖 = 1, 2, . . . , 𝑁,
∂𝑦𝑖 2ℎ
( )
∂𝑓𝑖 ℎ 𝑦𝑖+1 − 𝑦𝑖−1
𝐽F (y)𝑖,𝑖+1 = (y) = 1 − 𝑓𝑦′ 𝑥𝑖 , 𝑦𝑖 , , 𝑖 = 1, 2, . . . , 𝑁 − 1,
∂𝑦𝑖+1 2 2ℎ
( )
∂𝑓𝑖 ℎ 𝑦𝑖+1 − 𝑦𝑖−1
𝐽F (y)𝑖,𝑖−1 = (y) = 1 + 𝑓𝑦 𝑥𝑖 , 𝑦𝑖 ,
′ , 𝑖 = 2, 3, . . . , 𝑁.
∂𝑦𝑖−1 2 2ℎ

Then, during each iteration of Newton’s Method, the system of equations

𝐽F (y(𝑘) )s𝑘+1 = −F(y(𝑘) )

is solved in order to obtain the next iterate

y(𝑘+1) = y(𝑘) + s𝑘+1

from the previous iterate. An appropriate initial guess is the unique linear function that satisfies
the boundary conditions,
𝛽−𝛼
y(0) = 𝛼 + (x − 𝑎),
𝑏−𝑎
where x is the vector with coordinates 𝑥1 , 𝑥2 , . . . , 𝑥𝑁 .
It is worth noting that for two-point boundary value problems that are discretized by finite
differences, it is much more practical to use Newton’s Method, as opposed to a quasi-Newton
Method such as the Secant Method or Broyden’s Method, than for a general system of nonlinear
equations because the Jacobian matrix is tridiagaonal. This reduces the expense of the computation
of 𝑠𝑘+1 from 𝑂(𝑁 3 ) operations in the general case to only 𝑂(𝑁 ) for two-point boundary value
problems. It can be shown that regardless of the choice of iterative method used to solve the
system of equations arising from discretization, the local truncation error of the finite difference
method for nonlinear problems is 𝑂(ℎ2 ), as in the linear case. The order of accuracy can be
increased by applying Richardson extrapolation.

You might also like