Docsity

Solutions for Problem Set 2 | Numerical Methods for Differential Equations | MATH 4820, Assignments of Differential Equations

Toggle sidebar
bg1
Math 4820
D. Schwendeman Problem Set 2
Due:
Thursday, 2/11/10
1. Consider Heun’s method
wn=wn−1+h
4f(tn−1, wn−1)+3ftn−1+2
3h , wn−1+2
3hf(tn−1, wn−1),
which is a single-step method for the ODE y0=f(t, y).
(a) Find the stepping function φ(t, y, h) for Heun’s method.
(b) Show that the truncation error has the form τn=Cnhp+. . . as h→0. Find Cnand
the order of accuracy p.
(c) Show that the stepping function satisfies a Lipschitz condition in the variable yassuming
that f(t, y) satisfies a Lipschitz condition in ywith constant L > 0.
(d) Write a code based on Heun’s method to solve the IVP
y0=e−t−y, 0≤t≤4, y(0) = 0.
Solve the IVP numerically for h= 4/N ,N= 20, 40, 80 and 160. Find the global error for
each case and verify the order of accuracy found in part (b).
2. The population y1(t) of a prey and the population y2(t) of a predator satisfy the IVP
y0
1=y1−1
2y1y2
y0
2=−3
4y2+1
4y1y2
for 0 ≤t≤15,
with initial conditions y1(0) = 3 and y2(0) = α, 0 < α < 2. It is well known that solutions
for the two populations of this predator-prey model oscillate in time twith period T(that
depends of the choice for α). Write a code to solve the IVP based on standard Runge-
Kutta order 4 (RK4) using h= 15/N, where N= 1500. Consider the cases α= 0.5, 1.0
and 1.5. Plot the populations versus time and estimate Tfor each case. (It is known that
T→2πp4/3 as α→2.)
3. Consider the overdamped mass-spring system
y00 + 2y0+y= 0,0≤t≤4, y(0) = 0, y0(0) = 1/,
where > 0 is a parameter.
(a) Find the exact solution. Plot y(t) for = 0.5 and = 0.1. Describe the solution behavior
for each value of . (Work out the exact solution by hand, but then you can make the plots
using Maple or Matlab, for example.)
(b) Write the second-order ODE as a system of two first-order ODEs. Solve the correspond-
ing IVP using Euler’s method with h= 4/N, where N= 20, 40 and 80. Plot the numerical
solution versus the exact solution for each Nand for each value of . Describe the behavior
of the numerical solution for each case.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Solutions for Problem Set 2 | Numerical Methods for Differential Equations | MATH 4820 and more Assignments Differential Equations in PDF only on Docsity!

Math 4820

D. Schwendeman Problem Set 2

Due: Thursday, 2/11/

  1. Consider Heun’s method

wn = wn− 1 + h 4

[ f (tn− 1 , wn− 1 ) + 3f

( tn− 1 +

h , wn− 1 +

hf (tn− 1 , wn− 1 )

)] ,

which is a single-step method for the ODE y′^ = f (t, y).

(a) Find the stepping function φ(t, y, h) for Heun’s method.

(b) Show that the truncation error has the form τn = Cnhp^ +... as h → 0. Find Cn and the order of accuracy p.

(c) Show that the stepping function satisfies a Lipschitz condition in the variable y assuming that f (t, y) satisfies a Lipschitz condition in y with constant L > 0.

(d) Write a code based on Heun’s method to solve the IVP

y′^ = e−t^ − y, 0 ≤ t ≤ 4 , y(0) = 0.

Solve the IVP numerically for h = 4/N , N = 20, 40, 80 and 160. Find the global error for each case and verify the order of accuracy found in part (b).

  1. The population y 1 (t) of a prey and the population y 2 (t) of a predator satisfy the IVP

y′ 1 = y 1 −

y 1 y 2

y′ 2 = −

y 2 +

y 1 y 2

 

^ for 0^ ≤^ t^ ≤^ 15,

with initial conditions y 1 (0) = 3 and y 2 (0) = α, 0 < α < 2. It is well known that solutions for the two populations of this predator-prey model oscillate in time t with period T (that depends of the choice for α). Write a code to solve the IVP based on standard Runge- Kutta order 4 (RK4) using h = 15/N , where N = 1500. Consider the cases α = 0.5, 1. 0 and 1.5. Plot the populations versus time and estimate T for each case. (It is known that T → 2 π

√ 4 /3 as α → 2.)

  1. Consider the overdamped mass-spring system

y′′^ + 2y′^ + y = 0, 0 ≤ t ≤ 4 , y(0) = 0, y′(0) = 1/,

where  > 0 is a parameter.

(a) Find the exact solution. Plot y(t) for  = 0.5 and  = 0.1. Describe the solution behavior for each value of . (Work out the exact solution by hand, but then you can make the plots using Maple or Matlab, for example.)

(b) Write the second-order ODE as a system of two first-order ODEs. Solve the correspond- ing IVP using Euler’s method with h = 4/N , where N = 20, 40 and 80. Plot the numerical solution versus the exact solution for each N and for each value of . Describe the behavior of the numerical solution for each case.

2/19/10 11:32 AM /User.../ps2prob2ex.m 1 of 1

% Run the simulation for Problem Set 2,

% problem number 2.

tfinal=15;

tspan=[0 tfinal];

nstep=1500;

k=1;

color=[’r’ ’b’ ’g’];

figure(1)

plot(tspan,[3 3],’k’)

axis([0 15 0 10])

hold on

figure(2)

axis([0 15 0 6])

hold on

figure(3)

axis([0 10 0 6])

hold on

for alpha=[.5 1 1.5]

[t,w]=myRK4(’ps2prob2’,tspan,[3;alpha],nstep);

figure(1)

plot(t,w(1,:),color(k))

figure(2)

plot(t,w(2,:),color(k))

figure(3)

plot(w(1,:),w(2,:),color(k))

k=k+1;

end

time

y^1

y 1 vs time

red is alpha=0.

blue is alpha=1.

green is alpha=1.

time

y^2

y

vs time

red is alpha=0.

blue is alpha=1.

green is alpha=1.

2/19/10 11:33 AM /User.../ps2prob3ex.m 1 of 1

% Run the simulation for Problem Set 2,

% problem number 3.

global ep

color=[’g’ ’b’ ’r’];

tfinal=4;

tspan=[0 tfinal];

for ep=[.5 .1]

r1=(−1+sqrt(1−ep))/ep;

r2=(− 1 −sqrt(1−ep))/ep;

figure

t=linspace(0,4,500);

y=(exp(r1t)−exp(r2t))/(2*sqrt(1−ep));

plot(t,y,’k’)

hold on

k=1;

for n=[20 40 80]

[t,w]=myEuler(’ps2prob3’,tspan,[0;1/ep],n);

plot(t,w(1,:),color(k))

k=k+1;

end

hold off

axis([0 4 0 1])

end

time

solutions

epsilon=0.

black is exact

green is N=

blue is N=

red is N=

time

solutions

epsilon=0.

black is exact

green is N=

blue is N=

red is N=