HIGHER ORDER METHODS School of Mathematics Semester 1 2008
OUTLINE 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY
OUTLINE 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY
OUTLINE 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY
OUTLINE 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY
EULER S METHOD Initial value problems for ODEs Euler s Method: w 0 = α w i+1 = w i + hf(x i, w i ), for each i = 0, 1,...,n 1 Local truncation error for Euler s method: τ i+1 (h) h 2 M.
OUTLINE Review 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY
ELIMINATING TRUNCATION ERRORS A second order method should approximate the equation: y i+1 = y i + hf(x i, y i ) + h2 2 f (x i, y i ) with local truncation error O(h 2 ). Then use a scheme of the form such that y i+1 = y i + a 1 f(x i + α 1, y i + β 1 ) a 1 f(x i + α 1, y i + β 1 ) = hf(x i, y i ) + h2 2 f (x i, y i )
ELIMINATING TRUNCATION ERRORS A second order method should approximate the equation: y i+1 = y i + hf(x i, y i ) + h2 2 f (x i, y i ) with local truncation error O(h 2 ). Then use a scheme of the form such that y i+1 = y i + a 1 f(x i + α 1, y i + β 1 ) a 1 f(x i + α 1, y i + β 1 ) = hf(x i, y i ) + h2 2 f (x i, y i )
MIDPOINT METHOD Review Then using a Taylor expansion we may choose the constants a 1, α 1 and β 1 to satisfy our second order equation One such choice is a 1 = h, α 1 = h/2 and β 1 = (h/2)f(x, y) gives the midpoint method w 0 = α w i+1 = w i + hf (x i + h/2, w i + (h/2)f(x i, w i )), We take evaluate the function f half way through the step to get a better approximation This is a Runge-Kutta method of order 2
MIDPOINT METHOD Review Then using a Taylor expansion we may choose the constants a 1, α 1 and β 1 to satisfy our second order equation One such choice is a 1 = h, α 1 = h/2 and β 1 = (h/2)f(x, y) gives the midpoint method w 0 = α w i+1 = w i + hf (x i + h/2, w i + (h/2)f(x i, w i )), We take evaluate the function f half way through the step to get a better approximation This is a Runge-Kutta method of order 2
MODIFIED EULER METHOD Now try a scheme of the form y i+1 = y i + a 1 f(x, y) + a 2 f (x i + α 1, y i + δ 1 f(x, y)) Again using the Taylor expansion we can choose the constants a 1 = h/2, a 2 = h/2, α 1 = h and δ 1 = h This gives the modified Euler method w 0 = α, w i+1 = w i + h 2 [f(x i, w i ) + f (x i+1, w i + hf(x i, w i ))]. This is a Runge-Kutta method of order 2
MODIFIED EULER METHOD Now try a scheme of the form y i+1 = y i + a 1 f(x, y) + a 2 f (x i + α 1, y i + δ 1 f(x, y)) Again using the Taylor expansion we can choose the constants a 1 = h/2, a 2 = h/2, α 1 = h and δ 1 = h This gives the modified Euler method w 0 = α, w i+1 = w i + h 2 [f(x i, w i ) + f (x i+1, w i + hf(x i, w i ))]. This is a Runge-Kutta method of order 2
OUTLINE Review 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY
RUNGE-KUTTA ORDER FOUR One of the most popular methods to solve an ODE is the Runge-Kutta method: w 0 = α, k 1 = hf(x i, y i ), ( k 2 = hf x i + h 2, w i + 1 ) 2 k 1 ( k 3 = hf x i + h 2, w i + 1 ) 2 k 2 k 4 = hf (x i+1, w i + k 3 ) w i+1 =w i + 1 6 (k 1 + 2k 2 + 2k 3 + k 4 ).
ALGEBRA Review The algebra required to arrive at the Runge-Kutta order four (RK4) method is tedious The idea is the same as with the midpoint and modified Euler methods... Match up and cancel out error terms. The local truncation error for the RK4 is unsurprisingly O(h 4 )
ALGEBRA Review The algebra required to arrive at the Runge-Kutta order four (RK4) method is tedious The idea is the same as with the midpoint and modified Euler methods... Match up and cancel out error terms. The local truncation error for the RK4 is unsurprisingly O(h 4 )
OUTLINE Review 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY
SOLVING A SYSTEM OF FIRST ORDER EQUATIONS We can solve a system of equations just as easily as a single equation Simply rewrite algorithms in vector form, for example so the jth equation is w 0 = α w i+1 = w i + hf(x i, w i ), w i+1,j = w i,j + hf j ( xi, w i,1,...,w i,m ),
SOLVING A SYSTEM OF FIRST ORDER EQUATIONS We can solve a system of equations just as easily as a single equation Simply rewrite algorithms in vector form, for example so the jth equation is w 0 = α w i+1 = w i + hf(x i, w i ), w i+1,j = w i,j + hf j ( xi, w i,1,...,w i,m ),
MODULAR PROGRAMMING We can use modular programming to allow functions to return arrays This allows for simple coding of the algorithms given above Example code: USE some_function_module REAL, DIMENSION(10) :: y x = a DO i = 1,n y = y + h*f(x,y) x = x+h ENDDO
ONE STEP METHODS Review All methods up to now have been one-step methods... using only w i to calculate w i+1 Methods that use more than one previous step are called multistep methods There are two types of multistep methods: Explicit; Implicit.
ONE STEP METHODS Review All methods up to now have been one-step methods... using only w i to calculate w i+1 Methods that use more than one previous step are called multistep methods There are two types of multistep methods: Explicit; Implicit.
OUTLINE Review 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY
MODIFIED EULER METHOD - REVISITED In the modified Euler method we can see that the last term is an approximation to the value of the function at x i+1 : f (x i+1, w i + hf(x i, w i )) f(x i+1, w i+1 ) This suggests we may use the implicit scheme
MODIFIED EULER METHOD - REVISITED In the modified Euler method we can see that the last term is an approximation to the value of the function at x i+1 : f (x i+1, w i + hf(x i, w i )) f(x i+1, w i+1 ) This suggests we may use the implicit scheme w 0 = α, w i+1 = w i + h 2 [f(x i, w i ) + f(x i+1, w i+1 )].
MODIFIED EULER METHOD - REVISITED In the modified Euler method we can see that the last term is an approximation to the value of the function at x i+1 : f (x i+1, w i + hf(x i, w i )) f(x i+1, w i+1 ) This suggests we may use the implicit scheme w 0 = α, w i+1 = w i + h 2 [f(x i, w i ) + f(x i+1, w i+1 )]. The value we must calculate now appears on both sides
OUTLINE Review 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY
THE GENERAL M-STEP METHOD The general m-step method can be written as: w i+1 =a m 1 w i + a m 2 w i 1 + + a 0 w i+1 m [ + h b m f(x i+1, w i+1 ) + b m 1 f(x i, w i ) ] + + b 0 f(x i+1 m, w i+1 m )
THE GENERAL M-STEP METHOD The general m-step method can be written as: w i+1 =a m 1 w i + a m 2 w i 1 + + a 0 w i+1 m [ + h b m f(x i+1, w i+1 ) + b m 1 f(x i, w i ) ] + + b 0 f(x i+1 m, w i+1 m ) If the scheme has b m = 0 then the scheme is explicit If the scheme has b m 0 the scheme is now implicit
EXAMPLE ADAMS-BASHFORTH FOUR-STEP METHOD This is an explicit method: w 0 = α 0, w 1 = α 1, w 2 = α 2 and w 3 = α 3 are calculated using a one-step method(rk4), then for i = 3, 4,...,n 1 we use w i+1 = w i + h [ 55f(x i, w i ) 59f(x i 1, w i 1 ) 24 ] + 37f(x i 2, w i 2 ) 9f(x i 3, w i 3 )
USING MULTISTEP METHODS don t involve as many function calls as their one-step equivalents Implicit methods are more stable and have smaller errors than their explicit counterparts However, they do require iteration This means that we may use them together, in a predictor-corrector method (1) Use the explicit method to guess solution - predict (2) Input guess into implicit method - correct (3) Results in small errors with small expense
USING MULTISTEP METHODS don t involve as many function calls as their one-step equivalents Implicit methods are more stable and have smaller errors than their explicit counterparts However, they do require iteration This means that we may use them together, in a predictor-corrector method (1) Use the explicit method to guess solution - predict (2) Input guess into implicit method - correct (3) Results in small errors with small expense
SUMMARY To make higher order methods, we must eliminate truncation errors There are often different methods with the same order We can use modular programming to implement the algorithms on a system of equations are less expensive Implicit schemes have smaller errors, but can be more expensive than explicit versions
SUMMARY To make higher order methods, we must eliminate truncation errors There are often different methods with the same order We can use modular programming to implement the algorithms on a system of equations are less expensive Implicit schemes have smaller errors, but can be more expensive than explicit versions