Homework Set No. 9: 1. Scalar ODE
Homework Set No. 9: 1. Scalar ODE
9
1. Scalar ODE
x′ = 2x2 + x − 1, x(1) = 1.
(a) Write out the Euler’s method for this ODE. Compute the value x(1.2) by Euler’s
method, with h = 0.1.
(b) Write out the Heun’s method for this ODE. Compute the value x(1.2) by Heun’s
method, with h = 0.1.
(c) Write out the classic 4th order Runge-Kutta method for this ODE. Compute the
value x(1.2) by 4th order Runge-Kutta’s method, with h = 0.1.
d) (*Bonus) Write out the 2nd order Adams-Bashforth-Moulton method for this
ODE. Note that this is a multi-step method. It needs 2 initial values, i.e., x0
and x1 , to initiate the iterations. For the 2nd initial value x1 , you could use the
result you obtained in part (b) with Heun’s method. Please compute the values
x(1.2) and x(1.3) by ABM method.
a) Euler’s method,
1
3. Matlab solvers: a case study in astronomy
The following problem is taken from astronomy. Suppose we have two space objects
with mass 1 − µ and µ in circular rotation in the space. We can think of these two
space objects as the earth and the moon, where the moon moves around the earth with
distance 1. (This is a normalized distance.) A third object, which is relatively much
smaller than the first two, such that it would not make any change in the orbits of the
first two, is also moving in the space. You can think of this as a space-ship.
The equations below describes the movement of the third object, i.e. the spaceship. We
consider a two space dimensional case. Let the position of the earth be the origin of our
coordinate. The solution (y1 (t), y2 (t)) would give the position of the third object.
The equations are given as:
y1 + µ y1 − ν
y1′′ = y1 + 2y2′ − ν −µ
D1 D2
y2 y2
y2′′ ′
= y2 − 2y1 − ν −µ
D1 D2
2 2 3/2
D1 = ((y1 + µ) + y2 )
D2 = ((y1 − ν)2 + y22 )3/2
µ = 0.012277471,
ν = 1 − µ.
It is known that the solutions would become periodic, i.e., the object will following a
certain orbit. When t = 17.065211656 it would complete one full round of its orbit.
(b) Use Matlab function ‘ode45’ to solve the system of ODEs over one period. Draw
the orbit.
(c) Write a program that would solve the system one more time with Euler’s method,
using 24000 uniform time steps.
(d) Write a program that would solve the system with the classical 4th order Runge-
Kutta method, but reduce the step number to 6000.
2
(e) The total computation amounts in (c) and (d) are the about the same. Compare
these two solutions. Do you think any of them is acceptable? Give your arguments
here.
(f ) Also find out how many steps ‘ode45’ used for computing the solution over one
period. Can you explain why ’ode45’ uses much fewer steps but still get a much
better solution than the other two methods?
(g) Even though the exact solution is periodic, a small error (for example, some per-
turbation in initial condition) could throw the object out of its orbit. This means
that the numerical error, which in other cases might be invisible, could have big
consequences in this case. In order to see this effect, you could try to solve the
system with ‘ode45’ over 3 periods. What accuracy (error tolerance) you must
require to get a acceptable result? (In this case, “acceptable” means that the plot
of the solution looks reasonable to you.)