Topic 7.5 · BC

Reach the requested input

Builds on updating both coordinates after every step. 7 minutes.

Steps that end on the target

A problem can ask for \(y\) at one input, called the requested input. Here it is \(x = 2\), the dashed vertical line. The curve through \((0, 2)\) follows \(\frac{dy}{dx} = \frac{y}{2}\).

Press a button to choose a step size. The distance from the start to the dashed line is \(2 - 0 = 2\). Two steps of size 1 cover it, and so do four of 0.5.

The number of steps is the distance divided by the step size, so the last corner is on the dashed line every time.

A smaller step size needs more steps and gives a value closer to the curve: 4.5, 4.88 and 5.13, while the curve is at 5.44.

Any start, any requested input

The start is at \(x_0\), and the dashed line marks the requested input \(x^*\). The distance between them is \(x^* - x_0\).

The step sizes, added end to end, must equal this distance, so that the last corner is on the dashed line.

Move the requested input to the left of the start. The distance is then negative, so each step size is negative and the steps run left.

Press the button to make the step sizes unequal, as a problem may list them. They still add up to the distance.

Notation

  1. The dashed line marks the requested input \(x^*\). The distance from the start to it is negative when \(x^*\) is to the left of the start.

    \[x^* - x_0\]
  2. If every step has the same size \(h\), the number of steps is the distance divided by \(h\). It must be whole, because the path takes whole steps.

    \[n = \dfrac{x^* - x_0}{h}\]
  3. If the step sizes are different, the problem lists them. They must add up to the distance, so that the last corner is on the dashed line.

    \[h_1 + h_2 + \cdots + h_n = x^* - x_0\]
  4. Each step uses its own size in the Euler update from the previous skill. A negative size moves the path left, and the change in \(y\), the size times the slope, then has the opposite sign to the slope.

    \[\begin{aligned} x_{k+1} &= x_k + h_{k+1} \\ y_{k+1} &= y_k + h_{k+1}\, f(x_k, y_k) \end{aligned}\]

When it fails

Press the button. It puts the requested input at \(x = 2\), a distance of 2 from the start, and makes every step 0.6.

Three steps of 0.6 reach \(x = 1.8\) and four reach \(x = 2.4\), so neither corner is on the dashed line, because \(2 \div 0.6\) is not whole. Three steps of 0.6 and one of 0.2 add up to 2 and would end on the line.

Example 1: steps of different sizes

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

  1. The step sizes must add up to the distance from the start to the dashed line.

    \[0.5 + 1 = 1.5 = 1.5 - 0\]
  2. The first step has size 0.5, and the slope at \((0, 1)\) is 1.

    \[\begin{aligned} m_0 &= 2(0) + 1 = 1 \\ y_1 &= 1 + 0.5(1) = 1.5 \end{aligned}\]
  3. The second step has size 1, and the slope at \((0.5, 1.5)\) is 2.5. The last corner is on the dashed line, so \(f(1.5) \approx 4\).

    \[\begin{aligned} m_1 &= 2(0.5) + 1.5 = 2.5 \\ y_2 &= 1.5 + 1(2.5) = \cy{4} \end{aligned}\]

Example 2: steps to the left

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

  1. The requested input is to the left of the start, so the step size is negative. Two steps of \(-0.5\) cover the distance.

    \[\dfrac{1 - 2}{-0.5} = 2\]
  2. The slope at the start \((2, 3)\) is 4, so the orange segment there rises to the right.

    \[m_0 = 3 + 1 = 4\]
  3. A tempting wrong move: Add the slope times 0.5, as if the step went to the right.

    \[y_1 = 3 + 0.5(4) = 5\]

    The segment rises to the right, so a step to the left along it ends below the start. The red point \((1.5, 5)\) is above it.

  4. Multiply the slope by the step size \(-0.5\) instead. The change is negative, drawn in red, so the step falls to \((1.5, 1)\).

    \[\begin{aligned} \Delta y &= (-0.5)(4) = \cr{-2} \\ y_1 &= 3 - 2 = 1 \end{aligned}\]
  5. For the second step, the slope at \((1.5, 1)\) is 2. The last corner is \((1, 0)\), so \(f(1) \approx 0\).

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

Practice

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

How many steps of size 0.5 fit between the start and the dashed line?

Solution
  1. The distance from \(x = -1\) to \(x = 0.5\) is 1.5, so three steps of 0.5 reach the dashed line.

    \[n = \dfrac{0.5 - (-1)}{0.5} = 3\]
  2. In step 1, the slope at \((-1, 3)\) is \(-2\).

    \[y_1 = 3 + 0.5(1 - 3) = 2\]
  3. In step 2, the slope at \((-0.5, 2)\) is \(-1\).

    \[y_2 = 2 + 0.5(1 - 2) = 1.5\]
  4. In step 3, the slope at \((0, 1.5)\) is \(-0.5\), so \(f(0.5) \approx 1.25\).

    \[y_3 = 1.5 + 0.5(1 - 1.5) = \cy{1.25}\]

Questions

Questions 1 and 2 use the slope field of \(\dfrac{dy}{dx} = x - 2\). The orange dot starts an Euler path, and the dashed line marks the requested input.

  1. Euler steps of size 0.5 start at the orange dot \((1, 2)\). How many steps reach the dashed line at \(x = 3\)?

    • 4
    • 5
    • 6
    • 2
    Answer

    4

  2. A step of size \(-1\) starts at \((3, 1)\). Where does it end?

    • \((2, 0)\)
    • \((2, 2)\)
    • \((4, 2)\)
    • \((2, 1)\)
    Answer

    \((2, 0)\)

  3. Let \(y = f(x)\) be the solution to \(\dfrac{dy}{dx} = 3y\) with \(f(0) = 1\). Use Euler's method with two steps, the first of size 0.2 and the second of size 0.3, to approximate \(f(0.5)\).

    • 3.04
    • 2.5
    • 3.0625
    • 1.6
    Answer

    3.04

Summary

To find the number of equal steps, you divide the distance to the requested input by the step size and keep the sign.

This works because the step sizes, equal or not, add up to the distance, so the last corner is at the requested input.

You use it when a problem names the input where it wants the estimate.

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