Euler and improved euler method

3,663 views 20 slides Jun 20, 2020
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

These slides contain information about Euler method,Improved Euler and Runge-kutta's method.How these methods are helpful and applied to our questions are detailed discussed in the slides.


Slide Content

Topic: Numerical method for ODEs Euler Method Improved Euler Method Runge- kutta’s Method Prepared by: Sohaib Siddique Butt University of Gujrat NUMERICAL ANALYSIS

Ordinary Differential Equation Definition : A differential equation containing one or more functions of one independent variable and the derivatives of those functions Examples: y is dependent variable x is independent variable

Solution to Ordinary Differential Equations Analytical solutions: Eigenvalues, time constants, damping coefficients Numerical solutions: Euler Method, Runge- Kutta Method

Euler’s Method 𝑑 π‘₯ Consider the equation 𝑑𝑦 =f(x,y) …….(1) Given that Y(x )=y its curve of solution through P(x ,y ) is shown dotted in figure. Now we have to find ordinate of any other point at Q on this curve. Dividing the curve into β€˜n’ equal sub-interval each of width β€˜h’. So we approximate the tangent for LL 1 So Y 1 =L 1 P 1 =LP+R 1 P 1 =y +PR 1 tan πœƒ =y +hf(x ,y ) Here we go………………………………..

Euler’s Method . Repeating this process n times y n+1 =y n +hf(x n ,y n ) …… ….(2) Where x n =x +nh Equation 2 is called as Euler’s Method for finding an approximate solution.

EULER’S METHOD 𝑑 π‘₯ To solve a differential equation of first order of the type 𝑑𝑦 = 𝑓 π‘₯, 𝑦 , with initial 0 0 con d it i o n s 𝑦 π‘₯ = 𝑦 . The method is used to find the values of 𝑦(π‘₯) for different values of π‘₯ at equal intervals. The length of the interval is β„Ž , i.e. β„Ž = π‘₯ 𝑛+1 βˆ’ π‘₯ 𝑛 . In other words, π‘₯ 1 = π‘₯ + β„Ž, π‘₯ 2 = π‘₯ 1 + β„Ž , π‘₯ 3 = π‘₯ 2 + β„Ž … etc. Also 𝑦 𝑛 is defined as 𝑦 𝑛 = 𝑦 π‘₯ 𝑛 . Euler’s Method: 𝑦 π‘₯ 𝑛+1 𝑖. 𝑒. 𝑦 𝑛+1 = 𝑦 𝑛 + β„Žπ‘“(π‘₯ 𝑛 , 𝑦 𝑛 ) β„Ž will be provided or need to be chosen. Smaller the value of β„Ž , more accurate is the answer and less is the error committed.

Problem 1 Given 𝑑𝑦 = π‘₯ , with initial conditions 𝑦 0 = 1 . Choose β„Ž = 0.1 and find 𝑑π‘₯ 𝑦 0.1 , 𝑦 0.2 , 𝑦 0.3 and 𝑦 0.4 . Here 𝑓 π‘₯, 𝑦 = π‘₯, π‘₯ = 0, 𝑦 = 1 π‘₯ 1 = π‘₯ + β„Ž = 0 + 0.1 = 0.1, π‘₯ 2 = π‘₯ 1 + β„Ž = 0.2 , π‘₯ 3 = π‘₯ 2 + β„Ž = 0.3, π‘₯ 4 = 0.4 Using Euler’s Method: 𝑦 π‘₯ 𝑛+1 𝑖. 𝑒. 𝑦 𝑛+1 = 𝑦 𝑛 + β„Žπ‘“(π‘₯ 𝑛 , 𝑦 𝑛 ) 𝑦 1 = 𝑦 + β„Žπ‘“ π‘₯ , 𝑦 𝑦 2 = 𝑦 1 + β„Žπ‘“ π‘₯ 1 , 𝑦 1 = 1 + 0.1 π‘₯ = 1 + 0.1 π‘₯ 1 = 1 + 0 = 1 = 1 + (0.1)(0.1) = 1.01 𝑦 3 = 1.03, 𝑦 4 = 1.06

Errors with Euler`s Method Local truncation error : over one step size. Global error : cumulative over the range of the solution . The error Ξ΅ using Euler`s method can be approximated using the second term of the Taylor series expansion. If the range is divided into n increments, then the error at the end of range for x would be n Ξ΅ . In addition, there are roundoff errors in this and other methods, which may affect the accuracy of the values more and more as n increases.

Comparison Actual solution of the differential equation is π‘₯ 2 2 𝑦 = + 1 n π‘₯ 𝑛 𝑦 𝑛 (actual) 𝑦 𝑛 (approx) % error 1 1 1 0.1 1.005 1 0.497512 2 0.2 1.02 1.01 0.980392 3 0.3 1.045 1.03 1.435407 4 0.4 1.08 1.06 1.851852

Improved Euler’s Method In the Euler’s improved method , The curve of the solution in the interval LL 1 is approximates by the tangent at P such as at P 1 we have, Y 1 =y +hf(x ,y ) Than the slope of the curve of the solution through P 1 is computed at the tangent at P 1 to P 1 Q 1 is drawn meeting the ordinate through L 2 in P 2 (x +2h,y 2 )……1 Now we find better approximation y 1 ’ of y(x +h) by taking the slope of the curve as the mean of the slope of the tangent at P and P 1 i.e. Y 1 ’=y + β„Ž { f(x +y )+f(X +h,Y 1 )}…..2 2 As the slope of the tangent at P 1 is not known, We take Y 1 is found in equation (1)

improved Euler’s Method Euler method y n+1 =y n +hf(x n ,y n ) Where x n =x +nh Euler’s Modified Method is 2 y n+1 =y n + β„Ž {f(x n , y n )+f(x n+1 ,y n+1 )}

Euler method is a predictor–corrector method In each step of the improved Euler method we compute two values, first the predictor which is an auxiliary value, and then the new y-value, the corrector

Example Question : Apply Euler’s Modified Method to solve y’=x+y .Given y(0)=1.Find y at x=0.2 using step length 0.1 . Solution : Given, y’=x+y , y(0)=1 ,h=0.1 Than using Euler’s Method, y n+1 =y n +hf(x n ,y n ) …………..(1) Putting n=0, y 1 =y +hf(x ,y ) ; y 1 =1+0.1(1)=1.1 Than using Euler’s Modified Method, 2 y n+1 =y n + β„Ž {f(x n , y n )+f(x n+1 ,y n+1 )}……(2)

Example ……………………………….. 2 y 1 =y + β„Ž {f(x , y )+f(x 1 ,y 1 )} y 1 =1+ 0.1 (1+1.2)=1.11 2 Repeating process will give y 1 =1.1105 Than using Euler’s Method, Putting n=1; y 2 =y 1 +hf(x 1 ,y 1 ) y 2 =1.1105+0.1(0.1+1.1105)=1.23155 Than using Euler’s Modified Method,Putting n=1; 2 y 2 =y 1 + β„Ž {f(x 1 , y 1 )+f(x 2 ,y 2 )}

Continue………………………….. y 2 =1.1105+ 0.1 (1.2105+1.43155)=1.2426 2 Repeating process will give y 2 =1.2432 At y(0.2)=1.2432 Answer.

RUNGE-KUTTA’S METHOD Method of great practical importance Much greater accuracy than that of the improved Euler method The classical Runge– Kutta method of fourth order, which we call briefly the Runge– Kutta method.

RUNGE-KUTTA’S METHOD

Problem 1 𝑑 π‘₯ Given 𝑑𝑦 = π‘₯ + 𝑦 , with initial conditions 𝑦 0 = 1 . Choose β„Ž = 0.1 and find 𝑦 0.1 , 𝑦 0.2 and 𝑦 0.3 using Runge-Kutta’s method of fourth order. Putting 𝑛 = 0 in Runge-Kutta’s formula for fourth order, we get 𝑦 1 = 𝑦 + 1 6 π‘˜ 1 + 2π‘˜ 2 + 2π‘˜ 3 + π‘˜ 4 where π‘˜ 1 = β„Žπ‘“ π‘₯ , 𝑦 = 0.1 + 1 = 0.1 β„Ž = 0.1 0.05 + 1.05 = 0.11 π‘˜ 2 = β„Žπ‘“ π‘˜ 3 = β„Žπ‘“ β„Ž π‘₯ + 2 , 𝑦 + π‘₯ + 2 , 𝑦 + π‘˜ 1 2 π‘˜ 2 2 π‘˜ 4 = β„Žπ‘“ π‘₯ + β„Ž, 𝑦 + π‘˜ 3 = 0.1 0.05 + 1.055 = 0.1 0.1 + 1.1105 = 0.1105 = 0.12105 1 𝑦 0.1 = 𝑦 = 1 + 1 6 0.1 + 0.22 + 0.221 + 0.12105 = 1.11034

Putting 𝑛 = 1 in Runge-Kutta’s formula for fourth order, we get 𝑦 2 = 𝑦 1 + 1 6 π‘˜ 1 + 2π‘˜ 2 + 2π‘˜ 3 + π‘˜ 4 where π‘˜ 1 = β„Žπ‘“ π‘₯ 1 , 𝑦 1 = = 0.12103 β„Ž 0.1 0.1 + 1.11034 = 0.13208 π‘˜ 2 = β„Žπ‘“ π‘˜ 3 = β„Žπ‘“ β„Ž π‘₯ 1 + 2 , 𝑦 1 + π‘₯ 1 + 2 , 𝑦 1 + π‘˜ 1 2 π‘˜ 2 2 = 0.13263 = 0.14429 𝑦 . 2 π‘˜ 4 = β„Žπ‘“ π‘₯ 1 + β„Ž, 𝑦 1 + π‘˜ 3 = 𝑦 2 = 1.2428 𝑛 = 2 will give 𝑦 0.3 = 1.399711 π‘˜ 1 = 0.14428, π‘˜ 2 = 0.156494, π‘˜ 3 = 0.157105, π‘˜ 4 = 0.169990