720 likes | 1.14k Vues
CHAPTER 6. Numerical Solutions of Ordinary Differential Equations. Contents. 6.1 Euler Methods and Error Analysis 6.2 Runge-Kutta Methods 6.3 Multistep Methods 6.4 Higher-Order Equations and Systems 6.5 Second-Order Boundary-Value Problems. 6.1 Euler Method and Error Analysis.
E N D
CHAPTER 6 Numerical Solutions of Ordinary Differential Equations
Contents • 6.1 Euler Methods and Error Analysis • 6.2 Runge-Kutta Methods • 6.3 Multistep Methods • 6.4 Higher-Order Equations and Systems • 6.5 Second-Order Boundary-Value Problems
6.1 Euler Method and Error Analysis • IntroductionRecall the backbone of Euler’s Methodyn+1 = yn + hf(xn, yn) (1) • Errors in Numerical MethodsOne of the most important error sources is round-off error.
Truncation Errors for Euler’s Methods • This algorithm gives only a straight-line approximation to the solution. This error is called the local truncation error, or discretization error. To derive a formula for the truncation error of Euler’s method, we use the Taylor’s formula with remainder. Where c is some point between a and x.
Setting k = 1, a = xn, x = xn+1= xn + h, we haveorHence the truncation error in yn+1of Euler’s method is where xn < c < xn+1The value of c is usually unknown, but an upper bound is where
Note: The e(h) is said to be of order hn, denoted by O(hn),if there exists a constant C such that |e(h)| Chn for h sufficiently small.
Example 1 Find a bound for the local truncation errors for Euler’s method applied to SolutionFrom the solution we have soIn particular, h = 0.1,then the upper bound by replacing c by 1.1 is
Example 1 (2) When we take five steps, replacing c by 1.5, then(2)
Improved Euler’s Method • (3)where (4)is commonly known as the Improved Euler’s method. See Fig 6.1 • In general, the improved Euler’s method is an example of predictor-corrector method.
Example 2 Use the improved Euler’s method to obtain the approximate value y(1.5) for the solution of . Compare the results for h = 0.1and h = 0.05. SolutionWith x0 = 1, y0 = 1, f(xn, yn) =2xnyn , h = 0.1 y1* = y0 + (0.1)(2xy) = 1.2Using(3) with x1= 1 + h = 1.1The results are given in Table 6.3 and 6.4.
Truncation Errors for the Improved Euler’s MethodNote that he local truncation error is O(h3).
6.2 Runge-Kutta Methods • Runge-Kutta MethodAll the Runge-Kutta Methods are generalizations of the basic Euler’s Formula, that the slope function f is replaced by a weighted average of slopes over the interval xn x xn+1(1) where the weights wi, i = 1, 2, …, m are constants satisfying w1+ w2+ … + wm= 0,and ki is the function evaluated at a selected point (x, y)for which xn x xn+1.
The number m is called the order. If we take m = 1, w1 = 1, k1= f(x, yn),we get the Euler’s method. Simply it is the first-order Runge-Kutta method.
A Second-order Runge-Kutta Method • We try to find some values of constants so that the formula (2)where k1= f(xn, yn), k2= f(xn+h, yn+hk1)agrees with a Taylor formula with degree 2. These constants satisfy (3)then (4)where w2 0.
Eg: we choose w2 = ½ ,yields w1 = ½ , = 1, = 1,and (2) becomesyn+1= yn+(k1+ k2)h/2where k1= f(xn, yn), k2= f(xn+h, yn+hk1).Since xn + h = xn+1, yn+ hk1= yn + hf(xn, yn), it is identical to the improved Euler’s methods.
A Forth-order Runge-Kutta Method • We try to find parameters so that the formula (5)where agrees with a Taylor formula with degree 4.
The most commonly used set of values yields the following results. (6)
Example 1 Use the RK4 method with h = 0.1to obtain y(1.5) for the solution of y’ =2xy, y(1) = 1. SolutionWe first compute the case n = 0.
Example 1 (2) Therefore,See table 6.5.
Truncation Error for the RK4 method • Since it is of degree 4, then the local truncation error is O(h5)and the global truncation error isO(h4). However, this is beyond the scope of this text.
Example 2 Find a bound for the local truncation error of RK4 for the solution of SolutionBy computing the fifth derivative of the known solution we get (7)Thus with c= 1.5,then (7) = 0.00028.Table 6.7 gives the approximations to the solution of the initial-value problem at x = 1.5 by the RK4 method.
6.3 Multistep Method • Adams-Bashforth-Moulton MethodThe predictor is the Adams-Bashforth formula (1)where n 3.
The value of yn+1* is then substitutedinto the Adams-Moulton corrector (2)
Example 1 Use the above method with h = 0.2to obtain y(0.8) for the solution of SolutionWith h = 0.2, y(0.8)will be approximated by y4. To get started, we use the RK4 method with x0 = 0, y0 = 1, h = 0.2to obtainy1 = 1.02140000, y2 = 1.09181796,y3 = 1.22210646
Example 1 (2) Now with x0 = 0, x1 = 0.2, x3 = 0.4, x4 = 0.6,andf(x, y) = x + y – 1,we findThen predictor (1) gives
Example 1 (3) To use the corrector (2), we need
Stability of Numerical Methods • We say a numerical method is stable, if small changes in the initial condition result in only small changes in the computed solution.
6.4 Higher-Order Equations and Systems • Second-Order IVPsAn IVP(1)can be expressed by (2)Since y’(x0) = u0,then y(x0) = y0, u(x0) = u0.Apply the Euler’s method to (2) (3)
Example 1 Use the Euler’s method to obtain y(0.2),where(5) SolutionLet y’ = u, then (5) becomesFrom (3)
Example 1 (2) Using h = 0.1, y0 =1, u0 = 2, we find
Fig 6.2 • Fig 6.2 shows the comparison of results between by Euler’s method and by the RK4 method.
Example 2 Write as a system of first-order DEs. SolutionWe write After simplification
Example 2 (2) Let Then the original system can be
Numerical Solution of a System • The solution of a system of the formcan be approximated by numerical methods.
Example 3 ConsiderUse the RK4 method to approximate x(0.6) and y(0.6)with h = 0.2and h = 0.1. SolutionWith h = 0.2and the given data, from (8)
Example 3 (3) Therefore, from (7) we get See Fig 6.3 and Table 6.8, 6.9.
6.5 Second-Order BVPs • Finite Difference ApproximationThe Taylor series at a point a of y(x)isIf we set h = x – a, thenRewrite the last expression as (1)and (2)