0% found this document useful (0 votes)
136 views23 pages

Ordinary Differential Equations Boundary Value Problems: Copyleft 2005 by Media Lab 1

The document describes the shooting method for solving boundary value problems (BVPs). It discusses using the shooting method to solve both linear and nonlinear second-order BVPs. For linear problems, it involves solving two initial value problems (IVPs) and determining an unknown parameter to satisfy the boundary conditions. For nonlinear problems, it uses iterative techniques like secant or Newton's method. The document also introduces the finite difference method, which approximates derivatives in the BVP using finite differences to obtain a system of equations that can be solved.

Uploaded by

Mona Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views23 pages

Ordinary Differential Equations Boundary Value Problems: Copyleft 2005 by Media Lab 1

The document describes the shooting method for solving boundary value problems (BVPs). It discusses using the shooting method to solve both linear and nonlinear second-order BVPs. For linear problems, it involves solving two initial value problems (IVPs) and determining an unknown parameter to satisfy the boundary conditions. For nonlinear problems, it uses iterative techniques like secant or Newton's method. The document also introduces the finite difference method, which approximates derivatives in the BVP using finite differences to obtain a system of equations that can be solved.

Uploaded by

Mona Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Ordinary Differential Equations

Boundary Value Problems

Copyleft 2005 by Media Lab 1


14.1 Shooting Method for Solving Linear BVPs
We investigate the second-order, two-point boundary-value problem of
the form
y f ( x, y, y) ,a x b
with Dirichlet boundary conditions
y (a) , y (b)
Or Neuman boundary conditions
y(a ) , y(b)

Or mixed boundary condition


y(a) c1 y (a) , y(b) c 2 y (b)

Copyleft 2005 by Media Lab 2


14.1 Shooting Method for Solving Linear BVPs

Simple Boundary Conditions


y p( x) y q( x) y r ( x), a x b, y (a) ya, y (b) yb

The approach is to solve the two IVPs

u p ( x)u q ( x)u r ( x), u ( a ) ya , u (a ) 0,


v p ( x)v q( x)u , v ( a ) 0, v( a ) 1.

If v (b) 0, the solution of the original two-point BVP is given by


y(x) = u(x) + Av(x) is found from the requirement that y(b) = u(b) + Av(b) = yb

yb u (b) yb u (b)
A y ( x) u ( x) v( x).
v(b) v(b)

Copyleft 2005 by Media Lab 3


14.3 Shooting Method for Solving Linear BVPs

EX14.1
2
y y, y (1) 10, y (2) 0,
x

convert to the pair of initial-value problems


2
u u , u (1) 10, u (1) 0,
x
2
v v v (1) 0, v(1) 0,
x
2 2
w1 w2, wx w 2, w3 w4, w4 w 4,
x x

0 w1(b)
y ( x) w1 x w3( x).
w3(b)

Copyleft 2005 by Media Lab 4


14.1 Shooting Method for Solving Linear BVPs

General Boundary Condition at x = b


y p( x) y q( x) y r ( x)

The condition at x=b involves a linear combination of y(b) and y(b)

y (a) ya, y(b) cy (b) yb

The approach is to solve the two IVPs


u p ( x)u q ( x)u r ( x), u ( a ) ya , u (a ) 0,
v p ( x)v q( x)u , v ( a ) 0, v( a ) 1.

If v(b) cv (b) 0 there is a unique solution, given by


yb u(b) cu (b)
y ( x) u ( x) v( x).
v(b) cv(b)

Copyleft 2005 by Media Lab 5


14.3 Shooting Method for Solving Linear BVPs

General Boundary Condition at Both Ends of the Interval


y p( x) y q( x) y r ( x)
y(a) c1 y (a) ya, y(b) c 2 y (b) yb.

the approach is to solve two IVPs


u p ( x)u q ( x)u r ( x), u ( a ) 0, u ( a ) ya,
v p ( x)v q( x)u , v( a ) 1, v( a ) c1.

If v(b) c 2v(b) 0 , there is a unique solution, given by

yb u(b) c 2u (b)
y ( x) u ( x) v( x).
v(b) c 2v(b)

Copyleft 2005 by Media Lab 6


14.3 Shooting Method for Solving Linear BVPs

Ex 14.4
2x 2
y y y x 2
1, y (0) 1, y(1) y (1) 0.
x2 1 x2 1

y ( x 4 3x 2 x 6) / 6

Ex 14.5

2x 2
y y y x 2
1, y(0) y (0) 0, y(1) y (1) 3.
x 1
2
x 1
2

y x 4 / 6 3x 2 / 2 x 1

Copyleft 2005 by Media Lab 7


14.2 Shooting Method for Solving NonLinear BVPs

Nonlinear Shooting Based on the Secant Method


use an iterative process based on the secant method presented in
Chapter 2

y f ( x, y, y), y(a) ya , h( y (b), y(b)) 0,


the initial slope t, begin with u(a) = t(1) = 0, error is m(1)
Unless the absolute value of m(1) is less than the tolerance, we continue
by solving eq.

t (i 1) t (i 2)
t (i) t (i 1) m(i 1).
m(i 1) m(i 2)

Copyleft 2005 by Media Lab 8


14.2 Shooting Method for Solving NonLinear BVPs

EX 14.6

y 2 yy, y (0) 1, y (1) y(1) 0.25 0.

y = 1/(x+1)

Copyleft 2005 by Media Lab 9


14.2 Shooting Method for Solving NonLinear BVPs

Nonlinear Shooting Using Newtons Method


y f ( x, y, y), y(a) ya , y (b) yb .

begin by solving the initial-value problem

u f ( x, u , u), u (a ) ya , u (a) tk ,
v' ' vfu ( x, u , u) vf u ( x, u, u), v(a) 0, v(a) 1.

Check for convergence:


m u (b, tk ) yb ;

if |m| < tol, stop;


Otherwise, update t: tk 1 tk m / v(b, tk );

Copyleft 2005 by Media Lab 10


14.2 Shooting Method for Solving NonLinear BVPs

EX 14.8

[ y]2
y , y (0) 1, y (1) 2,
y

u [u]2 u 1 , u (0) 1, u(0) tk .


f u ( x, u, u) [u]2 (1)u 2 ,
f u ( x, u, u) 2[u]u1.

v v[u]2 u 2 v2[u]u1 , v (0) 0, v(0) 1.

Copyleft 2005 by Media Lab 11


14.3 Finite Difference Method for Solving Linear BVPs

Replace the derivatives in the differential equation by finite-difference


approximations (discussed in Chapter 11).
We now consider the general linear two-point boundary-value problem

y p( x) y q( x) y r ( x), a x b,

with boundary conditions


y (a) , y (b) ,

To solve this problem using finite-differences, we divide the interval [a, b]


into n subintervals, so that h=(b-a)/n. To approximate the function y(x) at
the points x1 a h, xn1 a (n 1)h, we use the central difference
formulas from Chapter 11:
yi 1 2 yi yi 1 yi 1 yi 1
y( xi ) , y ( xi )
h2 2h

Copyleft 2005 by Media Lab 12


Finite Difference Method for Solving Linear BVPs

Substituting these expressions into the BVP and writing p( xi ) as


____
pi , q( xi ) as qi , and r ( xi ) as ri gives
yi 1 2 yi yi 1 yi 1 yi 1
2
pi qi yi ri
h 2h
Further algebraic simplification leads to a tridiagonal system for
the unknowns y1 ,, yn1 , viz.
h h
1 pi yi 1 ( 2 h 2
qi ) yi 1 pi y i 1 h 2
ri , i 1,, n 1,
2 2

where y0 y(a) and yn y(b) .

Copyleft 2005 by Media Lab 13


Finite Difference Method for Solving Linear BVPs

Expanding this expression into the full system gives

h h
(2 h 2 q1 ) y1 1 p1 y2 h 2 r1 1 p1 ,
2 2
h h
1 p1 y1 (2 h q2 ) y2 1 p2 y3 h 2 r2 ,
2

2 2

h h
1 pi yi 1 (2 h qi ) yi 1 pi yi 1 h 2 ri ,
2

2 2

h h
1 p1n 2 yn 3 (2 h qn 2 ) yn 2 1 pn 2 yn 1 h rn 2 ,
2 2

2 2
h h
1 pn 1 yn 2 (2 h qn 1 ) yn 1 h rn 1 1 pn 1 ,
2 2

2 2

Copyleft 2005 by Media Lab 14


Example 14.9 A Finite-Difference Problem

Use the finite-difference method to solve the problem


y y x( x 4), 0 x 4,
with y(0)=y(4)=0 and n=4 subintervals.
Using the central difference formula for the second derivative, we
find that the differential equation becomes the system.
yi 1 2 yi yi 1
y( xi ) 2
yi xi ( xi 4), i 1,2,3.
h
For this example, h = 1 ,i =1, y = 0, and i = 3, y = 0. Substituting
this values, we obtain
y2 2 y1 0 y1 1(1 4),
y3 2 y2 y1 y2 2(2 4),
0 2 y3 y2 y3 3(3 4).

Copyleft 2005 by Media Lab 15


Example 14.9 A Finite-Difference Problem

Combining like terms and simplifying gives


3 y1 y2 3,
y1 3 y2 y3 4,
y2 3 y3 3,
Solving, we find that y_1=13/7, y_2 = 18/7, and y_3 = 13/7.
We note for comparison that the exact solution of this problem is

2(1 e 4 ) x 2(1 e 4 ) x
y 4 4 e 4 4 e x 2 4 x 2.
e e e e

Copyleft 2005 by Media Lab 16


Example 14.9 A Finite-Difference Problem

Copyleft 2005 by Media Lab 17


Example 14.10 A Matlab Script for a Linear FDP.
The Matlab script that follows solves the BVP.
y 2 y 2 y, y(0) 0.1, y(3) 0.1e3cos(3).
function S_linear_FD
aa = 0; bb = 3; n = 300;
p = 2*ones(1, n-1); q = -2*ones(1, n-1); r = zeros(1, n-1);
ya = 0.1; yb = 0.1*exp(3)*cos(3);
h = (bb-aa)/n; h2 = h/2; hh= h*h;
x = linspace(aa+h, bb, n);
a = zeros(1, n-1); b = a;
a(1:n-2) = 1 - p(1, 1:n-2)*h2; d = -(2 + hh*q);
b(2:n-1) = 1 + p(1, 2:n-1)*h2;
c(1) = hh*r(1) - (1+p(1)*h2)*ya;
c(2:n-2) = hh*r(2:n-2);
c(n-1) = hh*r(n-1) - (1 - p(n-1)*h2)*yb;
y = Thomas(a, d, b, c)
xx = [aa x]; yy = [ya y yb];
out = [xx' yy']; disp(out)
plot(xx, yy), grid on, hold on
plot(xx, 0.1*exp(xx).*cos(xx))
hold off

Copyleft 2005 by Media Lab 18


Example 14.10 A Matlab Script for a Linear FDP.

Copyleft 2005 by Media Lab 19


14.4 FDM for Solving Nonlinear BVPs

We consider the nonlinear ODE-BVP of the form


y 2 y 2 y, y(0) 0.1, y(3) 0.1e3cos(3).
Assume that there are constants Q* , Q* and P * such that
0 Q* f y ( x, y, y) Q* and | f y ( x, y, y) | P*
Use a finite-difference grid with spacing h 2 / P* ,and let f i denote
the result of evaluating f at xi using ( yi 1 yi 1 ) /( 2h) for yi .
The ODE then becomes the system
yi 1 2 yi yi 1
2
f i 0.
h
An explicit iteration scheme, analogous to the SOR method
yi
1

2(1 )

yi 1 2yi yi 1 h 2 f i ,

where y0 and yn . The process will converge for w h 2Q* / 2.

Copyleft 2005 by Media Lab 20


Example 14.12 Solving a Nonlinear BVP by Using FDM

Consider again the nonlinear BVP

y
y
2
, y (0) 1, y (1) 2.
y
We illustrate the use of the iterative procedure just outlined by
taking a grid with h = . The general form of the difference equation
is
yi
1
2(1 )

yi 1 2yi yi 1 h 2 f i ,
where

fi
( yi 1 yi 1 ) /( 2h)
2

yi21 2 yi 1 yi 1 yi21
.
yi 4h yi (1 )
2

Copyleft 2005 by Media Lab 21


Example 14.12 Solving a Nonlinear BVP by Using FDM

Substituting the rightmost expression for f_i into the equation for
y_i, we obtain
1 yi21 2 yi 1 yi 1 yi21
yi yi 1 2yi yi 1 .
2(1 ) 4 yi
The computed solution after 10 iterations agrees very closely with
the exact solution.
function S_nonlinear_FD
ya = 1; yb = 2; a = 0; b = 1;
max_it = 10; n = 4; w = 0.1; ww = 1/(2*(1+w)); h = (b-a)/n
y(1:n-1) = 1
for k = 1:max_it
y(1) = ww*(ya+2*w*y(1)+y(2)+(ya^2-2*ya*y(2)+y(2)^2)/(4*y(1)));
y(2) = ww*(y(1)+2*w*y(2)+y(3)+(y(1)^2-2*y(1)*y(3)+y(3)^2)/(4*y(2)));
y(3) = ww*(y(2)+2*w*y(3)+yb+(y(2)^2-2*y(2)*yb+yb^2)/(4*y(3)));
end
x = [ a a+h a+2*h a+3*h b ]; z = [ ya y yb ];
plot(x, z), hold on, zz = sqrt(3*x+1); plot(x, zz), hold off

Copyleft 2005 by Media Lab 22


Example 14.12 Solving a Nonlinear BVP by Using FDM

Copyleft 2005 by Media Lab 23

You might also like