Numerical Analysis Lecture 39 Chapter 7 Ordinary Differential Equations Introduction Taylor Series Euler Method Runge-Kutta Method Predictor Corrector Method PREDICTOR – CORRECTOR METHOD The methods presented so far are called single-step methods, where we have seen that the computation of y at tn+1 that is yn+1 requires the knowledge of yn only. In predictor-corrector methods which we will discuss now, is also known as multi-step methods. To compute the value of y at tn+1, we must know the solution y at tn, tn-1, tn-2, etc. Thus, a predictor formula is used to predict the value of y at tn+1 and then a corrector formula is used to improve the value of yn+1. Let us consider an IVP dy f (t , y ), dt y (tn ) yn Using simple Euler’s and modified Euler’s method, we can write down a simple predictor-corrector pair (P – C) as h (1) (0) C : yn1 yn f (tn , yn ) f (tn 1 , yn 1 ) 2 (0) n 1 P: y yn hf (tn , yn ) (1) Here, yn+1 is the first corrected value of yn+1. The corrector formula may be used iteratively as defined below: y (r ) n 1 h yn f (tn , yn ) f (tn 1 , yn( r11) ) , 2 r 1, 2, The iteration is terminated when two successive iterates agree to the desired accuracy In this pair, to extrapolate the value of yn+1, we have approximated the solution curve in the interval (tn, tn+1) by a straight line passing through (tn, yn) and (tn+1, yn+1). The accuracy of the predictor formula can be improved by considering a quadratic curve through the equally spaced points (tn-1, yn-1), (tn, yn), (tn+1, yn+1) Suppose we fit a quadratic curve of the form y a b(t tn1 ) c(t tn )(t tn1 ) where a, b, c are constants to be determined As the curve passes through (tn-1, yn-1) and (tn, yn) and satisfies dy f (tn , yn ) dt (tn , yn ) we obtain yn1 a, yn a bh yn1 bh Therefore yn yn 1 b h and dy f (tn , yn ) {b c[(t tn1 ) (t tn )]}(tn , yn ) dt (tn , yn ) Which gives f (tn , yn ) b c(tn tn1 ) b ch or f (tn , yn ) ( yn yn 1 ) c 2 h h Substituting these values of a, b and c into the quadratic equation, we get yn1 yn1 2( yn yn1 ) 2[hf (tn , yn ) ( yn yn1 )] That is, yn1 yn1 2hf (tn , yn ) Thus, instead of considering the P-C pair, we may consider the P-C pair given by P : yn1 yn 1 2hf (tn , yn ) h C : yn1 yn [ f (tn , yn ) f (tn1 , yn1 )] 2 The essential difference between them is, the one given above is more accurate However, this one can not be used to predict yn+1 for a given IVP, because its use require the knowledge of past two points. In such a situation, a R-K method is generally used to start the predictor method. Milne’s Method It is also a multi-step method where we assume that the solution to the given IVP is known at the past four equally spaced point t0, t1, t2 and t3. To derive Milne’s predictorcorrector pair, let us consider a typical IVP dy f (t , y ), dt y (t0 ) y0 On integration between the limits t0 and t4, we get t4 t0 t4 dy dt f (t , y )dt t 0 dt t4 y4 y0 f (t , y)dt t0 But we know from Newton’s forward difference formula s( s 1) 2 s ( s 1)( s 2) 3 f (t , y ) f 0 sf 0 f0 f0 2 6 where y4 y0 t4 t0 t t0 s , h t t0 sh s( s 1) 2 s( s 1)( s 2) 3 f0 f 0 sf 0 2 f 0 6 s( s 1( s 2)( s 3) 4 f 0 dt 24 Now, by changing the variable of integration (from t to s), the limits of integration also changes (from 0 to 4), and thus the above expression becomes y4 y0 h 4 0 s( s 1) 2 s( s 1)( s 2) 3 f0 4 f 0 sf 0 2 f 0 6 s( s 1( s 2)( s 3) 4 f 0 ds 24 which simplifies to 20 2 8 3 28 4 y4 y0 h 4 f 0 8f 0 f 0 f 0 f 0 3 3 90 Substituting the differences f0 f1 f0 , 2 f0 f2 2 f1 f0 , It can be further simplified to 4h 28 4 y4 y0 (2 f1 f 2 2 f3 ) h f 0 3 90 Alternatively, it can also be written as 4h 28 4 y4 y0 (2 y1 y2 2 y3 ) h y0 3 90 This is known as Milne’s predictor formula. Similarly, integrating the original over the interval t0 to t2 or s = 0 to 2 and repeating the above steps, we get h 1 4 y2 y0 ( y0 4 y1 y2 ) h y0 3 90 which is known as Milne’s corrector formula. In general, Milne’s predictorcorrector pair can be written as 4h P : yn 1 yn 3 (2 yn 2 yn 1 2 yn ) 3 h C : yn 1 yn 1 ( yn 1 4 yn yn 1 ) 3 From these equations, we observe that the magnitude of the truncation error in corrector formula is (1/ 90)h y , while the truncation error in predictor formula is (28/ 90) y . 4 0 4 0 Thus: TE in, c-formula is less than the TE in p-formula. In order to apply this P – C method to solve numerically any initial value problem, we first predict the value of yn+1 by means of predictor formula, where derivatives are computed using the given differential equation itself. Using the predicted value yn+1, we calculate the derivative y’n+1 from the given differential equation and then we use the corrector formula of the pair to have the corrected value of yn+1 This in turn may be used to obtain improved value of yn+1 by using corrector again. This in turn may be used to obtain improved value of yn+1 by using the corrector again. This cycle is repeated until we achieve the required accuracy. Example Find y (2.0) if y ( t ) is the solution of dy 1 (t y ) dt 2 y (0) = 2, y (0.5) = 2.636, y (1.0) = 3.595 and y(1.5) = 4.968 Use Milne’s P-C method. Solution Taking t0 = 0.0, t1 = 0.5, t2 = 1.0, t3 = 1.5 y0, y1, y2 and y3, are given, we have to compute y4, the solution of the given differential equation corresponding to t =2.0 The Milne’s P – C pair is given as 4h P : yn 1 yn 3 (2 yn 2 yn 1 2 yn ) 3 h C : yn 1 yn 1 ( yn 1 4 yn yn 1 ) 3 From the given differential equation, y (t y ) / 2. We have, t1 y1 0.5 2.636 y1 1.5680 2 2 t2 y2 1.0 3.595 y2 2.2975 2 2 t3 y3 1.5 4.968 y3 3.2340 2 2 Now, using predictor formula, we compute 4h y4 y0 (2 y1 y2 2 y3 ) 3 4(0.5) 2 2(1.5680) 2.2975 2(3.2340) 3 6.8710 Using this predicted value, we shall compute the improved value of y4 from corrector formula h y4 y2 ( y2 4 y3 y4 ) 3 Using the available predicted value y4 and the initial values, we compute t4 y4 2 6.68710 y4 4.4355 2 2 t3 y3 1.5 4.968 y3 3.2340 2 2 and y2 2.2975 Thus, the first corrected value of y4 is given by (1) 4 y 0.5 3.595 [2.2975 4(3.234) 4.4355] 3 6.8731667 Suppose, we apply the corrector formula again, then we have h y y2 ( y2 4 y3 ( y4(1) ) 3 0.5 2 6.8731667 3.595 2.2975 4(3.234) 3 2 6.8733467 (2) 4 Finally, y (2.0) = y4 = 6.8734. Example Tabulate the solution of dy t y, dt y (0) 1 in the interval [0, 0.4] with h = 0.1, using Milne’s P-C method. Solution Milne’s P-C method demand the solution at first four points t0, t1, t2 and t3. As it is not a self – starting method, we shall use R-K method of fourth order to get the required solution and then switch over to Milne’s P – C method. Thus, taking t0 = 0, t1 = 0.1, t2 = 0.2, t3 = 0.3 we get the corresponding y values using R–K method of 4th order; that is y0 = 1, y1 = 1.1103, y2 = 1.2428 and y3 = 1.3997 (Reference Lecture 38) Now, we compute y1 t1 y1 0.1 1.1103 1.2103 y2 t2 y2 0.2 1.2428 1.4428 y3 t3 y3 0.3 1.3997 1.6997 Using Milne’s predictor formula 4h P : y4 y0 (2 y1 y2 2 y3 ) 3 4(0.5) 1 2(1.21103) 1.4428 2(1.69971) 3 1.58363 Before using corrector formula, we compute y4 t4 y4 ( predicted value) 0.4 1.5836 1.9836 Finally, using Milne’s corrector formula, we compute h C : y4 y2 ( y4 4 y3 y2 ) 3 0.1 1.2428 (1.9836 6.7988 1.4428) 3 1.5836 The required solution is: t 0 0.1 0.2 0.3 0.4 y 1 1.1103 1.2428 1.3997 1.5836 Numerical Analysis Lecture 39