Topic 7.5 · BC

Update both coordinates after every step

Builds on taking one Euler step. 7 minutes.

A path of steps

The equation \(\frac{dy}{dx} = x - y\) gives a slope at every point. The orange path starts at \((0, 1)\) and is made of Euler steps of size 0.5. The chalk curve is the exact solution through the start.

The first step uses the slope at \((0, 1)\), which is \(0 - 1 = -1\), so \(y\) changes by \(0.5 \times (-1) = -0.5\) and the step ends at \((0.5, 0.5)\). A point where one step ends and the next starts is called a corner.

The second step starts at the corner \((0.5, 0.5)\), so it uses the slope there, \(0.5 - 0.5 = 0\), and runs flat. The slope changed because the corner has a new \(x\) and a new \(y\).

Drag across the figure to add steps. Each new corner adds a row to the table, with the slope there and the change in y for the next step. A negative change is red.

Any equation, any number of steps

The first step starts at the orange point \(P_0\) and ends at the corner \(P_1\).

The second step starts at \(P_1\), so its slope is the field's slope at \(P_1\), not at \(P_0\).

Move the slider to add steps, or drag \(P_0\) to move the start. Each step starts where the last one ended and takes its slope from that point, so one rule describes every step.

Notation

  1. After \(k\) steps, the path is at the corner \(\cy{(x_k, y_k)}\). The start that the problem gives counts as the corner with \(k = 0\).

  2. The slope of the next step comes from \(\frac{dy}{dx} = f(x, y)\) at that corner, so it uses the current \(x_k\) and \(y_k\).

    \[m_k = \cy{f(x_k, y_k)}\]
  3. The step moves \(x\) by the step size \(h\) and changes \(y\) by \(h\) times the slope. The change is green here because it is positive, and the new corner has both new values.

    \[\begin{aligned} x_{k+1} &= x_k + h \\ y_{k+1} &= y_k + h\,\cy{f(x_k, y_k)} \end{aligned}\]
  4. Make a table with one row for each corner. Each row holds x, y, the slope and the change, and you calculate each new row from the row above.

When it fails

Suppose every step kept the slope at the start, \(-1\), instead of the slope at its own corner. Then the red path has slope \(-1\) everywhere, so it is a straight line that falls.

At the corner \((1, 0)\) the field's segment rises and the orange path turns up, but the red path continues to fall. The slope must come from the point where each step starts.

Example 1: two steps

Let \(y = f(x)\) be the solution to \(\dfrac{dy}{dx} = 2y - x\) with \(f(0) = 1\). Use Euler's method with two steps of size 0.5 to approximate \(f(1)\).

  1. At \((0, 1)\) the slope is 2, so \(y\) changes by \(0.5 \times 2 = 1\) and the first step ends at the corner \((0.5, 2)\).

    \[\begin{aligned} m_0 &= 2(1) - 0 = 2 \\ y_1 &= 1 + 0.5(2) = 2 \end{aligned}\]
  2. The second step starts at the corner \((0.5, 2)\), so use both new values to find its slope.

    \[m_1 = 2(2) - 0.5 = 3.5\]
  3. The second step changes \(y\) by \(0.5 \times 3.5 = 1.75\), so it ends at \((1, 3.75)\) and \(f(1) \approx 3.75\).

    \[y_2 = 2 + 0.5(3.5) = \cy{3.75}\]

Example 2: the new x matters too

Let \(y = f(x)\) be the solution to \(\dfrac{dy}{dx} = x^2 - y\) with \(f(0) = 2\). Use Euler's method with two steps of size 1 to approximate \(f(2)\).

  1. At \((0, 2)\) the slope is \(-2\), so \(y\) changes by \(1 \times (-2) = -2\) and the first step ends at the corner \((1, 0)\).

    \[\begin{aligned} m_0 &= 0^2 - 2 = -2 \\ y_1 &= 2 + 1(-2) = 0 \end{aligned}\]
  2. A tempting wrong move: For the second step, use the new \(y = 0\) with the \(x = 0\) that the problem gave.

    \[\begin{aligned} m_1 &= 0^2 - 0 = 0 \\ y_2 &= 0 + 1(0) = 0 \end{aligned}\]

    The step starts at the corner \((1, 0)\), not at \((0, 0)\), so \(x\) is 1 there. The orange segment at the corner rises, but the red step is flat.

  3. Use the new \(x = 1\) as well as the new \(y = 0\), because the corner is \((1, 0)\).

    \[m_1 = 1^2 - 0 = 1\]
  4. The second step adds \(1 \times 1 = 1\) to \(y\). It ends at \((2, 1)\), so \(f(2) \approx 1\).

    \[y_2 = 0 + 1(1) = \cy{1}\]

Practice

Let \(y = f(x)\) be the solution to \(\dfrac{dy}{dx} = 1 - xy\) with \(f(0) = 2\). Use Euler's method with two steps of size 0.5 to approximate \(f(1)\).

Move the slider to draw the first step. At its end, both x and y have new values, so use both to find the second slope.

Solution
  1. The slope at \((0, 2)\) is 1, so \(y\) grows by \(0.5 \times 1 = 0.5\) and the first step ends at the corner \((0.5, 2.5)\).

    \[\begin{aligned} m_0 &= 1 - 0(2) = 1 \\ y_1 &= 2 + 0.5(1) = 2.5 \end{aligned}\]
  2. The second step starts at \((0.5, 2.5)\), so use \(x = 0.5\) and \(y = 2.5\). The slope there is negative, so the step falls.

    \[m_1 = 1 - 0.5(2.5) = -0.25\]
  3. The change is \(0.5 \times (-0.25) = -0.125\), so the second step ends at \((1, 2.375)\) and \(f(1) \approx 2.375\).

    \[y_2 = 2.5 + 0.5(-0.25) = \cy{2.375}\]

Questions

The graph shows the slope field of \(\dfrac{dy}{dx} = 2 - x - y\) and an Euler path from \((0, 0)\), drawn one step at a time. Every step has size 1.

  1. The second step starts at the corner \((1, 2)\). What slope does it use?

    • −1
    • 2
    • 0
    Answer

    −1

  2. The third step starts at the corner \((2, 1)\). Where does it end?

    • \((3, 0)\)
    • \((3, 3)\)
    • \((3, 1)\)
    Answer

    \((3, 0)\)

  3. Let \(y = f(x)\) be the solution to \(\dfrac{dy}{dx} = 3x + y\) with \(f(1) = 1\). Use Euler's method with two steps of size 0.5 to approximate \(f(2)\).

    • 6.75
    • 5
    • 6
    • 3
    Answer

    6.75

Summary

Each step moves both coordinates, and the next slope comes from the new corner.

This matters because the slope of the field depends on both \(x\) and \(y\), so an old \(x\) gives a wrong slope.

You use this when an Euler approximation needs more than one step.

This is one of four skills in topic 7.5 of Which & Why: AP Calculus.