Rabbits and foxes affect each other: more rabbits means more food for foxes, and more foxes means fewer rabbits. A model of this needs two differential equations that depend on each other, a coupled system. These are rarely solvable by hand, but Euler’s method extends to them with almost no extra effort: you just step both variables forward at the same time. The same trick handles second-order equations like the motion of a spring. Working a few steps by hand is the best way to understand the method; in IB Mathematics AI HL exams the values themselves come from a spreadsheet or your GDC.
Beyond two or three steps, use technology. The guide expects spreadsheets for this, and in exams the values are generated with your GDC. In a spreadsheet, put t, x, y in columns A, B, C, with the starting values in row 2. Then in row 3:
Cell
Formula (for step h in cell F1)
A3
=A2+$F$1
B3
=B2+$F$1*(formula for dx/dt using A2, B2, C2)
C3
=C2+$F$1*(formula for dy/dt using A2, B2, C2)
Fill down as many rows as you need. Notice that both B3 and C3 refer to row 2 only. On a GDC, use the sequence or program mode in the same way, or a built-in Euler/differential equation tool if yours has one.
A second-order equation dt2d2x=f(x,dtdx,t) becomes a coupled first-order system if you give the velocity its own name. Let y=dtdx. Then dt2d2x=dtdy, so
dtdx=y,dtdy=f(x,y,t)
You need two initial conditions: the starting value of x and the starting value of y=dtdx. Then use Euler’s method on the system as above. In context, x is often a position and y a velocity.
Each step follows a tangent line, so errors build up. A smaller step usually gives a better approximation but needs more steps. A good habit: repeat the calculation with half the step size. If the answers barely change, you can trust them more.
On an island, the number of rabbits x and foxes y after t years are modelled by
dtdx=0.5x−0.01xy,dtdy=−0.4y+0.005xy
with x(0)=100 and y(0)=20.
(a) Explain the meaning of each term.
(b) Use Euler’s method with h=0.1 to find the populations after 0.2 years, by hand.
(c) Use technology with h=0.1 to estimate both populations after 5 years.
(d) Show that (80,50) is an equilibrium point and describe how the populations behave.
Solution.
(a) Without foxes, rabbits grow (0.5x). Meetings between rabbits and foxes (proportional to xy) reduce rabbits (−0.01xy) and help foxes grow (+0.005xy). Without rabbits, foxes die out (−0.4y).
(b)
t
x
y
dtdx
dtdy
0
100
20
50−20=30
−8+10=2
0.1
103
20.2
30.694
2.323
0.2
106.0694
20.4323
For example, at t=0.1: dtdx=0.5(103)−0.01(103)(20.2)=51.5−20.806=30.694. After 0.2 years there are about 106 rabbits and 20 foxes.
(c) With a spreadsheet (B3 =B2+0.1*(0.5*B2-0.01*B2*C2), C3 =C2+0.1*(-0.4*C2+0.005*B2*C2)), 50 steps reach t=5:
x(5)≈96.9,y(5)≈106(3 s.f.)
So after 5 years there are about 97 rabbits and 106 foxes.
(d) At (80,50): dtdx=40−0.01(80)(50)=0 and dtdy=−20+0.005(80)(50)=0. Neither population changes, so it is an equilibrium. Starting from (100,20), the populations oscillate around it: rabbits boom, then foxes boom (lagging behind), then rabbits crash, then foxes crash, and so on.
Euler’s method for the rabbit–fox model (h=0.1). The populations oscillate, with foxes lagging behind rabbits; in the phase plane the path circles the equilibrium.
A comment on accuracy: for this model the true solutions repeat the same closed loop forever. The slow outward drift on the right is error from Euler’s method. With h=0.01 the estimates at t=5 become about 94.6 rabbits and 102 foxes, noticeably different from part (c), so the step h=0.1 is only roughly accurate here.
Updating x first and then using the new x to update y. Both new values must be computed from the old pair (xn,yn). In a spreadsheet, every formula in row n+1 should refer only to row n.
Forgetting to multiply by the step size. The change in x is h×dtdx, not dtdx. With h=0.1 a rate of 30 rabbits per year adds only 3 rabbits.
Missing the second initial condition. A second-order equation needs both x(0) and dtdx(0). Without the starting velocity you can’t take the first step for y.
Writing dy/dt = x when converting a second-order equation. The first equation is always dtdx=y (the definition of y), and the second is the original equation with dt2d2x replaced by dtdy and dtdx replaced by y.
Forgetting to update t. If the rates depend on t, use the current tn at every step. It’s easy to leave t=0 in every row by mistake.
Trusting a large step size. Euler estimates can drift far from the truth, especially for oscillating systems. Rerun with a smaller step and see whether the answer settles down before you interpret it.
1. (Warm-up) For dtdx=2x−y, dtdy=x+t, with x(0)=1 and y(0)=2, use one step of Euler’s method with h=0.5 to estimate x(0.5) and y(0.5).
Solution
At t=0: dtdx=2(1)−2=0 and dtdy=1+0=1.
x(0.5)≈1+0.5(0)=1,y(0.5)≈2+0.5(1)=2.5
2. (Warm-up) Write dt2d2x=3x−2dtdx+t, with x(0)=4 and dtdx(0)=−1, as a system of coupled first-order equations with initial conditions.
Solution
Let y=dtdx:
dtdx=y,dtdy=3x−2y+t,x(0)=4,y(0)=−1
3. (Warm-up) For dtdx=y, dtdy=−x, with x(0)=0 and y(0)=1, use Euler’s method with h=0.1 to estimate x(0.2) and y(0.2).
Solution
t
x
y
dtdx=y
dtdy=−x
0
0
1
1
0
0.1
0.1
1
1
−0.1
0.2
0.2
0.99
x(0.2)≈0.2 and y(0.2)≈0.99. (The exact solution is x=sint, y=cost, giving 0.199 and 0.980 to 3 s.f.)
4. (Core) Two species compete for food. Their populations (in thousands) satisfy
dtdx=x(3−x−y),dtdy=y(2−x−y)
with x(0)=1 and y(0)=0.5. Use Euler’s method with h=0.1 to estimate both populations at t=0.2, to 3 s.f.
Solution
t
x
y
dtdx
dtdy
0
1
0.5
1(1.5)=1.5
0.5(0.5)=0.25
0.1
1.15
0.525
1.15(1.325)=1.52375
0.525(0.325)=0.170625
0.2
1.302375
0.5420625
x(0.2)≈1.30 thousand and y(0.2)≈0.542 thousand (3 s.f.).
5. (Core) The displacement x of an undamped spring satisfies dt2d2x=−9x, with x(0)=1 and dtdx(0)=0.
(a) Use Euler’s method with h=0.1 to estimate x(0.3).
(b) The exact solution is x=cos3t. Find the percentage error in your estimate, and suggest how to improve it.
Solution
(a) Let y=dtdx, so dtdx=y and dtdy=−9x.
t
x
y
dtdx=y
dtdy=−9x
0
1
0
0
−9
0.1
1
−0.9
−0.9
−9
0.2
0.91
−1.8
−1.8
−8.19
0.3
0.73
−2.619
x(0.3)≈0.73.
(b) Exactly, x(0.3)=cos0.9≈0.6216 (radians). The percentage error is 0.62160.73−0.6216×100%≈17.4%. Use a smaller step size (with technology).
6. (Core) A predator–prey system is modelled by
dtdx=0.6x−0.02xy,dtdy=−0.3y+0.004xy
where x is the number of prey and y the number of predators after t months, with x(0)=50 and y(0)=10.
(a) Find the equilibrium point with x,y>0.
(b) Write down the first step of Euler’s method with h=0.05.
(c) Use technology with h=0.05 to estimate x(2) and y(2).
(d) Describe what is likely to happen to the predators shortly after t=2.
Solution
(a) dtdx=x(0.6−0.02y)=0 gives y=30; dtdy=y(−0.3+0.004x)=0 gives x=75. The equilibrium is (75,30).
(b) At t=0: dtdx=30−10=20 and dtdy=−3+2=−1. So x(0.05)≈50+0.05(20)=51 and y(0.05)≈10+0.05(−1)=9.95.
(c) 40 steps of a spreadsheet give x(2)≈112 and y(2)≈10.1 (3 s.f.).
(d) The prey population (112) is now well above 75, so −0.3+0.004x>0 and dtdy>0: with plenty of food, the predator population will start to grow quickly.
7. (Core) A damped spring satisfies dt2d2x+0.4dtdx+4x=0, with x(0)=2 and dtdx(0)=0.
(a) Write the equation as a coupled first-order system.
(b) Use technology to estimate x(1) with h=0.1 and with h=0.01. Comment on your results.
Solution
(a) Let y=dtdx. Rearranging, dt2d2x=−4x−0.4dtdx, so
dtdx=y,dtdy=−4x−0.4y,x(0)=2,y(0)=0
(b) With h=0.1 (10 steps): x(1)≈−0.656. With h=0.01 (100 steps): x(1)≈−0.532 (3 s.f.).
The two estimates differ by more than 0.1, so the larger step isn’t reliable. The smaller step is more accurate. (A further check with h=0.001 gives about −0.518, close to the true value of about −0.516.) Either way, after 1 second the mass is on the other side of its rest position.
8. (Challenge) Consider dtdx=−y, dtdy=x, whose exact solutions move around circles centred at the origin.
(a) Show that one step of Euler’s method with step h multiplies x2+y2 by 1+h2.
(b) Starting at (1,0) with h=0.1, find the distance from the origin after 10 steps, to 4 s.f. What does this tell you about Euler’s method for this system?
Solution
(a) One step gives xn+1=xn−hyn and yn+1=yn+hxn. Then
(b) The squared distance starts at 1 and is multiplied by 1.01 each step, so after 10 steps it is 1.0110. The distance is 1.0110=1.015≈1.051.
The true path stays on the unit circle, but every Euler step moves outward, so the Euler path spirals outward. Euler’s method always overestimates the size of the orbit here; smaller steps reduce, but never remove, the drift. (This is the same drift you can see in the phase plane in Example 2.)
9. (Challenge) A pendulum of length 1 m swings so that its angle θ (in radians) from the vertical after t seconds satisfies
dt2d2θ=−9.8sinθ,θ(0)=0.2,dtdθ(0)=0
(a) Use Euler’s method with h=0.05 to estimate θ and dtdθ at t=0.1, to 3 s.f.
(b) Use technology with h=0.01 to estimate the time when the pendulum first passes through the vertical.
Solution
(a) Let ω=dtdθ, so dtdθ=ω and dtdω=−9.8sinθ.
t
θ
ω
dtdθ=ω
dtdω=−9.8sinθ
0
0.2
0
0
−1.94696
0.05
0.2
−0.097348
−0.097348
−1.94696
0.1
0.195133
−0.194696
θ(0.1)≈0.195 rad and dtdθ(0.1)≈−0.195 rad/s (3 s.f.).
(b) The pendulum passes through the vertical when θ=0. In the spreadsheet with h=0.01, θ is still positive at t=0.50 (θ≈0.0021) and first becomes negative at t=0.51 (θ≈−0.0043). So it first passes through the vertical at about t=0.50 s (a quarter of a full swing).