1 / 39

Lecture 41

Numerical Analysis. Lecture 41. Examples of Differential Equations. Recall EULER METHOD. We considered the differential equation of first order with the initial condition y ( t 0 ) = y 0. We obtained the solution of the given differential equation in the form of a recurrence relation.

Download Presentation

Lecture 41

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NumericalAnalysis Lecture 41

  2. Examples of Differential Equations

  3. Recall • EULER METHOD

  4. We considered the differential equation of first order with the initial condition y(t0) = y0.

  5. We obtained the solution of the given differential equation in the form of a recurrence relation

  6. In fact Euler’s method constructs wi ~ y(ti ) for each i = 0, 1,…, N-1 by deleting the remainder term. Thus the Euler’s Method is

  7. Euler’s algorithm Let us try to approximate the solution of the given IVP at (N+1) equally spaced numbers in the interval [a ,b]

  8. INPUT endpoints a, b; integer N, initial condition (alpha) OUTPUTapproximate w to y at the (N+1) values of t

  9. Step 1 Set h=(b-a) / N t = a w = (alpha) OUTPUT(t , w) Step 2 For i = 0,1,…N do Step 3, 4.

  10. Step 3 Set w = w + h f (t , w); (compute wi ). t = a + i h (compute ti ) Step 4 OUTPUT (t , w) Step 5 STOP

  11. Example Use Euler’s method to approximate the solution of IVP y’= y - t2 + 1, 0 < t < 2, y ( 0 ) = 0.5 with N = 10.

  12. Solution Here, h = 0.2, ti = 0.2i, w0= 0.5 and wi+1 = wi + h (wi - ti2 + 1) = wi+0.2[wi - 0.04i2 +1] =1.2 wi - 0.008i2 + 0.2 for i = 0,1,…,9. The exact solution is y ( t )= (t+1)2 -0.5 et

  13. > alg051(); This is Euler's Method. Input the function F(t,y) in terms of t and y For example: y-t^2+1 > y-t^2+1

  14. Input left and right endpoints separated by blank > 0 2 Input the initial condition > 0.5 Input a positive integer for the number of subintervals > 10 Choice of output method: 1. Output to screen 2. Output to text file Please enter 1 or 2 > 1

  15. Output t w 0.000 0.5000000 0.200 0.8000000 0.400 1.1520000 0.600 1.5504000 0.800 1.9884800 1.000 2.4581760

  16. > alg051(); This is Euler's Method. Input the function F (t,y) in terms of t and y For example: y-3*t^2+4 > y-3*t^2+4

  17. Input left and right hand points separated by a blank >0 1 Input the initial condition > 0.5 Input a positive integer for the number of subintervals > 10 Choice of output method: 1. Output to screen 2. Output to text file Please enter 1 or 2 > 1

  18. Output t w 0.000 0.5000000 0.100 0.9500000 0.200 1.4420000 0.300 1.9742000 0.400 2.5446200 0.500 3.1510820 0.600 3.7911902 0.700 4.4623092 0.800 5.1615401 0.900 5.8856942 1.000 6.6312636

  19. Recall • Runge-Kutta (Order Four) METHOD

  20. The fourth-order R-K method was described as

  21. where

  22. Example Solve the following differential equation with the initial condition y(0) = 1, using fourth- order Runge-Kutta method from t = 0 to t = 0.4 taking h = 0.1

  23. Solution The fourth-order Runge-Kutta method is described as (1) where

  24. In this problem, As a first step, we calculate

  25. Now, we compute from Therefore y(0.1) = y1=1.1103 In the second step, we have to find y2 = y(0.2)

  26. We compute

  27. From Equation (1), we see that Similarly we calculate,

  28. Using equation (1), we compute Finally, we calculate

  29. Using them in equation (1), we get which is the required result.

  30. Runge-Kutta Order Four (1)

  31. RK4 algorithm Let us try to approximate the solution of the given IVP at (N+1) equally spaced numbers in the interval [a ,b]

  32. INPUT endpoints a, b; integer N, initial condition (alpha) OUTPUTapproximate w to y at the (N+1) values of t

  33. Step 1 Set h=(b-a) / N t = a w = (alpha) OUTPUT(t , w) Step 2 For i = 0,1,…N do Step 3 - 5.

  34. Step 3 Set

  35. Step 3 Set w = w + h f (t , w); (compute wi ). t = a + i h (compute ti ) Step 4 OUTPUT (t , w) Step 5 STOP

  36. > alg052(); This is the Runge-Kutta Order Four Method. Input the function F(t,y) in terms of t and y For example: y-t^2+1 > y-t^2+1

  37. Input left and right endpoints separated by blank > 0 2 Input the initial condition > 0.5 Input a positive integer for the number of subintervals > 10 Choice of output method: 1. Output to screen 2. Output to text file Please enter 1 or 2 > 1

  38. Output t w 0.000 0.5000000 0.200 0.8292933 0.400 1.2140762 0.600 1.6489220 0.800 2.1272027 1.000 2.6408227 1.200 3.1798942 1.400 3.7323401 1.600 4.2834095 1.800 4.8150857 2.000 5.3053630

  39. NumericalAnalysis Lecture 41

More Related