






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Department of Mathematics Fall 2008 MATH 4364, Section 24266 MW 5:30-7:00PM A. Caboussat
The Taylor method of order two reads as follows: { y 0 = α yi+1 = yi + hT (2)(ti, yi)
a. For f (t, y) = et−y^ , the Taylor method of order two reads:
T (2)(t, y) = et−y
h 2
h 2
et−y
The results are:
Approximation at time 0.00000000 : 1. Approximation at time 0.50000000 : 1. Approximation at time 1.00000000 : 1.
b. For f (t, y) = (1 + t)/(1 + y), the Taylor method of order two reads:
T (2)(t, y) = 1 + t 1 + y
h 2
1 + t (1 + y)^2
h 2
1 + y
The results are:
Approximation at time 1.00000000 : 2. Approximation at time 1.50000000 : 2. Approximation at time 2.00000000 : 2.
a. The Taylor method of order two reads
T (2)(t, y) =
t
y + t^2 et^ +
h 2
t
y + 2tet^ + t^2 et^ +
t
y + t^2 et
t
The results are
Approximation at time 1.00000000 : 2. Approximation at time 1.10000000 : 2. Approximation at time 1.20000000 : 3. Approximation at time 1.30000000 : 4. Approximation at time 1.40000000 : 6. Approximation at time 1.50000000 : 8. Approximation at time 1.60000000 : 10. Approximation at time 1.70000000 : 13. Approximation at time 1.80000000 : 17. Approximation at time 1.90000000 : 21. Approximation at time 2.00000000 : 26.
b. In order to approximate any value between two grid points, one uses a linear interpolation. If t ∈ [tn, tn+1], we write
y(t) =
t − tn h
yn+1 +
tn+1 − t h
yn
In the case t = 1.04, n = 10 and the result is:
Approximation at time 1.00000000 : 2. Approximation at time 1.10000000 : 2. Approximation of y( 1.04000000) : 2.
a. Since we can solve the problem with any numerical method, we can use the explicit Euler method. With v 0 = 8,
vi+1 = vi + h
−g −
k m
vi |vi|
The results are as follows:
Approximation at time 0.00000000 : 8. Approximation at time 0.10000000 : 6. Approximation at time 0.20000000 : 5. Approximation at time 0.30000000 : 4. Approximation at time 0.40000000 : 3. Approximation at time 0.50000000 : 2. Approximation at time 0.60000000 : 1. Approximation at time 0.70000000 : 0. Approximation at time 0.80000000 : -0. Approximation at time 0.90000000 : -1. Approximation at time 1.00000000 : -2.
b. The requested time is when vi > 0 and vi+1 < 0. The top of the trajectory would be between 0.7 and 0. 8 seconds.
a. The modified Euler method reads:
yi+1 = yi +
h 2
tie^3 ti^ − 2 yi + ti+1e^3 ti+1^ − 2
yi + htie^3 ti^ − h 2 yi
A small Matlab code can be written as:
h = 0.5; N=2;
y = 0; t = 0; yexact = 0; ttot = t;
a. The Midpoint method reads:
yi+1 = yi + h
(t +
h 2
)e3(ti+^
h 2 ) − 2
yi +
h 2
(ti +
h 2
)e3(ti+^
h 2 ) −
h 2
2 yi
The modification of the small Matlab code written before can be written as:
ymid = y + (h/2)texp(3t)-(h/2)2y; midpoint = (t+h/2)exp(3(t+h/2))-2ymid; y = y + h*midpoint;
The results are
Approximation at time 0.00000000 : 0. Exact solution at time 0.00000000 : 0. Approximation at time 0.50000000 : 0. Exact solution at time 0.50000000 : 0. Approximation at time 1.00000000 : 3. Exact solution at time 1.00000000 : 3.
a. The Runge-Kutta RK44 can be implemented as follows:
k1 = h(texp(3t)-2y); k2 = h((t+h/2)exp(3(t+h/2))-2(y+k1/2)); k3 = h((t+h/2)exp(3(t+h/2))-2(y+k2/2)); k4 = h((t+h)exp(3(t+h))-2(y+k3)); y = y + (1/6)(k1+2k2+2*k3+k4);
The results are given by:
Approximation at time 0.00000000 : 0. Exact solution at time 0.00000000 : 0. Approximation at time 0.50000000 : 0. Exact solution at time 0.50000000 : 0. Approximation at time 1.00000000 : 3. Exact solution at time 1.00000000 : 3.
Let us remind that the Midpoint method reads
yi+1 = yi + hf
ti +
h 2
, yi +
h 2
f (ti, yi)
The Modified Euler method reads
yi+1 = yi +
h 2
[f (ti, yi) + f (ti+1, yi + hf (ti, yi))].
The Heun’s method reads
yi+1 = yi +
h 4
f (ti, yi) + 3f
ti +
h, yi +
hf (ti, yi)
For instance in the case of f (t, y) = −y + t + 1, we obtain
Midpoint : yi+1 = yi + h
ti + 1 − yi +
h 2
(yi − ti)
Modified Euler : yi+1 = yi +
h 2
(2ti + 2 − 2 yi + h(yi − ti)) Heun : same
This remarkable property comes from the fact that the function f is linear both in t and y.
With an (explicit) Euler method, h = 0.01 and N = 200, we obtain
xi+1 = xi + h
k
n 1 − xi 2
n 2 − xi 2
n 3 − 3 xi 4
A subset of the results reads:
Approximation at time 0.19800000 : 2080. Approximation at time 0.19900000 : 2082. Approximation at time 0.20000000 : 2083.
Remark: Note that you obtain slightly different values at t = 0.2 if you use any other method.
a. We use only here the Adams-Bashforth 2-steps method given by:
yi+1 = yi +
h 2
(3f (ti, yi) − f (ti− 1 , yi− 1 ))
A small Matlab code reads:
h = 0.2; N=5;
%Step 0:
y = 0; t = 0; yexact = 0; ttot = t; ytot = y; ytotexact = yexact;
fprintf(’Approximation at time %11.8f : %11.6f\n’,t,y); fprintf(’Exact solution at time %11.8f : %11.6f\n’,t,yexact);
%Step 1 (exact):
h = 0.2; N=5;
y1 = 1; y2 = 1; t = 0;
ttot = t; ytot = y;
fprintf(’Approximation at time %11.8f : %11.6f / %11.6f \n’,t,y1,y2);
for i=1:N
k1_1 = h(3y1+2y2-(2tt+1)exp(2t)); k1_2 = h(4y1+y2+(tt+2t-4)exp(2*t));
tm = t+h/2; k2_1 = h(3(y1+k1_1/2)+2(y2+k1_2/2)-(2tmtm+1)exp(2tm)); k2_2 = h(4(y1+k1_1/2)+(y2+k1_2/2)+(tmtm+2tm-4)exp(2*tm));
k3_1 = h(3(y1+k2_1/2)+2(y2+k2_2/2) - (2tmtm+1)exp(2tm)); k3_2 = h(4(y1+k2_1/2)+(y2+k2_2/2)+(tmtm+2tm-4)exp(2*tm));
tp = t+h; k4_1 = h(3(y1+k3_1)+2(y2+k3_2) - (2tptp+1)exp(2tp)); k4_2 = h(4(y1+k3_1)+(y2+k3_2)+(tptp+2tp-4)exp(2*tp));
y1 = y1 + (1/6)(k1_1+2k2_1+2k3_1+k4_1); y2 = y2 + (1/6)(k1_2+2k2_2+2k3_2+k4_2);
t = t+h;
ytot = [ytot y]; ttot = [ttot t];
fprintf(’Approximation at time %11.8f : %11.6f / %11.6f \n’,t,y1,y2);
end
The numerical results are as follows:
Approximation at time 0.00000000 : 1.000000 / 1. Approximation at time 0.20000000 : 2.120366 / 1. Approximation at time 0.40000000 : 4.441228 / 3. Approximation at time 0.60000000 : 9.739133 / 8. Approximation at time 0.80000000 : 22.676560 / 21. Approximation at time 1.00000000 : 55.661181 / 56.
By introducing v(t) = θ′(t) (angular velocity), the two problems can be written as a system of two ODEs. The original problem (coming from the Newton law in mechanics):
θ′(t) = v(t), θ(0) = π 6 ,
v′(t) = −
g L sin(θ(t)), v(0) = 0.
The linearization around θ = 0, which is valid for small oscillations and small angles (sin θ ≃ θ) reads:
θ′(t) = v(t), θ(0) = π 6 ,
v′(t) = − g L
θ(t), v(0) = 0.
The comparative results are the following:
Angles at time 0.00000000 : 0.523599 / 0. Angles at time 0.10000000 : 0.482613 / 0. Angles at time 0.20000000 : 0.366458 / 0. Angles at time 0.30000000 : 0.192828 / 0. Angles at time 0.40000000 : -0.011250 / -0. Angles at time 0.50000000 : -0.213535 / -0. Angles at time 0.60000000 : -0.382102 / -0. Angles at time 0.70000000 : -0.490775 / -0. Angles at time 0.80000000 : -0.523043 / -0. Angles at time 0.90000000 : -0.474077 / -0. Angles at time 1.00000000 : -0.351229 / -0. Angles at time 1.10000000 : -0.173252 / -0. Angles at time 1.20000000 : 0.032094 / 0. Angles at time 1.30000000 : 0.232347 / 0. Angles at time 1.40000000 : 0.395935 / 0. Angles at time 1.50000000 : 0.497507 / 0. Angles at time 1.60000000 : 0.521664 / 0. Angles at time 1.70000000 : 0.464794 / 0. Angles at time 1.80000000 : 0.335443 / 0. Angles at time 1.90000000 : 0.153401 / 0. Angles at time 2.00000000 : -0.052884 / -0.
The following graphics shows the angle of oscillation of the pendulum with both models. It confirms the validity of the small angles linearization, since both trajectories are very similar.
a. By using Taylor expansions, one gets:
y(ti+2) = y(ti) + 2hy′(ti) +
4 h^2 2
y′′(ti) +
8 h^3 6
y′′′(ξ 1 )
y(ti+1) = y(ti) + hy′(ti) +
h^2 2 y′′(ti) +
h^3 6 y′′′(ξ 2 )
Therefore
y′(ti) =
−y(ti+2) + 4y(ti+1) − 3 y(ti) 2 h
h^2 12
(8y′′′(ξ 1 ) − 4 y′′′(x 2 )).
b. The results for h = 0.1 are as follows, i.e. the method is unstable:
Exact / Approximation at time 0.20000000 : 0.181269 / -604. Exact / Approximation at time 0.21000000 : 0.189416 / -1818. Exact / Approximation at time 0.22000000 : 0.197481 / -5473. Exact / Approximation at time 0.23000000 : 0.205466 / -16476. Exact / Approximation at time 0.24000000 : 0.213372 / -49592. Exact / Approximation at time 0.25000000 : 0.221199 / -149271. ETC...
The method is still unstable. The following graphics shows the two trajectories for both h = 0.1 and h = 0.01.
−10 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
−
−
−
−
0
2
approximation exact −12 0 0.2 0.4 0.6 0.8 1 1.2 1.
−
−
−
−
−
0
2 x 10^40
approximation exact
Figure 2: Stability of Multistep method. Left: h = 0.1, right: h = 0.01.
d. The method is consistent (by construction), but not stable (as seen by numerical experiments). Therefore it is not convergent.
See text for the definition.
b. The explicit Euler scheme reads: { y 0 = 1/ 3 yi+1 = yi + h
−20(yi − t^2 i ) + 2ti
The implicit Euler scheme reads: { y 0 = 1/ 3 yi+1 = (^) 1+20^1 h
yi + h
20 t^2 i+1 + 2ti+
The numerical results are shown in the next Figure. The implicit method simulates the trajectory and is stable. The explicit Euler method presents oscillations around that trajectory and eventually explodes (unstable).
−0.4 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
1
1.4 explicit implicit
Figure 3: Stiff problems - Comparison between explicit and implicit Euler schemes.
For the case f (t, y) = λy, we obtain successively
k 1 = hλyi
k 2 = h
λyi +
hλ^2 yi
k 3 = h
λyi +
hλ^2 yi +
h^2 λ^3 yi
k 4 = h
λyi +
hλ^2 yi +
h^2 λ^3 yi +
h^3 λ^4 yi
Therefore
yi+1 = yi +
(k 1 + 2k 2 + 2k 3 + k 4 )
= yi +
hλ + 2hλ + 2
h^2 λ^2 2
h^2 λ^2 2
h^3 λ^3 4
h^3 λ^3 2
h^4 λ^4 4
yi
1 + hλ +
h^2 λ^2 2
h^3 λ^3 6
h^4 λ^4 24
yi
The method is stable if h satisfies
∣ ∣ ∣ ∣1 +^ hλ^ +^
h^2 λ^2 2
h^3 λ^3 6
h^4 λ^4 24