Lecture3 1 Euler's Method Print4p

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

19/02/2018

Math 2403: lecture 3 The Approximation Method of Euler


 Existence and uniqueness theorems are very useful (and
make mathematicians happy), but we need more .
 An exact, explicit solution would be ideal!
 However, what do we mean by “exact” (e.g., polynomials,
exponentials, trigonometric functions…)?
 Also, this rarely works out!
 What else can we do?
 Graphical methods.
 Numerical methods. [today]
B. Abou El Majd
PhD in Applied Mathematics

Euler’s Method Example 1: Idea

1
19/02/2018

Example 1: Step One Example 1: Step Two

Euler’s Method: Procedure Euler’s Method

2
19/02/2018

Example 2 Example 2

Example 2: One Step (Written out) Example 2: two Steps

3
19/02/2018

Example 2: two Steps (Written out) Example 2: Four Steps

Example 2: Four Steps (Written out) Example 2: Eight Steps

4
19/02/2018

Example 2: Sixteen Steps Example 2: Exact Solution

Example 3 Example 3: One Step


Use Euler’s method to find approximations to the
solution of the initial value problem

5
19/02/2018

Example 3: Two Steps Example 3: Four/Eight Steps

Interpretation of Euler Method Interpretation of Euler Method


y2

Slope=f(x0,y0)
y1 y1
y1=y0+hf(x0,y0)
hf(x0,y0)
y0 y0

x0 x1 x2 x x0 x1 x2 x
h

6
19/02/2018

Interpretation of Euler Method Programming Euler Method

y2 y2=y1+hf(x1,y1) Write a MATLAB program to implement Euler method to


Slope=f(x1,y1) solve:
hf(x1,y1)
Slope=f(x0,y0)
y1=y0+hf(x0,y0)
y1
dv
 1  2v 2  t . v ( 0)  1
hf(x0,y0)
y0
dt
x0 x1 x2 x
h h

for ti  0.01i, i  1,2,...,100

Programming Euler Method


Programming Euler Method
f=inline('1-2*v^2-t','t','v') f=inline('1-2*v^2-t','t','v')
h=0.01 h=0.01 Definition of the ODE
t=0
t=0
v=1 Initial condition
v=1
T(1)=t; T(1)=t;
V(1)=v; V(1)=v;
for i=1:100 for i=1:100
Main loop
v=v+h*f(t,v) v=v+h*f(t,v)
t=t+h; t=t+h;
Euler method
T(i+1)=t;
T(i+1)=t;
V(i+1)=v;
V(i+1)=v; Storing information
end end

You might also like