$30
MATH 340
LAB 11 Assignment
ODEs:
Euler’s Method
We want to solve the initial value problem:
( dy
dt = f(x, y(t)), t0 ≤ t ≤ tf
y(t0) = y0
(1)
To solve this numerically, we discretize the time interval [t0, tf ] with a grid of n+1
points t0 < t1 < . . . < tn with equal step size h (in other words ti = t0 + ih, i =
0, 1, . . . , n, or equivalently h = ∆t). We seek the discrete approximated solution
to this problem, say w(tn) (it can be also denoted by the equivalent notations
wh(tn) or wn). Euler’s forward (or explicit) method is defined with a forward
finite difference by the iterative scheme:
wi+1 − wi
h
=f(ti
, wi), 0 ≤ i ≤ n
wi+1 =wi + hf(ti
, wi), 0 ≤ i ≤ n (2)
with initial condition given by w0 = y0.
Problem 1:
Read carefully the first table in Example 6.2 in your textbook. Implement your own
Euler’s method. Print out you results in a table with columns: ti (where the values
in each row are ti = 0, 0.2, 0.4, 0.6, 0.8, 1.0 ), the approximated solutions wh=0.2(ti),
wh=0.1(ti), wh=0.05(ti), the actual solution yi and the error ei = |y(ti)−wh=0.05(ti)|.
To compute the error at each grid point use the value for the actual solution given
y(t) = 3e
t
2/2 − t
2 − 2.
Plot in the same figure the approximations wh=0.2, wh=0.1, wh=0.05 you have found
together with the actual solution y(t) for t ∈ [0, 1]. Find the order of convergence
at the point ti = 1 in the same fashion you did for integration rules applied on
coarser or finer meshes, given by:
1
p = log2
wh=0.1(ti) − wh=0.2(ti)
wh=0.05(ti) − wh=0.1(ti)
(3)
Comment on your results.
2