Direction Fields and Slope Fields

April 13, 2026

Problem

Plot the slope field of dy/dx = x - y, then overlay several solution curves that follow the field. Show how curves trace the flow.

Explanation

What a slope field shows

A slope field (sometimes called a direction field) is a graphical answer to the question: "What does dy/dxdy/dx look like at every point of the plane?"

Given a first-order ODE dydx=f(x,y),\frac{dy}{dx} = f(x, y), the value f(x,y)f(x, y) is the slope of the solution passing through the point (x,y)(x, y). A slope field samples ff at a grid of points and draws a short line segment there with that slope. When you step back, the segments visually flow into curves — and every solution of the ODE is tangent to those segments.

The key insight: you can read off qualitative behaviour (stability, equilibria, blow-up, oscillation) from the slope field without solving the ODE. For many real-world ODEs, no closed-form solution exists — the slope field is how you reason about them.

The given equation

dydx=xy\frac{dy}{dx} = x - y

This is a first-order linear ODE (for the closed-form solution see #174). Let's read the slope field.

Step 1 — Evaluate slopes on a grid

Compute f(x,y)=xyf(x, y) = x - y at several points:

  • At (0,0)(0, 0): slope =0= 0. Segment is horizontal.
  • At (1,0)(1, 0): slope =1= 1. Segment slopes up at 45°.
  • At (0,1)(0, 1): slope =1= -1. Segment slopes down at 45°.
  • At (2,0)(2, 0): slope =2= 2. Steeper up-slope.
  • At (2,2)(2, 2): slope =0= 0. Horizontal.

Do this at every point of a visible grid and you have the slope field.

Step 2 — Identify isoclines (lines of equal slope)

Set f(x,y)=kf(x, y) = k (constant): xy=k    y=xk.x - y = k \quad\implies\quad y = x - k.

So every isocline of y=xyy' = x - y is a line of slope 11 (in the xyxy-plane), parametrised by the constant-slope value kk.

Useful isoclines:

  • k=0k = 0 (horizontal-tangent isocline): y=xy = x. Every point on this line has y=0y' = 0.
  • k=1k = 1: y=x1y = x - 1. Slope 11 here.
  • k=1k = -1: y=x+1y = x + 1. Slope 1-1 here.

The slope field shows these lines' segments sweeping through: horizontal along y=xy = x, steeper up above it, steeper down below it.

Step 3 — Trace solution curves

A solution is a curve whose tangent, at every point it passes through, matches the local segment. Start at a point (x0,y0)(x_0, y_0) and "flow" forward and backward along the segments.

For y=xyy' = x - y the closed-form solution is y=x1+Cexy = x - 1 + C e^{-x} (check with #174's recipe). Let's sanity-check against the slope field:

  • As xx \to \infty, Cex0C e^{-x} \to 0 so yx1y \to x - 1. Every solution is asymptotic to the line y=x1y = x - 1.
  • The line y=x1y = x - 1 itself (C=0C = 0) is a solution — plug in: y=1y' = 1 and xy=x(x1)=1x - y = x - (x - 1) = 1. ✓

So the slope field shows a river of parallel curves all funneling toward the attracting line y=x1y = x - 1.

Reading qualitative behaviour from a slope field

Without solving anything, you can often spot:

  • Equilibria (constant solutions): horizontal isoclines where the ODE reduces to y=0y' = 0. For autonomous y=g(y)y' = g(y), these are the roots of gg.
  • Stability: look at whether nearby segments point toward or away from the equilibrium.
  • Asymptotic behaviour: whether solutions grow unbounded, approach an attractor, or oscillate.
  • Blow-up in finite time: very steep segments clustered in a region     \implies trajectories may diverge.

Why every solution stays tangent to the field

This is the definition of a solution, not a property to prove — if y(x)y(x) satisfies y=f(x,y)y' = f(x, y), then at each xx the slope y(x)y'(x) exactly equals the value f(x,y(x))f(x, y(x)) that the slope field draws there. A solution curve is a path that follows the arrows.

Uniqueness (Picard–Lindelöf) ensures solutions don't cross when ff is smooth: each point has exactly one solution curve passing through it.

Numerical methods live here

Euler's method is literally: "stand at (xn,yn)(x_n, y_n), read the slope-field segment, take a short step along it, repeat." More refined methods (RK4, adaptive stepping) are smarter ways to follow the same field.

Common mistakes

  • Confusing isocline with solution curve. An isocline is where slopes have the same value; a solution curve follows the slopes. The two are generally not the same (and are not tangent to each other except by coincidence).
  • Drawing segments that "cross" at a point — for an ODE at a generic point there's one slope, so one segment. Crossings only happen at singular points where ff is undefined.
  • Forgetting equilibria. Horizontal segments along a line / curve of yy-values mean that line / curve is a constant solution.
  • Treating the field as static. For autonomous ODEs (ff depends on yy only) the field is horizontally striped — slopes don't change with xx. For non-autonomous ODEs the field shifts as xx changes, and solution curves need not be translates of each other.

Try it in the visualization

Drag the initial condition around and watch the solution curve snap to follow the slope field. Toggle isoclines on/off to see the y=x1y = x - 1 attractor. Increase the grid density to see the field resolve into a smooth-looking flow.

Interactive Visualization

Parameters

2.00
0.00
4.00
5.00
16.00
0.00
4.00
Your turn

Got your own math or physics problem?

Turn any problem into an interactive visualization like this one — powered by AI, generated in seconds. Free to try, no credit card required.

Sign Up Free to Try It30 free visualizations every day
Direction Fields and Slope Fields | MathSpin