Slope fields: reading an ODE before solving it
The question
y′ = y(2 − y)/2 sets the slope of y at every height. From y(0) = 0.25, can you sketch y(t) for 0 ≤ t ≤ 4 without solving it?
Sketch first; then the page draws the solution over your sketch.
- 1 SeeSketch three solutions from their slope fields.
- 2 TryPredict, then move the starting value.
- 3 ProveBuild the proof, line by line.
- 4 ApplyProblems to check yourself.
Before you start · 3 quick checks on tangent slopes, the chain rule and increasing functions, about 3 min
Two ideas before you start
2 ideasEach segment is the slope the equation asks for
Figure: the slope field of y′ = t − y, short segments on a grid, with the segment at the chosen point drawn long. It needs JavaScript.
At (0, 2): y′ = t − y = 0 − 2 = −2
At each point (t, y) the equation gives a slope y′. The slope field draws that slope as a short segment at many points of the plane.
Exact definition
Differential equation. A first-order ordinary differential equation (ODE) for an unknown function \(y\) of \(t\) has the form \(y' = f(t, y)\), where \(f\) is a given function of two variables and \(y'\) is the derivative \(\tfrac{dy}{dt}\).
Solution. A solution on an open interval \(I\) is a differentiable function \(y\) on \(I\) with \(y'(t) = f(t, y(t))\) for every \(t\) in \(I\). An initial value problem adds a starting condition \(y(t_0) = y_0\) with \(t_0\) in \(I\).
Slope field. The slope field (or direction field) of \(y' = f(t, y)\) draws, at each point \((t, y)\) of a grid, a short segment through that point with slope \(f(t, y)\), measured in the units of the two axes.
A solution runs along the segments
Figure: the slope field of y′ = y with two curves from the point (0, 0.5): curve A, 0.5eᵗ, and curve B, the straight line 0.5 + 0.5t. It needs JavaScript.
Both curves start at (0, 0.5). Tap the one that is a solution of y′ = y.
A solution curve is tangent to the segment at every point it passes through. Matching the slope at the start only is not enough.
Exact definition
Solution curves. If \(y\) is a solution of \(y' = f(t, y)\) on \(I\), then at each point \((t, y(t))\) of its graph the tangent line has slope \(y'(t) = f(t, y(t))\), the slope of the field at that point. Conversely, a differentiable function whose graph has, at each of its points, the slope of the field there is a solution.
Fine print: names and notation
“Ordinary” means there is one independent variable, here \(t\); equations with partial derivatives in several variables are partial differential equations. The equation is first order because only \(y'\) appears, not \(y''\). An equation \(y' = f(y)\) whose right side does not involve \(t\) is called autonomous. Every segment of a slope field has its slope measured in the units of the axes, so on a figure whose two axes have different scales, a segment of slope 1 need not be drawn at 45°.
Sketch the solution from the slope field
- Each round shows a slope field and a starting point \((0, y(0))\), the small square.
- Drag the 8 handles up or down (or focus one and use the arrow keys) so that your sketch follows the segments.
- Press Check my sketch: the page draws the solution over yours and shades where the two are more than 0.2 apart.
How the page draws the solution and measures the gap
The page solves each equation numerically with the classical fourth-order Runge–Kutta method, step 0.001, and fills in between steps with cubic Hermite interpolation; the error is far smaller than the width of a line. Your sketch is the broken line from the start through your 8 handles, which move in steps of 0.05. The gap is the vertical distance between your sketch and the solution, measured at 4,001 equally spaced times from 0 to 4. Where it is more than 0.2 the strip is shaded, and the ends of each strip are the times where the gap equals 0.2, found by bisection. After the third round a table compares the three sketches; Start over clears everything.
| Round | Equation | Your sketch | Largest gap |
|---|
Change the starting value
Back to \(y' = y(2 - y)/2\) from the question at the top. Two predictions first; the explorer below them opens once both are answered.
The explorer, its goals and the summary open after you answer both predictions.
Explorer: one equation, many starts
Goals
Equilibria. The constant functions 0 and 2 are solutions, because \(y(2 - y)/2 = 0\) at those heights. In the slope field they are the rows of flat segments.
The phase line. Write \(f(y) = y(2 - y)/2\). The right side does not involve \(t\), so the sign of \(f(y)\) alone says which way a solution moves at height \(y\): up where \(0 \lt y \lt 2\), down where \(y \lt 0\) or \(y \gt 2\). The phase line at the right of the figure records these directions with arrowheads.
Stable and unstable. Solutions that start near 2, on either side, move toward it: 2 is a stable equilibrium. Solutions that start near 0, on either side, move away from it: 0 is unstable. Every start above 0 leads toward 2.
No crossing. Here \(f\) and its derivative \(f'(y) = 1 - y\) are continuous. For such equations, two solutions that are equal at one time are equal at every time where both are defined (the existence and uniqueness theorem, proved in a later lesson). So a solution that starts between 0 and 2 stays strictly between them: it approaches 2 without reaching it.
Shifts in time. Because the right side does not involve \(t\), if \(y(t)\) is a solution then so is \(y(t - c)\) for every number \(c\), by the chain rule. Each solution curve shifted sideways is another solution curve.
The formula. For \(y(0) = y_0 \ne 0\) the solution is
\[\begin{aligned} y(t) &= \dfrac{2}{1 + Ce^{-t}}, \\ C &= \dfrac{2 - y_0}{y_0}, \end{aligned}\]which you can check by differentiating. It holds on the interval of times containing 0 on which the denominator \(1 + Ce^{-t}\) is not 0. For \(0 \lt y_0 \le 2\), \(C \ge 0\) and that is every \(t\). For \(y_0 \gt 2\), \(-1 \lt C \lt 0\) and it is \(t \gt \ln(-C)\), which includes every \(t \ge 0\). For \(y_0 \lt 0\), \(C \lt -1\) and it is \(t \lt \ln(-C)\): this solution tends to \(-\infty\) as \(t\) approaches \(\ln(-C)\).
How far apart two solutions stay
Assumptions. \(I\) is an open interval that contains 0, and \(y_1\) and \(y_2\) are solutions of \(y' = t - y\) on \(I\) with \(y_1(0) \ne y_2(0)\). Write \(d(t) = y_1(t) - y_2(t)\) for the gap between them, so \(d(0) \ne 0\).
Conclusion. For every \(t\) in \(I\),
\[\begin{aligned} d(t) &= d(0)e^{-t}. \end{aligned}\]So \(d(t) \ne 0\) for every \(t\) in \(I\): the two solution curves never meet. And whenever \(t\) and \(t + 1\) are both in \(I\), \(|d(t + 1)| = e^{-1}|d(t)|\), with \(e^{-1} \approx 0.368\): the gap shrinks by that factor per unit of \(t\).
Facts the proof uses.
- the product rule, \((uv)' = u'v + uv'\);
- a function whose derivative is 0 at every point of an open interval is constant on it (a consequence of the mean value theorem);
- \(\tfrac{d}{dt}e^{t} = e^{t}\), \(e^{s} \gt 0\) and \(e^{a}e^{b} = e^{a + b}\) for all real numbers \(s\), \(a\), \(b\).
Each option is one step about the \(y_1\), \(y_2\), \(d\) and \(I\) of the theorem. Pick the one that is true for every pair of solutions the theorem covers.
- Every solution of \(y' = t - y\). The function \(t - 1\) is a solution, since its slope 1 equals \(t - (t - 1)\), and it starts at \(-1\). Taking it as \(y_2\), every solution with \(y(0) \ne -1\) is \(y(t) = t - 1 + (y(0) + 1)e^{-t}\). Lines 1 to 3 of the proof never use \(d(0) \ne 0\); with \(d(0) = 0\) they give \(d(t) = 0\) for every \(t\). So two solutions that start at the same value are the same function: the starting value fixes the solution.
- Other linear equations. For a number \(k\) and a continuous function \(g\), the same steps with the factor \(e^{kt}\) show that two solutions of \(y' = g(t) - ky\) on an interval containing 0 differ by \(d(0)e^{-kt}\). For \(k \gt 0\) the gap shrinks, as for \(y' = t - y\). For \(k \lt 0\) it grows: \(y' = y - t\) from round 3 of stage 1 has \(g(t) = -t\) and \(k = -1\), so its solutions spread apart like \(e^{t}\).
- Equations that are not linear. For \(y' = f(t, y)\) with \(f\) and \(\tfrac{\partial f}{\partial y}\) continuous, two solutions that are equal at one time are equal wherever both are defined (the existence and uniqueness theorem), so solution curves still never cross. The gap between two of them no longer has to change at one fixed exponential rate; \(y' = y(2 - y)/2\) from stage 2 is an example.
Problems
Each problem has hints and a full solution.
Related: What happens to (1 + 1/n)n as n grows? shows why \(e^{t}\) is its own derivative, which makes \(0.5e^{t}\) a solution of \(y' = y\); What degree does a Taylor polynomial need? builds on the tangent line, which is curve B on the second key-idea card.
Further reading
- W. E. Boyce, R. C. DiPrima and D. B. Meade, Elementary Differential Equations and Boundary Value Problems, 11th ed. (Wiley, 2017), section 1.1 on direction fields and section 2.5 on autonomous equations.
- S. H. Strogatz, Nonlinear Dynamics and Chaos, 2nd ed. (Westview Press, 2015), chapter 2, “Flows on the Line.”
- M. W. Hirsch, S. Smale and R. L. Devaney, Differential Equations, Dynamical Systems, and an Introduction to Chaos, 3rd ed. (Academic Press, 2013), chapter 1, “First-Order Equations.”