Eulers Method
Model Problem:
x ' = f (t , x) x(t0 ) = x0
(1) Only a few of them that we can find analytic solutions. For example when f (t , x ) = p (t ) x + g (t ) , we can use integrating factor to solve the problem analytically. In general, we need to find the solution numerically, which means, instead of finding a analytic expression of the solution x(t ) , we need a table of the values of the solutions
t0 x0
t1 x0
t2 x2
t3 x3
tm xm
xi x(ti ) is computed approximate value of x(ti ) .
( ) t usually is time, so thin! about that we start from t0 which is given, then try to find x (t1 ) at time t1 .
First. "iven the value x(t0 ) , consider the value of x(t1 ) = x( x0 + h) . #y $aylor expansion%
x (t 0 + h ) = x (t 0 ) + hx '(t 0 ) +
h2 h3 x ''(t 0 ) + x '''(t 0 ) + 2! 3!
&hen h is small, h ' 1 , we can drop the high order terms, then
x(t1 ) = x( x0 + h) x (t0 ) + hx '(t0 ) = x (t0 ) + hf (t0 , x (t0 )) , x(t1 ) x1 = x0 + hf (t0 , x0 ) .
(econdly, )ow we have x1 x(t1 ) , we want to find the value of x(t2 ) = x(t1 + h) .
h2 h3 x (t1 + h ) = x (t 1 ) + hx '(t 1 ) + x ''(t 1 ) + x '''(t 1 ) + 2! 3!
*rop the high order terms, then 1
x(t2 ) = x( x1 + h) x(t1 ) + hx '(t1 ) x1 + hf (t1 , x1 ) x(t2 ) x2 = x1 + hf (t1 , x1 ) .
$hen we can do this successively% "iven xi 1 x(ti 1 ) , we want to find the value of x(ti ) = x(ti 1 + h) .
x(ti ) = x(ti 1 + h) = x(ti 1 ) + hx '(ti 1 ) +
h2 h3 x ''(ti 1 ) + x '''(ti 1 ) + + 2! 3!
*rop the high order terms, then
x(ti ) = x ( xi 1 + h) x(ti 1 ) + hx '(ti 1 ) xi 1 + hf (ti 1 , xi 1 ) x(ti ) xi = xi 1 + hf (ti , xi ) .
x x ' = Example. t . (exact solution% x(t ) = t ) x(1) = 1
2x x ' = Example. t . (exact solution% x(t ) = t 2 ) x(1) = 1
Taylor Series Method
Eulers method% {t = ti 1 , x (ti 1 ) xi 1} {t = ti , x(ti ) xi }
h2 h3 x (t i ) = x (t i 1 + h ) = x (t i 1 ) + hx '(t i 1 ) + x ''(t i 1 ) + x '''(t i 1 ) + 2! 3!
*rop the high order terms, then
x(ti ) xi = xi 1 + hf (ti , xi ) .
)ow consider Taylor series methods:
x (t i ) = x (t i 1 + h ) = x (t i 1 ) + hx '(t i 1 ) +
h2 h3 x ''(t i 1 ) + x '''(t i 1 ) + 2! 3!
,eep one more term than -uler.s method,
x(ti 1 ) xi 1 x '(ti 1 ) = f (ti 1 , x (ti 1 )) f (ti 1 , xi 1 ) x ''(ti 1 ) = ( f (t , x(t ))) ' |t =ti1 = ( f '+ = f '(ti 1 , x(ti 1 )) + f '(ti 1 , xi 1 ) +
$herefore
f (ti 1 , xi 1 ) f (ti 1 , xi 1 ), x
f (ti 1 , x(ti 1 )) f (ti 1 , x(ti 1 )) x
f x ') |t =ti1 x
h2 x(ti ) xi = xi 1 + hf (ti 1 , xi 1 ) + [ f t (ti 1 , xi 1 ) + f x (ti 1 , xi 1 ) f (ti 1 , xi 1 )] . 2!
Example. $ry to use $aylor (eries 0ethod to solve this initial value problem%
x ' = cos t sin t + t 2 x (1) = 3
Runge-Kutta Methods
#asically, what we do for $aylor (eries 0ethod is the following%
x(t + h) = x(t ) + hx '(t ) +
h2 x ''(t ) + O(h3 ), 2!
x '(t ) = f , x ''(t ) = f ' = f t + f x x ' = f t + f x f .
)oticed that this involves the partial derivative of f which may not so easy to get. &e try to express f t , f x in terms of f directly. (ince
f (t + h, x + hf ) = f + hf t + hff x + O (h 2 ) ,
then
f t + ff x = ( f (t + h, x + hf ) f ) / h + O( h) ,
so
h x (t + h ) = x (t ) + hf (t , x ) + (f (t + h , x + hf ) f ) + O ( h 3 ) , 2
i.e.
x (t + h ) = x (t ) +
h h f (t , x ) + (f (t + h , x + hf (t , x ))) + O ( h 3 ) . 2 2
)ow we have Heuns Methods (RK
Method!
&e want to find {t = ti 1 , x (ti 1 ) xi 1} {t = ti , x(ti ) xi } , we can do that in this way% Heuns Method:
F1 = hf (ti 1 , xi 1 ), F2 = hf (ti , xi 1 + F1 ), 1 1 xi = xi 1 + F1 + F2 . 2 2
In general,
x(t + h) = x(t ) + w1hf (t , x ) + w2 hf (t + h, x + hf ) + O( h3 ),
x(t + h) = x (t ) + w1hf (t , x ) + w2 h ( f + hf t + hff x ) + O (h 3 ) = x(t ) + ( w1 + w2 )hf + h 2 ( w2 f t + w2 ff x ) + O( h3 ),
Only need
w1 + w2 = 1 1 w2 = 2 1 w2 = 2
(1 un!nowns, / e2uations).
$his linear system has many solutions, different solution corresponding to different method. For example%
1 w1 = 2 1 4eun.s 0ethod w2 = . 2 = 1 = 1
&e can also choose the following solution, which gives us the so5called Modi"ied Euler Method
w1 = 0 w = 1 2 1 = modi"ied Euler Method. 2 1 = 2
Modified Euler Method:
1 1 x(ti ) = x(ti 1 + h) = x(ti 1 ) + hf (ti 1 + h, x(ti 1 ) + hf (ti 1 , x(ti 1 ))) , 2 2
F1 = hf (ti 1 , xi 1 ), 1 1 F2 = hf (ti 1 + h, xi 1 + F1 ), 2 2 xi = xi 1 + F2 .
0oreover, we can !eep more terms in the $aylor expansion, and do the exact same procedure as before. $his will give us high order numerical method for initial value problems. $hese methods usually are called 6unge5,utta Familay, and the following is a fourth5order 6unge5,utta 0ethod% 4th Order Runge-Kutta Method:
F1 = hf (t , x), F2 = hf (t + 1 h, x + 1 F1 ), 2 2 1 1 F3 = hf (t + h, x + F2 ), 2 2 F4 = hf (t + h, x + F3 ), x(t + h) = x(t ) + 1 ( F1 + 2 F2 + 2 F3 + F4 ). 6
#mpli$it Method
$he differential e2uation solvers we have presented so far are explicit, meaning that there is an explicit formula for the new approximation in terms of !nown data. It turns out that some differential e2uations are poorly served by explicit methods. 4ere, we will introduce the implicit method.
%a$&'ard Euler Method:
x i +1 = x i + hf (t i +1 , x i +1 )
$he difference is% -uler.s method uses the old approximation to obtain the new one without solving an e2uation, bac!ward -uler method need to solve a e2uation to get a new approximation.
Example: use -uler.s method and #ac!ward -uler.s method to solve the following I89%
x ' = 10(1 x ) x (0) = 1/ 2
()ote% the iterative scheme can be viewed as a fixed5point iteration, we can consider the convergence rate by what we learnt from F9I.)
Stability: $he stability of a method can be even more important than its accuracy. )ext example will show you why bac!ward -uler method is stable.
Example: solve the following I89
x ' = 100x x (0) = 1
Example: use #ac!ward -uler method to solve the following I89
x ' = x + 8x ^ 2 9 x ^ 3 x (0) = 1/ 2