Course: Numerical Solution of Ordinary Differential Equations
Module5: Non-linear Boundary value problems
Lecture Content Hours
1 Solution by Finite Difference Methods 1
2 Shooting Method 2
Lecture 1
Solution by Finite Difference Methods
Solution by Finite Difference Methods
Consider two point non-linear boundary value problem with Dirichlet’s boundary
conditions
y f(y, y, x); axb
(5.1)
y(a) , y(b)
The function f is a non-linear function of dependent variable and its derivatives. The
finite differences as discussed for linear boundary value problem can be applied to
nonlinear differential equation also to reduce it to algebraic system of equations which
will no more be linear. Replacing the derivative with finite differences at N-1equispaced
internal grid points give
y y ba
(yi1 2yi yi1) h2 f(xi,yi, i1 i1 ) 0; i 1,2,...,N 1,h
2h N
Let the solution vector of the BVP at given N+1 grid points (N-1 internal and 2 boundary
points) be
Y [y0 ,y1,y2,...,yN1,yN ]T
Due to Dirichlet boundary conditions
y 0 , yN
Write the system of equations in the matrix form as
G[Y ] [g0 (Y),g1(Y),...,gN1(Y),gN (Y)]T 0 (5.2)
Such that
g0(Y) y0 ; gN(Y) yN ;
2 yi1 yi1 b a (5.3)
g(Y)
i (yi1 2yi yi1) h f(x ,y
i i , ); i 1,2,...,N 1,h
2h N
The system (5.2) is a nonlinear system of N+1equations in N+1 unknowns. The
Newton’s iterative method can be used to solve the system numerically. This method is
a generalization of Newton-Raphson iterative scheme for finding roots of nonlinear
equation g(x)=0, N=1. According to Newton’s method, the sequence of iterations are
given as:
1
g(y(n) )
y(n ) y(n) y(n) v(n)
g(y )
(n)
0
1
2
3
v (n)g(y(n) ) g(y(n) ),n , , , ,...
For the system of equations, the derivative is replaced by Jacobian:
0 0 1 0
0 1 1 1
0
g g g
y .
y yN
1
g g g
.
J(Y)= y y yN
. . . .
gN gN
.
gN
0
y y yN
According to Newton’s method for solving (5.2), the sequence of iterations are given by
1
Y(n ) Y(n) v (n) (5.4)
The update vector v (n) is given by
J(Y (n) )v (n) G(Y (n) ) (5.5)
Since gi , i=1,2,…N-1 involves yi-1,yi and yi+1 only, various partial derivatives in the
Jacobian are computed as
1
1
1
gi h f y yi
(xi,yi, i
2
)
1
yi y h
2
1
2
gi f y yi
(xi,yi, i
2
h )
yi y h
12
1
1
gi h f y yi
(xi,yi, i
2
)
1
yi y h
0 0
g gN
Also, ;
y yN
Since gi involves yi-1,yi and yi+1 only, the rows in J(Y) will have at the most three non-
zero entries except in the first and last row and the Jacobian J is tri-diagonal:
1
0
0
0
. .
0
l
1
d u . .
. . . . . .
0
J(Y)
. li di ui .
. 0 . . . . .
0
0
1
. . NXN
where
2
12
1
2
1
f y yi
0
di h (xi,yi, i ),d
y h
12
1
1
0
h f y yi
0
(xi,yi, i
2
ui ),lN u (5.6)
y h
1
1
1
h f y yi
(xi,yi, i 1
2
li ),dN
y h
The initial guess for the solution is obtained using line passing through the point
(a, )and(b, ) :
0
ba
yi( ) (xi a); xi a ih,h
ba N
0
0
1
2
Or yi( ) i i , , ,...,N (5.7)
N
The method is illustrated for Dirichlet boundary conditions in the example.
Example 5.1: Solve the second order ordinary differential equation with Dirichlet type
boundary conditions:
yy y2 2 0;1 x 2; y(1) 0; y(2) 1
Solution: Consider the differential equation with Dirichlet boundary conditions
yy y 2 2 0 , y 0 0, yN 1
Rewriting the equation as
y2 2
y f(x,y,y)
y
f 1 y2 f 2y
or` ;
y i y 2 i y i y i
According to the problem y 0 0, yN 1 .
Let N=5;h=0.2. The Jacobian matrix J of order is obtained using (5.6) as
2
4
1 4
1
h (y y )
2
1
0
di i i ,d
yi
12
1
1
0
y yi
0
ui i ,lN u (A)
hyi
12
1
1
1
y yi
li i ,dN
hyi
The initial guess is obtained using (5.7):
y2 2
y f(x,y,y)
y
y y ba
gi (Y) (yi1 2yi yi1) h2 f(xi,yi, i 1 i1 ); i 1,2,...,N 1,h
2h N
y y
G(Y) [(yi1 2yi yi1) h2 (2 ( i1 i1 )2 / yi ]
2h
y y
G(Y) [( yi1 2yi yi1) (2h2 ( i1 i 1 )2 / yi ]
2
1 0 0 1
-0.83333 2.066667 -1.16667 -0.06667 The system
-0.83333 2.057143 -1.14286 -0.05714
of equations
-0.85714 2.05 -1.125 -0.05
-0.875 2.044444 -1.11111 -0.04444 is now
1 2
solved using
iterative method. The detailed solution is given in the excel file nonlinear
BVPnewton.xls . The final solution of nonlinear BVP is given in the table. The solution is
converging to the exact solution of the problem.
iteration x 1 1.2 1.4 1.6 1.8 2
initial y 1 1.2 1.4 1.6 1.8 2
1 y 1 1.313385 1.543711 1.726003 1.875667 2
2 1 1.323542 1.558232 1.740394 1.885025 2
3 1 1.324788 1.560191 1.742175 1.886067 2
4 1 1.32495 1.560447 1.742408 1.886201 2
5 1 1.324971 1.56048 1.742438 1.886218 2
exact 1 1.32665 1.56205 1.74356 1.886796 2
Table 5.1 Solution for example 5.1