First-Order Ordinary Differential Equations

Exercise 1

Suppose you’re working for a government agency and your work involves numerically solving differential equations. The regulations require your measurements to be accurate to within \(0.0001\). You’re using an algorithm with fourth-order global error, and after running a simulation using three steps, you’ve estimated that the error does not exceed \(13000\). (It’s three pretty big steps.) How many times must you halve the step size before you’re within the required tolerance?

Exercise 2

You’ve used a numerical method with second-order global error to estimate the value of a solution of a differential equation, and using \(4\) time steps you’ve got an error not exceeding \(0.25\). How many times must you halve the step size to be sure the error is less than \(0.0001\)? How does the answer change if the method were fifth-order instead?

Exercise 3

Suppose \(y(t)\) is the solution of the differential equation \(y' + y = t^2 + 1\) satisfying the initial condition \(y(1) = 2\). Estimate \(y(2)\) using Euler’s method with a step size of \(0.5\).

Exercise 4

Suppose \(y(t)\) solves the initial value problem \[\dot{y} + \frac{1}{1+t} \, y = t^2 \,, \qquad y(0) = 1 \,.\] Estimate \(y(1)\) using Euler’s method and four steps. [You can work to four decimal places of precision if you’d prefer to avoid fractions.] If you can, write a computer program that allows you to run Euler’s method on this question with \(100\) steps.

Exercise 5

Suppose \(y(t)\) solves the differential equation \(y' + y = 2t\) with initial condition \(y(2) = 0\).

  1. Use the implicit Euler method with two steps to estimate \(y(3)\).

  2. Solve the equation and determine the actual value of \(y(3)\) for the solution with a zero at \(t=2\).

  3. What if we repeat part (a) with four steps? Does the estimate get any closer to the truth?

Exercise 6

Let \(y(t)\) be a solution to \(y' + \frac{1}{2}\,ty^2 = 2\) with \(y(2) = 1\). Use implicit Euler with a step size \(h=1\) to estimate an approximate value of \(y(5)\). [Let’s focus on the solution that will come up if we take positive square roots at every juncture possible.]

Exercise 7

Let \(y(t)\) be the solution to the initial-value problem \(y' = \sqrt{y}\), \(y(0) = 3\). Using four steps, estimate \(y(1)\) with the implicit Euler method. [Take positive square roots should the need arise, and use four decimals of precision.] [Hint. Though it doesn’t look like it at first, \(y + \alpha\sqrt{y}\) is the sort of thing that’s amenable to completing the square, where \(\alpha\) is some constant.]

Exercise 8

Consider the solution to the differential equation \(\dot{y} = -100y\) with \(y(0) = 1\).

  1. Use explicit (forward, usual) Euler’s method with a step size of \(0.2\) to estimate the value of \(y(1)\).

  2. Repeat part (a) with the same step size but use implicit (backwards) Euler instead.

  3. What function are we approximating here, and which method got closer to the correct value?

  4. Does increasing the number of steps help with any shortcomings you saw with either of the methods? Why or why not?

Exercise 9

Use the Runge-midpoint method to estimate \(y(0.2)\) if \(y(t)\) is the solution to \(y' = \sqrt{y + t^2 + 1}\) with \(y(0) = 0\). Use a step size of \(h = 0.1\).

Exercise 10

Use the Runge-trapezoid method to calculate \(y(1.4)\) if \(y(t)\) is the solution to the differential equation \(y'=\frac{1 + y^2}{1 + t^2}\) with \(y(1) = 2\). Use a step size of \(h = 0.2\).

Exercise 11

Use the Runge-Kutta method with to calculate \(y(1.5)\) if \(y(t)\) is the solution to \(y'+y=\frac{1}{t}\) satisfying \(y(1) = 1\). Use a step size of \(h = 0.5\) (so just one step).

Exercise 12

Use the second-order Taylor method to estimate \(y(2)\) if \(y(t)\) is the solution to \(\dot{y}=t+\frac{1}{y}\) with \(y(1) = 2\). Use a step size of \(h = 0.5\).

Exercise 13

The direction field for the equation \[\frac{\dy}{\dt} = 5 y (1-y) - \left( 1 + \frac{\sin(2\pi t)}{2} \right)\] may appear chaotic at first glance. We’ll try to make sense of it in this exercise.

  1. Plot this direction field for \(0 < t < 6\), \(0 < y < 1\). Can you tell what is the long-term behavior of solutions from the picture?

  2. Use ode45 to generate solutions to the equation with initial conditions \(y(0) \in \{ 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 \}\), again on the range \(0 < t < 6\). Plot them all on the same graph, and speculate as to what’s going on.

  3. Overlay the figures from part (a) and part (b) to see how the solutions followed the direction field.

Exercise 14

The goal of this problem is to use numerical methods to confirm our theorems regarding autonomous differential equations. We’ll look at the equation \[y' = - y^4 + 4 y^3 - y^2 - 6y = - y (y+1) (y-2) (y-3) \,.\]

  1. Draw a phase line and indicate the kind of stationary solutions this equation has.

  2. Where should a solution with \(y(0) = 1.2\) go as \(t\to\infty\)? Using a computer, perform Euler’s method with \(100\) steps to estimate \(y(10)\) to try to confirm this. Use ode45 to plot a solution.

  3. Repeat the previous part using \(y(0) = 2.1\).

Exercise 15

In this problem we’ll try to “see” that the Runge-Kutta method has an error term of fourth order only by looking at its estimates for a specific problem. To do this we’ll have to know what the error actually is, so we’ll pick a straightforward differential equation whose solution we can get our hands on: \[y' - 2 y = e^t \,, \qquad y(0) = 2 \,.\]

  1. Find the solution to this initial value problem; call it \(y(t)\). Calculate \(y(1)\).

  2. Using a computer programmed to perform the Runge-Kutta method, estimate \(y(1)\) by using \(1\), \(2\), \(10\), \(20\), \(32\), \(50\), \(64\), and \(100\) steps. Make a table with the number of steps, the estimated value that Runge-Kutta gives, and the error (the absolute value of the difference between the answer to part (a) and the estimate). You’ll need at least eight to ten digits of precision.

  3. For \(h = 1\), \(10\), \(32\), and \(50\), calculate \[\log\!\left( \frac{\text{error using $h$ steps}} {\text{error for $2h$ steps}} \right) \cdot \frac{1}{\log(2)} \,.\] What is this number telling us, and why do we expect it to be about \(4\) if it’s the algorithm is fourth order? [Note. The fact that we get numbers near \(4\) for this problem is not enough evidence to conclude that the method is fourth order; in fact it’s possible for these numbers to be smaller for specific problems. But generally speaking they will be around four.]

Exercise 16

As humans we sometimes take for granted that time can only move forwards, but when we’re working with differential equations time can move both ways. We’ll explore this in this problem, where we put the “backwards” in “backwards Euler method”.

  1. Consider the differential equation \[t y' - y = t^4 - 3 \,,\] with “terminal condition” \(y(1) = 0\). Use the implicit Euler method \[y_n = y_{n+1} - hf(t_{n+1}, y_{n+1})\] with step size \(h = \frac{1}{2}\) to estimate \(y(0)\).

  2. Solve the initial value problem and determine what value of \(y(0)\) would lead to a solution which has a root at \(t=1\). [Do you even need the specific solution to determine \(y(0)\)? Is something weird going on here?]

  3. Check that upping the number of steps from two to four improves the accuracy of the approximation.

Exercise 17

Let \(y(t)\) be the solution to the differential equation \(y' - 3y = t^2\) with \(y(1) = 1\). Use the explicit Euler method with a step size of \(\frac{1}{2}\) to estimate \(y(0)\). Was this easier or harder than the previous problem?

Exercise 18

You’ve estimated the error of a fourth order method on an interval \([0,10]\) with \(20\) time steps. If you increase to \(60\) time steps, by what factor will the error go down?

Exercise 19

You’ve estimated the error of a Forward Euler method on an interval \([0,10]\) with \(20\) time steps. If you increase to \(100\) time steps, by what factor will the error go down?

Exercise 20

Suppose \(x(t)\) solves the differential equation \(x'=-2tx^2\) with initial condition x(1) = 1. Solve the above IVP for x(2) using:
a) Euler method with step size \(0.5\)
b) Analytically.

Exercise 21

Use the explicit Euler method to plot the estimate \(y(2)\) if \(y(t)\) is the solution to \(y'=t-y^3\) with \(y(0)=1\). Use \(10\) steps, \(20\) steps, and \(30\) steps and plot all three.

Exercise 22

Use the Explicit Euler and Runge-Kutta methods to estimate \(y(2)\) if \(y(t)\) is a solution to \(y'=\frac{1}{t^2+y}\) with \(y(0)=1\) and \(10\) time steps.