Menu
Sign up Sign in

AI HL · AHL 9

Differential Equations

AHL 9.14

Euler's method for second order equations

AHL 9.14

Euler's method for second order equations

Target: I can write a second order differential equation as a pair of coupled first order equations by letting y = dx/dt. (+5 more)

By the end of this section

Key points

From one second order equation to two first order equations

  • A second order equation has \(\frac{d^2x}{dt^2}\) in it. Since \(\frac{d^2x}{dt^2} = \frac{d}{dt}\left(\frac{dx}{dt}\right)\), give the first derivative its own letter: \(y = \frac{dx}{dt}\).
  • Then \(\frac{dy}{dt} = \frac{d^2x}{dt^2}\). If \(\frac{d^2x}{dt^2} = f\left(x, \frac{dx}{dt}, t\right)\), the pair is \(\frac{dx}{dt} = y\) and \(\frac{dy}{dt} = f(x, y, t)\).
  • Move every term except the second derivative to the right side first. Terms move with their sign changed: \(\frac{d^2x}{dt^2} + 6\frac{dx}{dt} + 4x = 7\) gives \(\frac{dy}{dt} = 7 - 6y - 4x\).
  • The starting values are \(x(0)\) and \(y(0) = x'(0)\). The second one is the speed, not a position.

Euler's method on the pair

  • Write the recurrences: \(t_{n+1} = t_n + h\), \(x_{n+1} = x_n + h\,y_n\), \(y_{n+1} = y_n + h\,f(x_n, y_n, t_n)\).
  • Both new values use the old row. Never use \(y_{n+1}\) to work out \(x_{n+1}\).
  • If the right side has t in it (such as \(2\cos t\)), use the \(t_n\) of that row, and work in radians.
  • x at time T is the x of row \(n = T/h\). With \(h = 0.1\), t = 2 is row 20.
  • Write down the recurrences and a couple of lines of the table. You do not write every row.

Graphs and step lengths

  • Graph x against t from the table to see the motion. The maximum displacement is the highest point of the graph.
  • Give a maximum to 2 significant figures when asked. Read x, not y and not t.
  • A smaller step length gives a more accurate estimate. To justify it, compare both estimates with a run using a much smaller step.
  • A step that is too long can give nonsense, such as a decaying motion that swings between positive and negative values.

A pendulum

  • A pendulum's angle satisfies an equation with \(\sin\theta\). It is not linear, so it has no solution by eigenvalues. Euler's method still works.
  • Write \(\omega=\dfrac{d\theta}{dt}\). Then \(\dfrac{d\theta}{dt}=\omega\) and \(\dfrac{d\omega}{dt}\) is the rest of the equation.
  • Use radians on the calculator. For a small angle \(\sin\theta\approx\theta\), which gives a linear equation. For a large angle the two models differ.

On the calculator

Euler's method in a spreadsheet

  • Put t, x and y in three columns. The first row holds t = 0, x(0) and y(0).
  • The next row of t adds h. The next row of x is the x above plus h times the y above. The next row of y is the y above plus h times the right side of dy/dt, using the x, y and t above.
  • Fill down until t reaches the time you want, then read the x on that row.
  • Check that the right side uses the row above, not the row it is in.

Screenshot and video to come

Graphing x against t and finding the maximum

  • Make a scatter plot of the x column against the t column.
  • Find the highest point on the graph, or scan down the x column for the largest value.
  • Read the x value of that point and round it to 2 significant figures.

Screenshot and video to come

Worked examples

Problems like the ones in class. Pick one, try it, then open the working.
Writing a second order equation as a pair

A displacement x satisfies \(\frac{d^2x}{dt^2} + 6\frac{dx}{dt} + 4x = 7\), with x(0) = 3 and x′(0) = −1. Write it as a pair of coupled first order equations and state the starting values.

Working
  1. Name the first derivative

    \(y = \frac{dx}{dt}\), so \(\frac{dx}{dt} = y\)

    The first equation is always this one.

  2. Isolate the second derivative

    \(\frac{d^2x}{dt^2} = 7 - 6\frac{dx}{dt} - 4x\)

    Move 6x′ and 4x across: both change sign.

  3. Replace the derivatives

    \(\frac{dy}{dt} = 7 - 6y - 4x\)

    \(\frac{d^2x}{dt^2}\) is \(\frac{dy}{dt}\) and \(\frac{dx}{dt}\) is \(y\).

  4. Starting values

    \(x(0) = 3,\quad y(0) = x'(0) = -1\)

    y starts at the starting speed.

Video walkthrough coming
Euler's method for a damped motion

Given \(\frac{d^2x}{dt^2} + 2\frac{dx}{dt} + 3x = 0\), x(0) = 4 and x′(0) = −1, use Euler's method with step length 0.1 to estimate x(1).

Working
  1. The pair

    \(\frac{dx}{dt} = y,\quad \frac{dy}{dt} = -2y - 3x\)

    Let y = dx/dt.

  2. The recurrences

    \(x_{n+1} = x_n + 0.1y_n,\quad y_{n+1} = y_n + 0.1(-2y_n - 3x_n)\)

    Start from x_0 = 4 and y_0 = −1.

  3. First rows

    n = 0: x = 4, y = −1, n = 1: x = 3.9, y = −2, n = 2: x = 3.7, y = −2.77

    Row 1: x_1 = 4 + 0.1(−1) = 3.9 and y_1 = −1 + 0.1(−2(−1) − 3(4)) = −2.

  4. From the calculator

    x_10 = 0.854745

    t = 1 is 10 steps of 0.1.

  5. Answer

    \(x(1) \approx 0.855\)

    Three significant figures.

Video walkthrough coming
A right side that depends on t

A system satisfies \(\frac{d^2x}{dt^2} + 3\frac{dx}{dt} + 4x = 2\cos t\), with x(0) = 1 and x′(0) = 0. Use Euler's method with step length 0.1 to estimate x(2).

Working
  1. The pair

    \(\frac{dx}{dt} = y,\quad \frac{dy}{dt} = -3y - 4x + 2\cos t\)

    The forcing term goes straight into dy/dt.

  2. The recurrences

    \(t_{n+1} = t_n + 0.1,\quad x_{n+1} = x_n + 0.1y_n,\quad y_{n+1} = y_n + 0.1(-3y_n - 4x_n + 2\cos t_n)\)

    Each row uses its own t_n.

  3. First rows

    n = 0: x = 1, y = 0, n = 1: x = 1, y = −0.2, n = 2: x = 0.98, y = −0.341

    Row 1: y_1 = 0 + 0.1(2 − 0 − 4) = −0.2.

  4. From the calculator

    x_20 = 0.143747

    t = 2 is row 20. Radian mode.

  5. Answer

    \(x(2) \approx 0.144\)

Video walkthrough coming
Reading the maximum from a graph

The displacement x cm of a damped spring t seconds after release satisfies \(\frac{d^2x}{dt^2} + 1.2\frac{dx}{dt} + 9x = 0\), with x(0) = 0 and x′(0) = 6. Use Euler's method with step length 0.1 to graph x for 0 ≤ t ≤ 3, then estimate the maximum displacement to 2 significant figures.

0.511.522.53−2−1.5−1−0.50.511.52tx
Working
  1. The pair

    \(\frac{dx}{dt} = y,\quad \frac{dy}{dt} = -1.2y - 9x\)

    Starting values x_0 = 0 and y_0 = 6.

  2. Table of values

    n = 0: x = 0, y = 6, n = 1: x = 0.6, y = 5.28, n = 2: x = 1.13, y = 4.11, …

    Run the recurrences to t = 3 (30 steps).

  3. Graph x against t

    highest point at t = 0.50, x = 1.889

    The graph rises, peaks, then falls through zero.

  4. Answer

    maximum displacement ≈ 1.9 cm

    2 significant figures. The peak is the largest x in the table.

Video walkthrough coming
Comparing two step lengths

A motion satisfies \(\frac{d^2x}{dt^2} + 3\frac{dx}{dt} + 2x = 0\), with x(0) = 1 and x′(0) = 0. Use Euler's method to estimate x(4) with step length (a) 1 and (b) 0.5. Which estimate is more accurate?

Working
  1. Step length 1

    4 steps: x_4 = −1.00

    Rows: x = 1, 1, −1, 1, −1.

  2. Step length 0.5

    8 steps: x_8 = 0.00781

    Same recurrences with h = 0.5.

  3. A check run

    step length 0.1: x(4) ≈ 0.0294

    A much smaller step is a good reference.

  4. Compare

    |0.00781 − 0.0294| is much smaller than |−1.00 − 0.0294|

    The step length 0.5 estimate is closer, so it is more accurate. A smaller step follows the curve more closely. Step length 1 even gives a negative x.

Video walkthrough coming
A damped pendulum

A pendulum swings through the air. The angle \(\theta\) radians that it makes with the vertical after \(t\) seconds satisfies \(\dfrac{d^2\theta}{dt^2}+0.4\dfrac{d\theta}{dt}+20\sin\theta=0\), with \(\theta(0)=0.5\) and \(\theta'(0)=0\). Write the equation as a pair of first order equations and use Euler's method with step length 0.1 to estimate \(\theta(1)\).

Working
  1. The pair

    \(\dfrac{d\theta}{dt}=\omega,\quad \dfrac{d\omega}{dt}=−0.4\omega-20\sin\theta\)

    Let ω = dθ/dt. The sine stays: the equation is not linear.

  2. The recurrences

    \(\theta_{n+1}=\theta_n+0.1\omega_n,\quad \omega_{n+1}=\omega_n+0.1(−0.4\omega_n-20\sin\theta_n)\)

    Start from θ₀ = 0.5 and ω₀ = 0. Radians.

  3. First rows

    n = 0: θ = 0.5, ω = 0; n = 1: θ = 0.500, ω = −0.959; n = 2: θ = 0.404, ω = −1.88

    Row 1: ω₁ = 0 + 0.1(0 − 20 sin 0.5) = −0.959.

  4. From the calculator

    θ₁₀ = −0.576770

    t = 1 is 10 steps of 0.1.

  5. Answer

    \(\theta(1)\approx −0.577\) radians

    Three significant figures.

Video walkthrough coming