0% found this document useful (0 votes)
112 views478 pages

Maths Complete Notes

This document presents an example of using the finite difference method to solve a two-point boundary value problem (BVP). Specifically, it solves the BVP where y''= y + x(x-4) on the interval [0,4] with boundary conditions y(0)=y(4)=0. The interval is divided into 4 subintervals of width h=1. This leads to a system of 3 algebraic equations that can be solved to find the approximate solution y1, y2, y3 at points x1=1, x2=2, x3=3. The numerical solution found is y1=13/7, y2=18/7, y3=13/7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views478 pages

Maths Complete Notes

This document presents an example of using the finite difference method to solve a two-point boundary value problem (BVP). Specifically, it solves the BVP where y''= y + x(x-4) on the interval [0,4] with boundary conditions y(0)=y(4)=0. The interval is divided into 4 subintervals of width h=1. This leads to a system of 3 algebraic equations that can be solved to find the approximate solution y1, y2, y3 at points x1=1, x2=2, x3=3. The numerical solution found is y1=13/7, y2=18/7, y3=13/7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 478

Example 6.

17 'Given the initial value problem


u' = -2 tu 2 , u(0) =1
estimate u (0.4) using (i) modified Euler-Cauch y method, and (ii) Heun method, with h = 0.2. Compare
the results with the exact solution u (t) = 1/(1 + t ).
2

(i) The modified Euler-Cauc hy method is given by


- 1 =u-+K
u J+ J 2

where
and
For j = 0, we have
t0 = 0, u0 = I, K 1 = 0, = -0.4 (0.1) (1)2 = -0.04.
K2

u (0.2) = u 1 = u 0 + K 2 = 1 - 0.04 = 0.96.

For j = 1, we have
!1 = 0.2, U1 = 0.96, K1 = -0.4 (0.2) (0.96)2 = -0.073728.
2
K 2 = - 0.4 (0.2 + 0.1) (0. 96 - 0.036864) = - 0.102262.

u(0.4) = u 2 = u 1 + K 2 = 0.96 - 0.102262 = 0.857738.


(ii) The Heun method is given by
1
uj+t = uj + 2 (Ki + K2)
where K 1 = hf(ti' u j) = - 0.4 tj u;

and K2 = hf(tj + h, uj + Ki) = -0.4(tj + 0.2) (uj + Ki/-


For j = 0, we have
t0 = 0, u 0 = I, Ki = o, K2 = -0.4 (0.2) (1)2 = - 0.08.
1 1
u (0.2) = u 1 = u0 + (K1 + K 2 ) = I + (- 0.08) = 0.96.
2 2
For j = I, we have
ti = 0.2, U1 = 0.96, K1 = -0.4(0.2) (0.96)2= - 0.073728.
K2 = - 0.4 (0.2 + 0.2) (0.96 - 0.073728)2 = - 0.125676.
u (0 .4 ) = u2 = u1 + _!_ (K + K ) = 0 . 9 6 + 1 (- 0 .0 7 3 7 2 8 25676
2 I 2 - O. l
2 '
= 0 .8 6 0 2 9 8 .
T he ex ac t so lu ti on is
u (0 .2 ) = 0 .9 6 1 5 3 8 , u
T he ab so lu te er ro rs in (0 .4 ) = 0 .8 6 2 0 6 9 •
th e nu m er ic al so lu ti o n
M od if ie d E ul er -C au ch
y m et ho d: e (0 .2 ) == s ar e:
H eu n m et h o d : e (0 .2 )
0 .0 0 1 5 3 8 , £ (0 .4 )
== 0 .0 0 1 5 3 8 , e (0 .4 )
= 0 .0 04 3 3 1 ·
E xa m o le Ii 1R ~
= 0 .0 0 1 7 7 1 .
Section 14.2 Finite-Difference Method 599

The General Linear BVP


We now consider the general linear two-point boundary-value problem

= p(x)y' + q(x)y + r(x), a~ x b


y"

with boundary conditions y(a) = a, y(b) = /3. 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 x 1 = a+h, ... , Xn-l = a+ (n- l)h,
we use the central difference formulas from Chapter 11:

y
"( ) ~~ Yi+l -
Xi
2yi
h2
+ Yi-1
' y
'(
Xi
) ' Yi+l - Yi-1
2h

Substituting these expressions into the BVP and writing p(xi) as Pi, q(xi) as
q;, and r(xi) as r; gives

Yi+l - 2yi + Yi-1 Yi+l - Yi-1


h2 = Pi 2h + q.y. + Ti
Further algebraic simplification leads to a tridiagonal system for the unknowns
y 1 , . . . , Yn-1 - that is, for i = 1, . . . , n - 1,

(2 + h Pi)Y;-1 - (4 + 2h2 q;)Yi + (2 - h p;)Yi+l = 2h2 ri


where y0 = y(a) = a and Yn = y(b) = /3.
Using the boundary conditions and simplifying gives:
first (for i = 1),
-(4 + 2h2 qi)y 1 + (2 - hpi)y2 = 2h2r1 - o(2 + hp1)

t hen (for i = 2, . .. ,n - 2) ,
(2 + hp.~Yi-1 - (4 + 2h 2 qi)Yi + (2 - hp;)Yi+l = 2h2r;
and , finally (for i = n- 1),
(2 + hPn-l)Yn-2 - (4 + 2h2 qn-dYn-1 = 2h2 Tn-1 - /3(2 - hPn-1)

The system in matrix form is Ay = b, with A


-(4 + 2h 2 qi) (2 - hpi)
(2 + hP2) -(4 + 2h 2q2)

(2 + hp.) (2 - hp.)

-(4 + 2h 2qn-2) (2 - hPn-2)


(2 + hPn-1) -(4 + 2h 2 Qn-d

L
EXAMPLE 14.5 A Finite-Difference Problem
Use the finite-difference method to solve the problem

y
11
= y +X(X - 4), 0$ X $ 4

with y(O) = y(4) = 0 and n = 4 subintervals. The finite-difference method will find
an approximate solution at the points x 1 = 1, x 2 = 2, and X3 = 3. Using the central
difference formula for the second derivative, we find that the differential equation
becomes the system

Yi+ 1 2yi + Yi-1 = y,· + X·, (X ,· - 4) ,


YII ( X·, ) -
:=::::; - - - - - : h
2
--::----
i = 1, 2, 3
For this example, h = 1. In writing out the system of algebraic equations, we make
use of t}:te fact that at i = 1; yg = 0 (from the boundary condition at x = 0), and
similarly, at i = 3, y4 = 0. Substituting in the values of x 1 , x 2 , ·and x we obtain
3

Y2 - 2y1 + 0 = Y1 + 1(1 -
4}
Y3 - 2y2 + Y1 = Y2 + 2(2 - 4)
0 - 2y3 + Y2 = y3 + 3(3 - 4)
Combining like terms and simplifying gives

-3y1 + Y2 =-3
Y1 - 3y2 +y3 =-4
+ Y2 -3y3 =-3

Solving, we find that Y1 = 13/7, Y2 18/7, and y3 = 13/7. =


We note for comparison that the exact solution of this problem is

2(1 - e4 ) 2(1 - e- 4 ) :i:


y = --:-----:-e
e-4 - e4
-:i:
- -e-4 -e - x2
~ -- :e4 + 4x - 2

At x = 1, the exact solution is 1.8341 (to four decimal places) ; the finite-difference
solution is Y1 = 13/7 = 1.8571.
+X T in( m)
h: 0-2S
) 3 ) =o,

J. y ) Jl»)D No:

- ?

(24) i)= o

-(u2)***i

m a
0 tAS3*1

1 o 3S Pao
(

al44)

(44)
4-

130

ol&) ol4') o4)

30

SL

120

(4)-°)

You might also like