Solve Differential Equations Using The Euler Method SungJu

  • Slides: 5
Download presentation
Solve Differential Equations Using The Euler Method. Sung-Ju Kang Department of Physics Kangwon National

Solve Differential Equations Using The Euler Method. Sung-Ju Kang Department of Physics Kangwon National University Although Euler Method is seldom used in practice, the simplicity of its derivation can be used to illustrate the techniques involved in the construction of some of the more advanced techniques. The object of the method is to obtain an approximation to the well-posed initial-value problem Approximations to y will be generated at various value, called mesh point, in the interval [a, b]. 1

Theory We will use Taylor’s theorem to derive Euler’s method. Suppose that y(t) has

Theory We will use Taylor’s theorem to derive Euler’s method. Suppose that y(t) has two continuous on [a, b], so that for each i = 0, 1, 2, …. , N. Since And, since satisfies the differential equation. Thus, Euler’s method is t 2 from t 1 again by the same formula. Above Equation is called the Difference Equation associated with Euler’s method. 2

Algorism To approximate the solution of the initial-value problem. INPUT function: f(t), begin point:

Algorism To approximate the solution of the initial-value problem. INPUT function: f(t), begin point: a, integer: N, step size: dt, initial condition: y 0. OUTPUT application y to values of t. Step 1 Set t=a; y = y 0 ; Step 2 For i = 0, 1, 2, … , N Step 3 Set y = y + dt*f(t) ; OUTPUT (t, y) Set t = t + dt ; Step 4 STOP. 3

Programming with C language #include <stdio. h> #include <math. h> #include <conio. h> #include

Programming with C language #include <stdio. h> #include <math. h> #include <conio. h> #include <stdlib. h> long double y, t, dt, N, f; void EULER(); void DF(); void PRINT(); void main() { dt = 0. 2; N = 10. 0; t = 0. 0; y = 0. 5; EULER(); } void EULER() { int i; for(i=0; i<=N; ++i){ DF(); y=y+dt*f; PRINT(); t=t+dt; } } void PRINT(){ printf(“t=%20. 15 Lf y=%20. 15 Lf n", t, x); } void DF(){ f=-y+t+1 } 4

Summary 1. The object of the Euler Method is to obtain an approximation to

Summary 1. The object of the Euler Method is to obtain an approximation to the initial-value problem. 2. Approximations to y will be generated at various value, called mesh point. 3. Although Euler Method is not accurate enough to warrant its used in practice, it is sufficiently elementary to analyze the error that is produced from its application. 5