60 likes | 197 Views
Solve Differential Equations Using The Euler Method. Sung-Ju Kang Department of Physics Kangwon National University.
E N D
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].
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 t2 from t1 again by the same formula. Above Equation is called the Difference Equation associated with Euler’s method.
Algorism To approximate the solution of the initial-value problem. INPUT function: f(t), begin point: a, integer: N, step size: dt, initial condition: y0. OUTPUT application y to values of t. Step1 Set t = a ; y = y0 ; Step2 For i = 0, 1, 2, … , N Step3 Set y = y + dt*f(t) ; OUTPUT (t, y) Set t = t + dt ; Step4 STOP.
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.15Lf y=%20.15Lf \n", t, x); } void DF(){ f=-y+t+1 }
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.