Skip to content
Family Table Math
Auto

Euler's Method for Coupled Systems

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.

For dydx=f(x,y)\dfrac{dy}{dx} = f(x, y) with step size hh:

xn+1=xn+h,yn+1=yn+h f(xn,yn)x_{n+1} = x_n + h, \qquad y_{n+1} = y_n + h\,f(x_n, y_n)

New value = old value + step × slope at the old point.

A coupled system has two quantities xx and yy that both change with time tt, where each rate can depend on both quantities (and on tt):

dxdt=f1(x,y,t),dydt=f2(x,y,t)\frac{dx}{dt} = f_1(x, y, t), \qquad \frac{dy}{dt} = f_2(x, y, t)

Euler’s method updates both at once, using the old values in both formulas:

tn+1=tn+hxn+1=xn+h f1(xn,yn,tn)yn+1=yn+h f2(xn,yn,tn)\begin{aligned} t_{n+1} &= t_n + h \\ x_{n+1} &= x_n + h\,f_1(x_n, y_n, t_n) \\ y_{n+1} &= y_n + h\,f_2(x_n, y_n, t_n) \end{aligned}

A table with columns tt, xx, yy, dxdt\dfrac{dx}{dt}, dydt\dfrac{dy}{dt} keeps the work organized.

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 tt, xx, yy in columns A, B, C, with the starting values in row 2. Then in row 3:

CellFormula (for step hh 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 d2xdt2=f ⁣(x,dxdt,t)\dfrac{d^2x}{dt^2} = f\!\left(x, \dfrac{dx}{dt}, t\right) becomes a coupled first-order system if you give the velocity its own name. Let y=dxdty = \dfrac{dx}{dt}. Then d2xdt2=dydt\dfrac{d^2x}{dt^2} = \dfrac{dy}{dt}, so

dxdt=y,dydt=f(x,y,t)\frac{dx}{dt} = y, \qquad \frac{dy}{dt} = f(x, y, t)

You need two initial conditions: the starting value of xx and the starting value of y=dxdty = \dfrac{dx}{dt}. Then use Euler’s method on the system as above. In context, xx is often a position and yy 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.

Use Euler’s method with h=0.1h = 0.1 to estimate x(0.2)x(0.2) and y(0.2)y(0.2) for

dxdt=x−y,dydt=x+y,x(0)=1, y(0)=0\frac{dx}{dt} = x - y, \qquad \frac{dy}{dt} = x + y, \qquad x(0) = 1,\ y(0) = 0

Solution.

ttxxyydxdt=x−y\dfrac{dx}{dt} = x - ydydt=x+y\dfrac{dy}{dt} = x + y
0011001111
0.10.11+0.1(1)=1.11 + 0.1(1) = 1.10+0.1(1)=0.10 + 0.1(1) = 0.1111.21.2
0.20.21.1+0.1(1)=1.21.1 + 0.1(1) = 1.20.1+0.1(1.2)=0.220.1 + 0.1(1.2) = 0.22

So x(0.2)≈1.2x(0.2) \approx 1.2 and y(0.2)≈0.22y(0.2) \approx 0.22.

On an island, the number of rabbits xx and foxes yy after tt years are modelled by

dxdt=0.5x−0.01xy,dydt=−0.4y+0.005xy\frac{dx}{dt} = 0.5x - 0.01xy, \qquad \frac{dy}{dt} = -0.4y + 0.005xy

with x(0)=100x(0) = 100 and y(0)=20y(0) = 20.

(a) Explain the meaning of each term.

(b) Use Euler’s method with h=0.1h = 0.1 to find the populations after 0.20.2 years, by hand.

(c) Use technology with h=0.1h = 0.1 to estimate both populations after 55 years.

(d) Show that (80,50)(80, 50) is an equilibrium point and describe how the populations behave.

Solution.

(a) Without foxes, rabbits grow (0.5x0.5x). Meetings between rabbits and foxes (proportional to xyxy) reduce rabbits (−0.01xy-0.01xy) and help foxes grow (+0.005xy+0.005xy). Without rabbits, foxes die out (−0.4y-0.4y).

(b)

ttxxyydxdt\dfrac{dx}{dt}dydt\dfrac{dy}{dt}
00100100202050−20=3050 - 20 = 30−8+10=2-8 + 10 = 2
0.10.110310320.220.230.69430.6942.3232.323
0.20.2106.0694106.069420.432320.4323

For example, at t=0.1t = 0.1: dxdt=0.5(103)−0.01(103)(20.2)=51.5−20.806=30.694\dfrac{dx}{dt} = 0.5(103) - 0.01(103)(20.2) = 51.5 - 20.806 = 30.694. After 0.20.2 years there are about 106106 rabbits and 2020 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)), 5050 steps reach t=5t = 5:

x(5)≈96.9,y(5)≈106(3 s.f.)x(5) \approx 96.9, \qquad y(5) \approx 106 \quad \text{(3 s.f.)}

So after 55 years there are about 9797 rabbits and 106106 foxes.

(d) At (80,50)(80, 50): dxdt=40−0.01(80)(50)=0\dfrac{dx}{dt} = 40 - 0.01(80)(50) = 0 and dydt=−20+0.005(80)(50)=0\dfrac{dy}{dt} = -20 + 0.005(80)(50) = 0. Neither population changes, so it is an equilibrium. Starting from (100,20)(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 with step 0.1 for the rabbit and fox model over 20 years. Left: rabbits rise to about 200 near year 18 after a first peak near year 3, and fox numbers rise after each rabbit peak, so the two populations oscillate with the foxes lagging behind. Right: in the phase plane the point (x, y) circles anticlockwise around the equilibrium (80, 50), spiralling slowly outward. 2 4 6 8 10 12 14 16 18 20 40 60 80 100 120 140 160 180 200 Populations over time time t (years) rabbits x foxes y number of animals 20 40 60 80 100 120 140 160 180 200 20 40 60 80 100 120 Phase plane: (x, y) start (100, 20) equilibrium (80, 50) rabbits x foxes y
Euler’s method for the rabbit–fox model (h=0.1h = 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.01h = 0.01 the estimates at t=5t = 5 become about 94.694.6 rabbits and 102102 foxes, noticeably different from part (c), so the step h=0.1h = 0.1 is only roughly accurate here.

A mass on a spring with some friction has displacement xx metres after tt seconds, where

d2xdt2=−4x−0.5dxdt,x(0)=1,dxdt(0)=0\frac{d^2x}{dt^2} = -4x - 0.5\frac{dx}{dt}, \qquad x(0) = 1, \quad \frac{dx}{dt}(0) = 0

(a) Write this as a pair of coupled first-order equations.

(b) Use Euler’s method with h=0.1h = 0.1 to estimate the displacement and velocity at t=0.3t = 0.3.

Solution.

(a) Let y=dxdty = \dfrac{dx}{dt} (the velocity). Then

dxdt=y,dydt=−4x−0.5y,x(0)=1, y(0)=0\frac{dx}{dt} = y, \qquad \frac{dy}{dt} = -4x - 0.5y, \qquad x(0) = 1,\ y(0) = 0

(b)

ttxxyydxdt=y\dfrac{dx}{dt} = ydydt=−4x−0.5y\dfrac{dy}{dt} = -4x - 0.5y
00110000−4-4
0.10.111−0.4-0.4−0.4-0.4−4+0.2=−3.8-4 + 0.2 = -3.8
0.20.20.960.96−0.78-0.78−0.78-0.78−3.84+0.39=−3.45-3.84 + 0.39 = -3.45
0.30.30.8820.882−1.125-1.125

At t=0.3t = 0.3 s the displacement is about 0.8820.882 m and the velocity about −1.13-1.13 m/s: the mass has been released and is speeding up back toward x=0x = 0.

Updating x first and then using the new x to update y. Both new values must be computed from the old pair (xn,yn)(x_n, y_n). In a spreadsheet, every formula in row n+1n + 1 should refer only to row nn.

Forgetting to multiply by the step size. The change in xx is h×dxdth \times \dfrac{dx}{dt}, not dxdt\dfrac{dx}{dt}. With h=0.1h = 0.1 a rate of 3030 rabbits per year adds only 33 rabbits.

Missing the second initial condition. A second-order equation needs both x(0)x(0) and dxdt(0)\dfrac{dx}{dt}(0). Without the starting velocity you can’t take the first step for yy.

Writing dy/dt = x when converting a second-order equation. The first equation is always dxdt=y\dfrac{dx}{dt} = y (the definition of yy), and the second is the original equation with d2xdt2\dfrac{d^2x}{dt^2} replaced by dydt\dfrac{dy}{dt} and dxdt\dfrac{dx}{dt} replaced by yy.

Forgetting to update t. If the rates depend on tt, use the current tnt_n at every step. It’s easy to leave t=0t = 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 dxdt=2x−y\dfrac{dx}{dt} = 2x - y, dydt=x+t\dfrac{dy}{dt} = x + t, with x(0)=1x(0) = 1 and y(0)=2y(0) = 2, use one step of Euler’s method with h=0.5h = 0.5 to estimate x(0.5)x(0.5) and y(0.5)y(0.5).

Solution

At t=0t = 0: dxdt=2(1)−2=0\dfrac{dx}{dt} = 2(1) - 2 = 0 and dydt=1+0=1\dfrac{dy}{dt} = 1 + 0 = 1.

x(0.5)≈1+0.5(0)=1,y(0.5)≈2+0.5(1)=2.5x(0.5) \approx 1 + 0.5(0) = 1, \qquad y(0.5) \approx 2 + 0.5(1) = 2.5

2. (Warm-up) Write d2xdt2=3x−2dxdt+t\dfrac{d^2x}{dt^2} = 3x - 2\dfrac{dx}{dt} + t, with x(0)=4x(0) = 4 and dxdt(0)=−1\dfrac{dx}{dt}(0) = -1, as a system of coupled first-order equations with initial conditions.

Solution

Let y=dxdty = \dfrac{dx}{dt}:

dxdt=y,dydt=3x−2y+t,x(0)=4, y(0)=−1\frac{dx}{dt} = y, \qquad \frac{dy}{dt} = 3x - 2y + t, \qquad x(0) = 4,\ y(0) = -1

3. (Warm-up) For dxdt=y\dfrac{dx}{dt} = y, dydt=−x\dfrac{dy}{dt} = -x, with x(0)=0x(0) = 0 and y(0)=1y(0) = 1, use Euler’s method with h=0.1h = 0.1 to estimate x(0.2)x(0.2) and y(0.2)y(0.2).

Solution
ttxxyydxdt=y\dfrac{dx}{dt} = ydydt=−x\dfrac{dy}{dt} = -x
0000111100
0.10.10.10.11111−0.1-0.1
0.20.20.20.20.990.99

x(0.2)≈0.2x(0.2) \approx 0.2 and y(0.2)≈0.99y(0.2) \approx 0.99. (The exact solution is x=sin⁡tx = \sin t, y=cos⁡ty = \cos t, giving 0.1990.199 and 0.9800.980 to 3 s.f.)

4. (Core) Two species compete for food. Their populations (in thousands) satisfy

dxdt=x(3−x−y),dydt=y(2−x−y)\frac{dx}{dt} = x(3 - x - y), \qquad \frac{dy}{dt} = y(2 - x - y)

with x(0)=1x(0) = 1 and y(0)=0.5y(0) = 0.5. Use Euler’s method with h=0.1h = 0.1 to estimate both populations at t=0.2t = 0.2, to 3 s.f.

Solution
ttxxyydxdt\dfrac{dx}{dt}dydt\dfrac{dy}{dt}
00110.50.51(1.5)=1.51(1.5) = 1.50.5(0.5)=0.250.5(0.5) = 0.25
0.10.11.151.150.5250.5251.15(1.325)=1.523751.15(1.325) = 1.523750.525(0.325)=0.1706250.525(0.325) = 0.170625
0.20.21.3023751.3023750.54206250.5420625

x(0.2)≈1.30x(0.2) \approx 1.30 thousand and y(0.2)≈0.542y(0.2) \approx 0.542 thousand (3 s.f.).

5. (Core) The displacement xx of an undamped spring satisfies d2xdt2=−9x\dfrac{d^2x}{dt^2} = -9x, with x(0)=1x(0) = 1 and dxdt(0)=0\dfrac{dx}{dt}(0) = 0.

  • (a) Use Euler’s method with h=0.1h = 0.1 to estimate x(0.3)x(0.3).
  • (b) The exact solution is x=cos⁡3tx = \cos 3t. Find the percentage error in your estimate, and suggest how to improve it.
Solution

(a) Let y=dxdty = \dfrac{dx}{dt}, so dxdt=y\dfrac{dx}{dt} = y and dydt=−9x\dfrac{dy}{dt} = -9x.

ttxxyydxdt=y\dfrac{dx}{dt} = ydydt=−9x\dfrac{dy}{dt} = -9x
00110000−9-9
0.10.111−0.9-0.9−0.9-0.9−9-9
0.20.20.910.91−1.8-1.8−1.8-1.8−8.19-8.19
0.30.30.730.73−2.619-2.619

x(0.3)≈0.73x(0.3) \approx 0.73.

(b) Exactly, x(0.3)=cos⁡0.9≈0.6216x(0.3) = \cos 0.9 \approx 0.6216 (radians). The percentage error is 0.73−0.62160.6216×100%≈17.4%\dfrac{0.73 - 0.6216}{0.6216} \times 100\% \approx 17.4\%. Use a smaller step size (with technology).

6. (Core) A predator–prey system is modelled by

dxdt=0.6x−0.02xy,dydt=−0.3y+0.004xy\frac{dx}{dt} = 0.6x - 0.02xy, \qquad \frac{dy}{dt} = -0.3y + 0.004xy

where xx is the number of prey and yy the number of predators after tt months, with x(0)=50x(0) = 50 and y(0)=10y(0) = 10.

  • (a) Find the equilibrium point with x,y>0x, y \gt 0.
  • (b) Write down the first step of Euler’s method with h=0.05h = 0.05.
  • (c) Use technology with h=0.05h = 0.05 to estimate x(2)x(2) and y(2)y(2).
  • (d) Describe what is likely to happen to the predators shortly after t=2t = 2.
Solution

(a) dxdt=x(0.6−0.02y)=0\dfrac{dx}{dt} = x(0.6 - 0.02y) = 0 gives y=30y = 30; dydt=y(−0.3+0.004x)=0\dfrac{dy}{dt} = y(-0.3 + 0.004x) = 0 gives x=75x = 75. The equilibrium is (75,30)(75, 30).

(b) At t=0t = 0: dxdt=30−10=20\dfrac{dx}{dt} = 30 - 10 = 20 and dydt=−3+2=−1\dfrac{dy}{dt} = -3 + 2 = -1. So x(0.05)≈50+0.05(20)=51x(0.05) \approx 50 + 0.05(20) = 51 and y(0.05)≈10+0.05(−1)=9.95y(0.05) \approx 10 + 0.05(-1) = 9.95.

(c) 4040 steps of a spreadsheet give x(2)≈112x(2) \approx 112 and y(2)≈10.1y(2) \approx 10.1 (3 s.f.).

(d) The prey population (112112) is now well above 7575, so −0.3+0.004x>0-0.3 + 0.004x \gt 0 and dydt>0\dfrac{dy}{dt} \gt 0: with plenty of food, the predator population will start to grow quickly.

7. (Core) A damped spring satisfies d2xdt2+0.4dxdt+4x=0\dfrac{d^2x}{dt^2} + 0.4\dfrac{dx}{dt} + 4x = 0, with x(0)=2x(0) = 2 and dxdt(0)=0\dfrac{dx}{dt}(0) = 0.

  • (a) Write the equation as a coupled first-order system.
  • (b) Use technology to estimate x(1)x(1) with h=0.1h = 0.1 and with h=0.01h = 0.01. Comment on your results.
Solution

(a) Let y=dxdty = \dfrac{dx}{dt}. Rearranging, d2xdt2=−4x−0.4dxdt\dfrac{d^2x}{dt^2} = -4x - 0.4\dfrac{dx}{dt}, so

dxdt=y,dydt=−4x−0.4y,x(0)=2, y(0)=0\frac{dx}{dt} = y, \qquad \frac{dy}{dt} = -4x - 0.4y, \qquad x(0) = 2,\ y(0) = 0

(b) With h=0.1h = 0.1 (1010 steps): x(1)≈−0.656x(1) \approx -0.656. With h=0.01h = 0.01 (100100 steps): x(1)≈−0.532x(1) \approx -0.532 (3 s.f.).

The two estimates differ by more than 0.10.1, so the larger step isn’t reliable. The smaller step is more accurate. (A further check with h=0.001h = 0.001 gives about −0.518-0.518, close to the true value of about −0.516-0.516.) Either way, after 11 second the mass is on the other side of its rest position.

8. (Challenge) Consider dxdt=−y\dfrac{dx}{dt} = -y, dydt=x\dfrac{dy}{dt} = x, whose exact solutions move around circles centred at the origin.

  • (a) Show that one step of Euler’s method with step hh multiplies x2+y2x^2 + y^2 by 1+h21 + h^2.
  • (b) Starting at (1,0)(1, 0) with h=0.1h = 0.1, find the distance from the origin after 1010 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−hynx_{n+1} = x_n - hy_n and yn+1=yn+hxny_{n+1} = y_n + hx_n. Then

xn+12+yn+12=xn2−2hxnyn+h2yn2+yn2+2hxnyn+h2xn2=(1+h2)(xn2+yn2)\begin{aligned} x_{n+1}^2 + y_{n+1}^2 &= x_n^2 - 2hx_ny_n + h^2y_n^2 + y_n^2 + 2hx_ny_n + h^2x_n^2 \\ &= (1 + h^2)\left(x_n^2 + y_n^2\right) \end{aligned}

(b) The squared distance starts at 11 and is multiplied by 1.011.01 each step, so after 1010 steps it is 1.01101.01^{10}. The distance is 1.0110=1.015≈1.051\sqrt{1.01^{10}} = 1.01^5 \approx 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 11 m swings so that its angle θ\theta (in radians) from the vertical after tt seconds satisfies

d2θdt2=−9.8sin⁡θ,θ(0)=0.2,dθdt(0)=0\frac{d^2\theta}{dt^2} = -9.8\sin\theta, \qquad \theta(0) = 0.2, \quad \frac{d\theta}{dt}(0) = 0
  • (a) Use Euler’s method with h=0.05h = 0.05 to estimate θ\theta and dθdt\dfrac{d\theta}{dt} at t=0.1t = 0.1, to 3 s.f.
  • (b) Use technology with h=0.01h = 0.01 to estimate the time when the pendulum first passes through the vertical.
Solution

(a) Let ω=dθdt\omega = \dfrac{d\theta}{dt}, so dθdt=ω\dfrac{d\theta}{dt} = \omega and dωdt=−9.8sin⁡θ\dfrac{d\omega}{dt} = -9.8\sin\theta.

ttθ\thetaω\omegadθdt=ω\dfrac{d\theta}{dt} = \omegadωdt=−9.8sin⁡θ\dfrac{d\omega}{dt} = -9.8\sin\theta
000.20.20000−1.94696-1.94696
0.050.050.20.2−0.097348-0.097348−0.097348-0.097348−1.94696-1.94696
0.10.10.1951330.195133−0.194696-0.194696

θ(0.1)≈0.195\theta(0.1) \approx 0.195 rad and dθdt(0.1)≈−0.195\dfrac{d\theta}{dt}(0.1) \approx -0.195 rad/s (3 s.f.).

(b) The pendulum passes through the vertical when θ=0\theta = 0. In the spreadsheet with h=0.01h = 0.01, θ\theta is still positive at t=0.50t = 0.50 (θ≈0.0021\theta \approx 0.0021) and first becomes negative at t=0.51t = 0.51 (θ≈−0.0043\theta \approx -0.0043). So it first passes through the vertical at about t=0.50t = 0.50 s (a quarter of a full swing).