Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 39 ยท Getting Started

Direction Fields and Solution Curves

Learn to read and draw slope fields for first-order ODEs, follow solution curves through them, and spot equilibria and trends without solving, using NumPy and Matplotlib.

Most differential equations cannot be solved with a neat formula. Yet you can often learn almost everything important about their solutions by drawing a picture. For a first-order equation y' = f(t, y) the right side hands you the slope of the solution curve at every point (t, y) of the plane, before you know any solution at all. Draw a tiny line segment with that slope at a grid of points and you get a direction field (also called a slope field).

A solution is then any curve that is tangent to the little segments everywhere it goes. You follow the arrows like a leaf floating on a stream. This lesson shows how to read a direction field, how to build one in a few lines of Python, and how to use it to predict long-term behavior.

From the equation to a slope

Take y' = t - y. At the point (0, 0) the slope is 0 - 0 = 0, so the segment is flat. At (0, 2) the slope is -2: steeply downward. At (3, 1) the slope is 2: rising. Evaluating f(t, y) over a grid and drawing a short segment with that slope at each grid point is all a direction field is.

Two features are worth knowing in advance.

  • Isoclines. The set of points where f(t, y) = c for a constant c is an isocline: along it every segment has the same slope. For y' = t - y the isocline for slope 0 is the line y = t. Solution curves cross it with a horizontal tangent, so it marks where solutions have local maxima or minima.
  • Equilibrium solutions. If f(t, y0) = 0 for all t, the constant function y = y0 is a solution. On the field it shows up as a row of horizontal segments.
Python Build a direction field by hand

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The red dashed line is the zero-slope isocline. Above it the slopes point down, below it they point up, so solutions are squeezed toward a line that runs parallel to y = t. (That line is y = t - 1, which you can confirm is itself a solution: its slope is 1, and t - y = t - (t - 1) = 1.)

Following a solution curve

Pick a starting point, an initial condition such as y(0) = 2, and trace a path that always follows the local segment. If you draw this by hand you will make a smooth curve that bends gently as the slopes change. A computer does the same thing in tiny steps; that idea becomes Euler's method in the numerical methods chapter.

Two curves from the same direction field can never cross when the equation is nice, because at a crossing point the field has just one slope. This non-crossing rule is the geometric face of uniqueness, which we make precise in existence and uniqueness.

Python Trace solution curves through the field

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Read the picture without solving anything. The horizontal lines y = 0 and y = 1 are equilibria. Curves starting between them climb toward y = 1 and never reach it. Curves starting above 1 sink back down to 1. Curves starting below 0 plunge toward minus infinity (in finite time, so the traced curve leaves the picture). So y = 1 attracts nearby solutions and y = 0 repels them. We formalize this in autonomous equations and stability.

What a direction field cannot tell you

A direction field gives qualitative information: increasing or decreasing, bounded or not, where it levels off. It does not give exact values. Hand-drawn curves can also mislead you near places where f is undefined or very steep, for example on the line y = 0 for y' = 1/y, where slopes become infinite and solutions cannot be continued.

When you meet a new equation, sketch its direction field (or let a short script do it) before trying any formula. A thirty-second picture often tells you what kind of answer to expect, and lets you catch algebra mistakes later.

Reading a field: a checklist

  1. Find the isocline f = 0: solutions are flat there.
  2. Mark regions where f > 0 (solutions rise) and f < 0 (solutions fall).
  3. Look for horizontal rows of flat segments: equilibria.
  4. Decide whether nearby curves converge toward or diverge from each equilibrium.
  5. Check for lines where the field is undefined.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the segment at point (t, y) of a direction field show?

    A direction field draws the slope given by the right side of y' = f(t, y) at each grid point.
  2. 2. For y' = t - y, what is the slope at the point (3, 1)?

    f(3, 1) = 3 - 1 = 2, so the segment rises with slope 2.
  3. 3. On a direction field, an equilibrium solution appears as

    A constant solution y = y0 has slope 0 for all t, so f(t, y0) = 0 and the segments along that height are horizontal.
  4. 4. Two solution curves of y' = f(t, y) with a nice f

    At a crossing point both curves would need the same slope, so they would have to coincide there and everywhere after.

Summary

  • A direction field draws the slope f(t, y) of every solution passing through each grid point.
  • Solutions follow the segments; they do not cross when f is well-behaved.
  • Isoclines (f = c) group equal slopes; f = 0 marks flat tangents and equilibria.
  • Direction fields give qualitative behavior (trend, equilibria, stability) without any formula.
  • Following the arrows in tiny steps is the idea behind Euler's method.

Next: Initial Value Problems, Existence and Uniqueness