Skip to content
ihateDesmos

How to draw a slope field, by hand and online

· 9 min read · ihateDesmos

A slope field turns a differential equation into a picture: tiny line segments showing which way every solution is heading. Drawing one by hand takes ten minutes and teaches you more about the equation than solving it.

What a slope field is

A first-order differential equation dy/dx = f(x, y) tells you the slope of a solution curve at every point, without telling you the curve itself. A slope field (or direction field) draws that information: at each point of a grid, a short segment with the slope f(x, y).

Solutions are the curves that follow the segments everywhere, like leaves floating on a stream. Different starting points give different solutions, and the slope field shows all of them at once.

Drawing one by hand

Take dy/dx = x − y. First, compute the slope at each point of a small grid. The table shows f(x, y) = x − y for x and y from −2 to 2:

y \ x-2-1012
2-4-3-2-10
1-3-2-101
0-2-1012
-1-10123
-201234

Then draw the segments:

  1. At each grid point, draw a short segment centred on the point with the slope from the table. A slope of 0 is flat, 1 is at 45° upward, −1 at 45° downward, and large slopes are nearly vertical.
  2. Start with the zeros. Here f = 0 wherever y = x, so every point on the diagonal gets a flat segment. That line is called an isocline: a curve along which the slope is constant.
  3. Use other isoclines to speed up. Along y = x − 1 the slope is always 1; along y = x + 1 it is always −1.
  4. Keep the segments short and the same length, so the picture shows direction, not magnitude.
−22−220
Open in calculator
The slope field of dy/dx = x − y. The segments are flat along the line y = x.

Sketching solution curves

To sketch the solution through a point, start there and follow the segments, keeping the curve tangent to them, in both directions. The curves should never cross each other (for well-behaved equations, solutions are unique) and should pass smoothly between segments.

For dy/dx = x − y, every solution bends toward the line y = x − 1. That line is itself a solution: its slope is 1, and on it x − y = 1. The general solution is y = x − 1 + Ce⁻ˣ, so every other solution approaches the line as x grows.

−22−220
Open in calculator
Five solutions of dy/dx = x − y, all approaching the straight-line solution y = x − 1 (dashed).

Equilibrium solutions

When f depends only on y, horizontal lines where f(y) = 0 are constant solutions, called equilibria. For the logistic equation dy/dx = y(1 − y), y = 0 and y = 1 are equilibria. Solutions near y = 1 move toward it (a stable equilibrium) while solutions near y = 0 move away (unstable). The slope field shows this at a glance: segments point toward stable equilibria and away from unstable ones.

−4−224−1120
Open in calculator
The logistic equation: solutions leave y = 0 and settle on y = 1.

Matching an equation to a slope field

A classic exam question shows a slope field and four equations. Work through these checks:

  1. Columns: if every segment in each vertical column has the same slope, f depends only on x (for example dy/dx = x² or dy/dx = cos x).
  2. Rows: if every segment in each horizontal row has the same slope, f depends only on y (for example dy/dx = y − 1).
  3. Zeros: find where the segments are flat. Those points satisfy f(x, y) = 0. Flat along y = x? Try x − y. Flat along both axes? Try xy.
  4. Signs: pick one point, say (1, 2), and check whether the segment there rises or falls. Eliminate equations that give the wrong sign.

From slope fields to Euler’s method

Following the segments step by step is a numerical method. Euler’s method does exactly that: from (x, y), move a small step h along the current slope to (x + h, y + h·f(x, y)), recompute the slope and repeat. It is simple and intuitive but not very accurate, because the slope changes during each step. Practical solvers like the Runge–Kutta methods sample the slope several times within each step and combine them. The calculator uses the Dormand–Prince method, which also estimates its own error and adjusts the step size to keep it small.

Drawing slope fields online

In the calculator, type dy/dx = x - y and the slope field appears. Click anywhere to add a solution through that point, and drag the starting dots to see how the solutions change. For systems, write both equations on one line, dx/dt = y, dy/dt = -x, to get a phase portrait. The slope field generator page has more examples.

Read next

See it for yourself

Every figure in this post opens in the calculator, where you can change it and watch what happens.

Open the calculator