Slope Fields

Visualize and approximate differential equations without solving them exactly.

Some differential equations are difficult to solve exactly. A slope field helps you understand the behavior of solutions anyway. It shows the slope predicted by the equation at many points.

Learning objectives

After this lesson you should be able to:

  • interpret each segment in a slope field;
  • sketch an approximate solution through an initial point;
  • identify equilibrium solutions in autonomous equations;
  • compute basic Euler-method steps;
  • explain why smaller step sizes usually improve approximations;
  • compare exact and numerical answers.

What a slope field shows

For an equation

dy/dx = f(x,y)

choose a point (x,y), compute f(x,y), and draw a short segment with that slope. Repeat this at many points. The result is a slope field.

A solution curve should follow the local directions in the slope field, like a leaf floating along a stream.

Reading a slope field

  • Horizontal segments mean dy/dx = 0.
  • Positive slopes mean the solution is increasing as x increases.
  • Negative slopes mean the solution is decreasing.
  • Steeper segments mean faster change.
  • In many well-behaved first-order ODEs, solution curves do not cross.

Equilibrium solutions

For an autonomous equation

dy/dt = f(y)

an equilibrium occurs where f(y)=0. If a solution starts at that value, its rate of change is zero, so it stays there.

Example:

dy/dt = y(1-y)

Equilibria occur when

y(1-y)=0

so y=0 and y=1.

Euler’s method

Euler’s method is a simple numerical method. It says: use the current slope for one small step.

x_{n+1} = x_n + h
y_{n+1} = y_n + h f(x_n, y_n)

Here h is the step size.

Worked example: one Euler step

Approximate the solution to

y' = y,     y(0)=2

using one step of size h=0.5.

At the starting point, the slope is

f(0,2)=2

Update x:

x_1 = 0 + 0.5 = 0.5

Update y:

y_1 = 2 + 0.5(2) = 3

So the next Euler point is (0.5, 3).

Worked example: long-term behavior

For

dy/dt = y(1-y)
  • if 0 < y < 1, then y(1-y)>0, so y increases;
  • if y > 1, then 1-y<0, so y decreases;
  • if y < 0, then y<0 and 1-y>0, so y decreases.

The equilibrium y=1 attracts nearby positive solutions. We call it stable. The equilibrium y=0 pushes nearby solutions away. We call it unstable.

Common pitfalls

  • Thinking each small segment is a whole solution curve.
  • Forgetting that Euler’s method updates both x and y.
  • Using the new slope too early in basic Euler’s method.
  • Believing smaller step size makes the method exact.
  • Confusing an equilibrium value with an intercept on a graph.

Practice

  1. What does a horizontal segment in a slope field mean?

  2. Use one Euler step for y'=2y, y(0)=1, h=0.25.

  3. Find the equilibria of dy/dt = y(4-y).

  4. For dy/dt = y(4-y), is the solution increasing or decreasing when y=5?

  1. The derivative is zero at that point.
  2. Slope is 2; x_1=0.25; y_1=1+0.25(2)=1.5.
  3. y=0 and y=4.
  4. It is decreasing because 5(4-5)=-5 is negative.

Subtopic guided practice and checkpoints

A slope field is a visual calculator for an ODE. It does not give a formula by itself; it shows local directions that solution curves should follow.

Lab 1: read local slopes

Guess first. For y' = x - y, what is the slope at (2, 1)?

Guided exercise.

Substitute the coordinates into the right-hand side:

f(x,y) = x - y
f(2,1) = 2 - 1 = 1

At (2,1), the slope-field segment should tilt upward with slope 1.

Checkpoint. For y' = y(2-y), compute the slope at y=0, y=1, and y=3. Which segments are horizontal?

Lab 2: identify equilibria and stability clues

Guess first. For y' = y(2-y), which values of y make the derivative zero?

Guided exercise.

y(2-y) = 0
y = 0 or y = 2

Test intervals:

0 < y < 2      -> y' > 0, solutions move upward
y > 2          -> y' < 0, solutions move downward
y < 0          -> y' < 0, solutions move downward

So y=2 attracts nearby positive solutions, while y=0 repels nearby positive solutions.

Checkpoint. Find the equilibria of y' = (y - 1)(3 - y). Test the sign of y' on each interval.

Lab 3: take one Euler step

Guess first. Euler’s method uses the old slope or the new slope?

Guided exercise. Use one step for y' = x + y, y(0)=1, h=0.2.

x0 = 0, y0 = 1
slope = f(0,1) = 0 + 1 = 1
x1 = 0 + 0.2 = 0.2
y1 = 1 + 0.2(1) = 1.2

Euler uses the slope at the current point, then moves.

Checkpoint. Use one Euler step for y' = 2 - y, y(0)=0, h=0.5.

Lab 4: compare numerical and qualitative information

Guess first. If an Euler approximation increases, does that prove the exact solution always increases?

Guided exercise.

Euler steps give sampled evidence. A slope-field or sign analysis gives broader behavior. For autonomous equations, the sign of f(y) on intervals tells you where solutions increase or decrease between equilibria.

Checkpoint. For y' = y(1-y), explain why a solution starting at y(0)=0.5 should increase toward 1 without solving the equation exactly.

Slope-field checkpoint

Using this lesson with edumath and SymPy

Use edumath for Euler approximations.

from edumath.differential_equations import euler_method

euler_method(lambda x, y: y, initial_x=0, initial_y=2, step=0.5, steps=3)
[(0, 2), (0.5, 3.0), (1.0, 4.5), (1.5, 6.75)]

Use SymPy for an exact comparison when an exact solution exists.

import sympy as sp

x = sp.Symbol("x")
y = sp.Function("y")
sp.dsolve(sp.Eq(sp.diff(y(x), x), y(x)))

\(\displaystyle y{\left(x \right)} = C_{1} e^{x}\)

The exact solution of y'=y is exponential. Euler’s method approximates that curve with small straight-line steps.