Math Insight

Forward Euler introduction

Math 1241, Fall 2020
Name:
ID #:
Due date: Dec. 4, 2020, 11:59 p.m.
Table/group #:
Group members:
Total points: 3
  1. Consider the dynamical system \begin{align*} z'(t) &= - z^{2} + 1\\ z(0) &=-0.8. \end{align*} (We could also write the differential equation as $z'(t) = - z^{2}{\left (t \right )} + 1$. Also, by $-z^2$, we mean take the number $z$, square it, then multiply by $-1$, so $-z^2$ is a negative number if $z$ is either positive or negative.) After reviewing how to solve this system graphically, we will use the Forward Euler algorithm to obtain a more accurate estimate of the solution $z(t)$.
    1. Sketch a phase line with equilibria (use closed circles for stable and open circles for unstable) and vector field indicating the direction of motion.
      Feedback from applet
      equilibria:
      number of equilibria:
      stability of equilibria:
      vector field:
    2. Using the phase line as a guide, sketch the solution $z(t)$ (i.e., a plot of $z$ versus $t$). Since we cannot determine how fast the solution is moving from the phase line, this plot does not have the scale for $t$ labeled. We just want a sketch of the approximate behavior of the solution.
      Feedback from applet
      Final values of curves:
      Initial conditions of curves:
    3. We don't have a formula for the solution $z(t)$ that you just sketched. But, we do have some information it. The differential equation $z'(t)=- z^{2} + 1$ gives the slope $z'(t)$ of the function $z(t)$ in terms of the value of the function $z=z(t)$ itself. z0

      Since we know that at time $t=0$, $z(0)=-0.8$, we can determine from the equation the initial slope of $z(t)$. What is the slope $z'(0)$ of the function $z(t)$ when $t=0$?

    4. As soon as $z(t)$ changes away from the value $-0.8$, then the slope will change to always be $- z^{2}{\left (t \right )} + 1$. But, to make the situation simpler, let's pretend that the slope $z'(t)$ did not change but was fixed at this value $z'(0)$ that you calculated. If the slope, or derivative, of a function is a constant, then the function is linear. Write down a linear approximation for $z(t)$, based on assuming the slope is fixed at the number $z'(0)$ and that $z(0)=-0.8$.

      $L_0(t)=$

    5. According to this linear approximation, what should be the value of $z(1)$?

      $z(1) \approx L_0(1) = $

    6. By using this linear approximation, you have estimated the value of $z(1)$ using one step of the Forward Euler algorithm with a step size of $\Delta t = 1$. If we let $f(z)= - z^{2} + 1,$ we can write the Forward Euler algorithm compactly as $z(0 + \Delta t) = z(0) + f(z(0))\Delta t.$ Repeat the calculation with this formula to verify you get the same answer for $z(1)$.

      $z(1) = z(0+\Delta t) = z(0)+f(z(0))\Delta t$
      $=$
      $+ f($
      $) \cdot $

      $=$
      $+ $
      $ \cdot $

      $=$

    7. Now that we have an estimate of $z(1)$, we can use the Forward Euler algorithm to take another step of size $\Delta t=1$ and estimate $z(2)$. If we use the linear approximation at $t=1$, the slope is $z'(1)=f(z(1))$. Since you have an estimate of $z(1)$, you can estimate this slope. Taking a step of size $\Delta t$ along this linear approximation with constant slope, the Forward Euler estimate of $z(2)$ is $z(1+\Delta t) = z(1) + f(z(1))\Delta t.$ Estimate $z(2)$ using the Forward Euler algorithm.

      $z(2)=z(1+\Delta t) \approx z(1) + f(z(1))\Delta t$
      $=$
      $+ f($
      $) \cdot $

      $=$
      $+ $
      $ \cdot $

      $=$

    8. The general formula for a Forward Euler step to estimate $z(t+\Delta t)$ from $z(t)$ is the linear approximation formula with constant slope $z'(t)=f(z(t))$. The formula is $$z(t + \Delta t) = z(t) + f(z(t))\Delta t.$$ In each step, we move alone the linear approximation from time $t$ to time $\Delta t$, i.e., taking a step of length $\Delta t$.

      In the previous calculations, you used a time step of $\Delta t=1$ to estimate $z(2)$ in two time steps. The Forward Euler algorithm is more accurate if you take smaller time steps (as we allow the slope to change more frequently). Obtain a more accurate estimate of $z(1)$ and $z(2)$ by taking four time steps of length $\Delta t = 1/2$. (You'll do twice as much work, using the above formula at $t=0, 1/2, 1,$ and $3/2$.)

      $z(1/2) = z(0+\Delta t) \approx z(0) + f(z(0)) \Delta t$
      $=$
      $+ f($
      $)$

      $=$
      $+ $


      $=$

      $z(1) = z(1/2+\Delta t) \approx z(1/2) + f(z(1/2)) \Delta t$
      $=$
      $+ f($
      $)$

      $=$
      $+ $


      $=$

      $z(3/2) = z(1+\Delta t) \approx z(1) + f(z(1)) \Delta t$
      $=$
      $+ f($
      $)$

      $=$
      $+ $


      $=$

      $z(2) = z(3/2+\Delta t) \approx z(3/2) + f(z(3/2)) \Delta t$
      $=$
      $+ f($
      $)$

      $=$
      $+ $


      $=$

    9. Graph your Forward Euler solutions. Make a plot of that shows both your approximations of $z(t)$ versus $t$. For the first case, with $\Delta t=1$, the graph should have three points on it (including the initial condition at $(t,z) = (0,-0.8)$). For the second case, with $\Delta=\frac{1}{2}$, the graph should have five points on it (including the initial condition at $(t,z) = (0,-0.8)$). Connect the points with line segments so that the graph is similar to the graph from part b (it will be similar to just the first part of the sketch from part b, since for Forward Euler, we only calculated a few time points). Unlike the sketch from part b, this graph does label the scale on the $t$ axis, since we calculate actual speeds (slopes) this time.
      Feedback from applet
      Curve 1 points:
      Curve 2 points:

      Online, if you like, you can compare your solution to the “actual solution” by checking the box. (The “actual solution” is really just a Forward Euler approximation where we calculated 100 points with a small $\Delta t=0.025$. You wouldn't want to do that by hand, but it's easy for the computer to do it.) If your Forward Euler approximations are correct, then, if you move the initial point (cyan diamond) next to any of the points you calculated, the slope of the actual solution at that point will match the slope of the following Forward Euler segment. But, unlike the real solution, the Forward Euler solution keeps blindly heading in the same direction without changing its slope for the entire time interval until its next point. That's why the Forward Euler approximation is better, the smaller you make the time step $\Delta t$.

  2. Our goal is to use Forward Euler to approximate the solution of the differential equation \begin{align*} \diff{u}{t} &= \left(- u + 1\right) e^{u}\\ u(0) &= 0.5. \end{align*}
    1. Calculate $u(0.8)$ and $u(1.6)$ using the Forward Euler algorithm with time step $\Delta t = 0.8$. Plot the solution (i.e., a graph of $u$ versus time with line segments between the three points).

      $u(0.8) \approx $

      $u(1.6) \approx $

      Feedback from applet
      values of solution:
    2. There should be something wrong with the plot you just drew. To find the problems, sketch the solution using a graphical approach. To do so, you'll need to calculate the equilibria, their stability, and determine how the speed of $u$ evolves with time.

      Equilibria:
      (Separate multiple answers by commas.)

      Stability of equilibria:
      (Enter stable for stable and unstable for unstable. Separate multiple answers by commas and enter in same order as equilibria.)

      Feedback from applet
      Final values of curves:
      Initial conditions of curves:
    3. Is it possible for a solution to a single autonomous differential equation (i.e., an equation like the dynamical system for $u$) to cross through an equilibrium? (Remember what a vector field sketch looks like.)
      Does your Forward Euler solution cross through an equilibrium?
      . If so, that is one problem.
    4. Is it possible for the solution to a single autonomous differential equation to turn around? (Remember what a vector field sketch looks like.)
      Does your Forward Euler solution turn around?
      If so, that is another problem.
    5. The problem with the Forward Euler solution is that we took too large of a time step. When $\Delta t = 0.8$, we keep going along the same slope for too long. We end up sailing past an equilibrium. Then, since we crossed the equilibrium, the next estimate of our direction is in the opposite direction, and it looks like the solution turns around. To avoid this problem, we must decrease the time step.

      Redo the Forward Euler approximation, but this time halve the time step to $\Delta t=0.4$. Now, take four steps of the Forward Euler algorithm.

      $u(0.4) \approx$

      $u(0.8) \approx$

      $u(1.2) \approx$

      $u(1.6) \approx$

      Plot your solution.

      Feedback from applet
      values of solution:

      This time, the solution shouldn't cross the solution or turn around. (Well, OK, maybe it did a tiny bit. We'd have to make the time step even a little smaller to eliminate this error. But, you are probably glad we didn't take 16 steps with $\Delta t=0.1$. If you are bored some day, you could try it. At least the problems are not obvious from the graph.)

      The important take-home message is that the Forward Euler algorithm could give you bogus results if you take time steps $\Delta t$ that are too big. You need to use common sense special mathematical know-how to check if Forward Euler (or any other computer program) is lying to you.