Starting from:

$30

MATH 340 LAB 12 Assignment

MATH 340
LAB 12 Assignment
DUE Tuesday 04-19-2016
ODEs:
Runge-Kutta (R-K2) also called Explicit Trapezoidal Rule
Recalling the notation from your textbook, we discretize the time interval [t0, tf ]
with a grid of n + 1 points t0 < t1 < . . . < tn with equal step size h (or in other
words ti = t0 + ih, i = 0, 1, . . . , n). We seek the discrete approximated solution
to an initial value problem, say w(tn) (it can be also denoted by the equivalent
notations wh(tn) or wn). Runge-Kutta of order two, is given by the following set
of equations:
wi+1 = wi +
h
2
(v1 + v2) (1)
where
v1 = f(ti
, wi)
v2 = f (ti + h, wi + hv1)
with initial condition given by w0 = y0.
Runge-Kutta (R-K4)
Runge-Kutta method of order four is given by the following set of equations:
wi+1 = wi +
h
6
(v1 + 2v2 + 2v3 + v4) (2)
1
where
v1 = f(ti
, wi)
v2 = f

ti +
h
2
, wi +
h
2
v1

v3 = f

ti +
h
2
, wi +
h
2
v2

v4 = f(ti + h, wi + hv3)
with initial condition given by w0 = y0.
Problem 1:
Implement your own R-K2 and R-K4 methods in MATLAB. Use them to solve the
same initial value problem seen last week
(
y
0 = ty + t
3
y(0) = 1
Print your results, for each method, in a table like the one made last week,
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.
For each method, 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, for each method, the order of convergence p at the point ti = 1 in the same
fashion you did last week, given by:
p = log2

wh=0.1(ti) − wh=0.2(ti)
wh=0.05(ti) − wh=0.1(ti)

(3)
Comment on your results. How do the methods RK-2 and RK-4 perform
comparing to Euler’s explicit method?
2

More products