Math Insight

Solving pure-time differential equations with the Forward-Euler algorithm

Math 201, Spring 2017
Name:
ID #:
Due date:
Table/group #:
Group members:
Total points: 3
  1. In this problem, we will explore a method for approximating solutions to differential equations. Let's consider the pure-time differential equation \begin{align*} x'(t) &= f(t)\\ x(0) &= -5 \end{align*} where $f(t) = 2 t - 1$.
    1. Recall that the derivative, along with a point, can be used to find the linear approximation (or tangent line) to a function. Even though we might not know what $x(t)$ is, we can still use the initial condition and the derivative to find the linear approximation. Remember that the formula for the linear approximation at $t=a$ is $L_a(t) = x(a)+x'(a) (t-a)$. Write down the linear approximation for $x(t)$ at $t=0$.
      $L_0(t) =$
      $+$
      $($
      $)$
      (Even though the linear approximation involves a derivative, you will not need to take any derivatives, as you are given the formula for the derivative in the statement of the differential equation. The hard part isn't determining the derivative $x'(t)$, instead it is estimating the values of the function $x(t)$ itself.)

      Suppose we want to know what $x (4)$ is. We could estimate it by plugging $4$ into the linear approximation. What does that give us?
      $L_0(4) =$
      $+$
      $($
      $)=$

      In general, what do we know about the error of the linear approximation (in other words, the difference between a function and its linear approximation)?

    2. Is this close to the actual value? Probably not, because $4$ is not very close to $0$. Is there a way we can use the idea of linear approximation to get a closer estimate? Can we use the linear approximation at some point close to $4$? Why or why not?

      Rather than taking one large step from $0$ all the way to $4$, we could break up the approximation into two steps, where each step is smaller. We could use the linear approximation at $t=0$ to find an estimate for $t=2$. Once we have an estimate for $x(2)$, we can calculate another linear approximate based on that new value and use that new linear approximation to estimate $x(4)$.

      For the first step, we plug $t=2$ into the linear approximation we found at $t=0$ (i.e., what you calculated in part a):
      $L_0(2)=$
      $+$
      $($
      $)=$

      For the second step, use the answer from the first step as an estimate of $x(2)$ and create a new linear approximation at $t=2$:
      $L_2(t)=x(2) + x'(2) (t-2)$
      The only new information you'll need is the derivative $x'(2)$, but you can look up that value directly from the differential equation. (Again, no taking derivatives here.)
      $L_2(t)=$
      $+$
      $($
      $)$
      Use $L_2(t)$ to estimate $x(4)$.
      $L_2(4) =$
      $+$
      $($
      $)=$

      This estimate is quite different from the estimate in part a. Does that necessarily mean that it is a better estimate?

    3. To determine which answer is better, we will cheat and calculate the answer from the solution to our particular differential equation, which is $x(t)=t^{2} - t - 5$. (In more difficult cases, we won't know the actual solution, which is why we'd use the Forward Euler algorithm.) Given the solution, the actual value is $x (4) = $
      . Which of our estimates is closer?
      Is either one a good estimate?
      .

      The problem with the second estimate is that $2$ is still not close to $0$, so the estimate for $x(2)$ is not close to the actual value. How can we fix this problem?
      As we decrease the time intervals, the estimate for $x (4)$ will approach the actual value. If we wanted to, we could take the time intervals to be very small (perhaps getting estimates at $t=.001$, $t=.002$, $t=.003$, all the way up to $t=3.999$ and $t=4$), which would result in a very close estimate. What is the problem with this approach?

      Typically we'll use a computer program so we don't have to do all these repetitive steps manually. Even so, we often have to struggle with a tradeoff between accuracy and computational time, especially with “difficult problems“ where the time step we want for accuracy might make the computer program take to long to run.

    4. Sketch your solution for $\Delta t=2$ using the following applet. The applet breaks the process into multiple steps. For step=1, sketch the initial condition. For step=2, sketch the linear approximation $L_0(t)$; in the applet, all you need to do is get the slope $m=x'(0)$ correct. For step=3, show the result $L_0(2)$. Repeat this process with step=4 and step=5 to sketch $L_2(t)$ and estimate the final result of $L_2(4)$.

      If you select the “exact” checkbox, the applet will show the exact solution $x(t)=t^{2} - t - 5$. If you have exact checked while constructing the graph, it will show you the tangent line of the exact solution when you are on the steps to construct the linear approximations $L_a(t)$. (The linear approximations will be parallel to the exact tangent lines, but shifted up or down due to errors from the previous steps.)

      Feedback from applet
      Initial condition:
      Points for curve 1:
      Points for curve 2:
      Points for curve 3:
      Slopes for curve 1:
      Slopes for curve 2:
      Slopes for curve 3:

      (After completing the estimate for $\Delta t=2$, the applet should give you credit for the initial condition and the points and slopes for curve 1. We'll come back to the applet to complete curves 2 and 3.)

    5. This approach to estimating solutions with successive linear approximations is known as the Forward Euler algorithm for solving differential equations. Let's derive a formula for this algorithm.

      The first step is to choose a step size, which we'll call $\Delta t$. Then, if we start at $t_0=0$, we add $\Delta t$ to get that the first time step will be $t_1 =$
      . We add another $\Delta t$ to compute that the second time step is $t_2=$
      . In general the $n$-th time step will be $t_n = $
      . We'll denote our estimate of $x(t)$ at time $t=t_n$ as $\hat{ x }(t_n)$.

      If we have the estimate $\hat{ x }(t_n)$ at time $t=t_n$, then the linear approximate at $t=t_n$ is $L_{t_n}(t) = \hat{ x }(t_n) + x'(t_n) (t - t_n).$ We calculate a new estimate at the next time step $t=t_{n+1}$ by plugging in $t=t_{n+1}$: $$\hat{ x }(t_{n+1}) = L_{t_{n}} (t_{n+1}) = \hat{ x }(t_n) + x'(t_n) (t_{n+1} - t_n).$$ Since $t_{n+1}-t_n = \Delta t$, the formula for the Forward Euler step simplifies to $$\hat{ x }(t_{n+1}) = \hat{ x }(t_n) + x'(t_n) \Delta t.$$

      To use the Forward Euler algorithm to estimate the solution, you just keep using the above equation for $n=0,1,2, \ldots$.

      Let's look at how this connects to parts a and b. In part a, $\Delta t =$
      and we had to take
      step(s) to reach the desired value. In part b, $\Delta t = $
      and we had to take
      step(s) to reach the desired value.

    6. Use $\Delta t = 1$ to estimate $x(4)$ for the differential equation from the start of this problem. Our time steps are therefore $t_1=$
      , $t_2=$
      , $t_3=$
      , and $t_4=$

      $\hat{ x }(t_1) =\hat{ x }(_) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_2) = \hat{ x }(_) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_3) = \hat{ x }(_) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_4) = \hat{ x }(_) = $
      $+$
      $\times$
      $=$

      Plot your solution using the above applet. Change $\Delta t$ to 1 using the lower slider. For step 1, the initial condition should already be set from the previous results. Skip to step 2 to calculate the slope and step 3 to calculate $\hat{ x }(t_1)$, and continue in this pattern up to step 9, where you'll calculate $\hat{ x }(t_4)$. The slopes you calculate in even numbered steps should match the second columns of numbers entered above. The points calculated in odd steps should match the values of the time steps and the estimates entered in the last column above.

    7. Use $\Delta t = \frac{1}{2}$ to estimate $x(4)$ for the differential equation from the start of this problem. The time steps are $t_1=$
      , $t_2=$
      , $t_3=$
      , etc. and we can stop when $t_n=4$, which is when $n=$
      .

      $\hat{ x }(t_1) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_2) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_3) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_4) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_5) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_6) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_7) = $
      $+$
      $\times$
      $=$

      $\hat{ x }(t_8) = $
      $+$
      $\times$
      $=$

      Plot your solution using the above applet. Change $\Delta t$ to $\frac{1}{2}$ using the lower slider, and continue as in the previous part. Again the slopes should match the second column of numbers and the points should match the times and calculations from the last column of numbers.

    1. Consider the differential equation \begin{align*} \frac{d y}{d t} &= f(t)\\ y(0) &= 2 \end{align*} where $f(t) = e^{\sqrt{t}}$.

      Use the Forward Euler method with step size $0.2$ to approximate $y(1)$. Note: Answers must be accurate to at least 4 significant digits. To prevent round-off error, though, make sure you use more than that in your computations.

      How many steps do you need to take?

      $\hat{ y }(t_1) = $
      $+$
      $($
      $)=$

      $\hat{ y }(t_2) = $
      $+$
      $($
      $)=$

      $\hat{ y }(t_3) = $
      $+$
      $($
      $)=$

      $\hat{ y }(t_4) = $
      $+$
      $($
      $)=$

      $\hat{ y }(t_5) = $
      $+$
      $($
      $)=$

    2. Consider the differential equation \begin{align*} \frac{d z}{d t} &= g(t)\\ z(0) &= -1 \end{align*} where $g(t) = \sqrt{t} + t$.

      Use the Forward Euler method with step size $0.5$ to approximate $z(2)$. Note: Answers must be accurate to at least 4 significant digits. To prevent round-off error, though, make sure you use more than that in your computations.

      How many steps do you need to take?

      $\hat{ z }(t_1) = $
      $+$
      $($
      $)=$

      $\hat{ z }(t_2) = $
      $+$
      $($
      $)=$

      $\hat{ z }(t_3) = $
      $+$
      $($
      $)=$

      $\hat{ z }(t_4) = $
      $+$
      $($
      $)=$