Chapter 8 - Numerical Methods For Boundary Value Problems

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

Lecture 35

Last lecture:
System of 1st orde ODEs and higher order ODE
Numerical instability

This lecture:

Methods for BVP


CHAPTER VIII
ODE’S—Boundary Value Problems
Objectives: develop methods for solving general 2nd order ODE's:

y"+ f(x, y, y') = 0, ax  b


c0y + k0 y' = q0 at x = a y
c1y + k1 y' = q1 at x = b
y(x) y(b)
 BVP
y(a)

a b x
8.1 Shooting Method

 A linear ODE example


𝑥
* Consider y" - (1 - 5) y = x
y(1) = 2, y(3) = -1.

* Note: y'(1) is not known—DIFFERENT from IVP


* Idea: If we guess a value for y'(1),
we can solve the ODE to x=3 with any very accurate method.
If y(x=3) matches the given B.C. at x=3, accept the solution.
If y(x=3) DOES NOT match y=-1 at x=3, adjust y(1) until the computed y(3) agree with the BC.
* Try Euler modified method with h = 0.2.
The results are as follows: Guessed G=y'(1) Resulting y(3) Comments
G1 = -1.5 R1 =4.811 too large
G2 = -3 R2 =0.453 still too large
G3 = -3.5 R3 =-1=D=Destination accept G3.
Shooting Method

* How to best estimate G3 based on previous values G1 and G2?


6
R Use linear extrapolation:
4 (G1, R1 ) 𝐺2 − G1
𝐺3 = 𝐺1 + (𝐷 − 𝑅1 )
𝑅2 − R1
2
−3 − −1.5
= −1.5 + −1 − 4.811 = −3.5
0 (G2, R2 ) 0.453 − 4.811

-2 This is a typical approach to continue the guess or shooting.


G3 G
-4 -3 -2 -1 0
In this problem, the ODE is linear so that G3 is exact.
 A nonlinear ODE example
* Consider solving the following using Euler modified method
𝑥
y" - (1 - 5) yy' = x, y(1) = 2, y(3) = -1
Guessed G= y'(1) Resulting y(3) G4 = -1.9460 R4 = -0.8932
G1 = -1.5 R1 = -0.0282 G5 = -2.0215 R5 = -1.0080
G2 = -3.0 R2 = -2.0752 G6 = -2.0162 R6 = -1.0002
G3 = -2.2138 R3 = -1.2719 G7 = -2.0161 R7 = -1.0000
 Third order ODEs u"' = f(x, u, u', u")

Two B.C.'s (u & u', or u' & u", or u & u") are given on one side (x=a)
and one BC is given on the other side (x=b).

Starting from the side with two B.C.'s, guess u"(x=a) (or u'(x=a)), & shoot for the other side.

 Fourth order ODEs’ u"" = f(x, u, u', u", u"')

* Typically we are given two conditions on one side and


need to shoot for two conditions on the other side.
* The guessing for two values becomes more difficult.
* Shooting is not generally recommended.
* Finite difference method is more robust.
8.2 Finite Difference Method

* Consider y" + b(x) y' + c(x) y = d(x) (1)


y(x=0) = y0, y(x=L)= y1 xi-1 xi+1
x
Finite difference for y' and y": h
x1 =0 xi xn =L
𝑦𝑖+1 −𝑦𝑖−1 𝑦𝑖+1 −2𝑦𝑖 +𝑦𝑖−1
y'i = , y"i =
2ℎ ℎ2

𝑦𝑖+1 −2𝑦𝑖 +𝑦𝑖−1 𝑦𝑖+1 −𝑦𝑖−1


⇒ + 𝑏𝑖 + 𝑐𝑖 𝑦𝑖 = 𝑑𝑖 (2)
ℎ2 2ℎ

ℎ ℎ
(1- 2 bi) yi-1 - (2-ci h2) yi + (1+ 2 bi) yi+1 = dih2 (3)

* Eq. (3) is a tri-diagonal system for i=2, 3, ... n-1


which can be solved efficiently using Thomas algorithm.
y1 and yn are known from the given BC's.
* Finite difference method is widely used for BVP problems.

* Errors: The truncation error is of O(h2) for Eq. (2) since y' and y" have O(h2) errors.
𝑥
* Example: Consider y" - (1 - 5) y = x, y(1) = 2, y(3) = -1.
Soln. • bi = 0, ci = -(1- xi /5), di = xi
• Choose h=0.5 (with 4 intervals)
 yi-1 - [2+(1-xi /5) h2] yi + yi+1 = xi h2 for i=2, 3 & 4.

• From BC's, y1 = 2, y5 = -1.


• With x1 = 1, x2 = 1.5, x3 =2, x4 =2.5, x5 =3.0,
2.5
𝑦2 −2 + 𝑥2 ℎ2 Solution y
−2.175 1 0 −1.625 2
 1 −2.15 1 𝑦3 = 𝑥3 ℎ2 = 0.5 1.5
0 1 −2.125 𝑦4 1 + 𝑥3 ℎ2 1.625
1
0.5
 y2 = 0.552, y3 = -0.424, y4 = -0.964
0
-0.5
* The solution using h=0.05:
-1
-1.5
1 1.5 2 2.5 3 x
8.3 Boundary Condition Given In Terms Of y'

𝑥
* Example: y" - (1 - 5) y = x, y'(1) = -3.5, y(3) = -1.
ℎ ℎ
Solution: + (1- 2 bi) yi-1 - (2-ci h2) yi (1+ 2 bi) yi+1 = dih2 (3)

bi = 0, ci = -(1-xi/5), di = xi x0 x2 xi-1 xi+1


choose h = 0.5 (with 4 intervals) x
h
x1 =1 xi xn =3
 yi-1 - [2+(1-xi /5) h2] yi + yi+1 = xi h2 for i=2, 3 & 4.
• y1 is not known, the above equation is needed at i=1 besides at i = 2, 3, & 4.
• In this case, a fictitious y0 at x0 = x1-h is then needed; it can be obtained as follows
𝑦𝑖+1 −𝑦𝑖−1
= y′ = -3.5 at i=1
2ℎ

so that y0 = y2 - 2hy1' = y2 +3.5 −2.2 2 0 0 𝑦1 −3.25


1 −2.157 1 0 𝑦2 0.375
• Thus at i=1, Eq. (3) gives y0 - 2.2 y1 + y2 = 0.52  𝑦3 =
0 1 −2.15 1 0.5
0 0 1 2.125 𝑦4 1.625
 y2 +3.5 - 2.2 y1 + y2 = 0.52
 -2.2y1 + 2 y2 = -3.25  (y1, y2, y3, y4) = (1.9638, 0.5352, -0.4344, -0.9691)

You might also like