AP Calculus AB and BC

Slope Field Generator: Free, Download as PNG or SVG

A slope field draws a short segment at each grid point with the slope that dy/dx gives there, so one picture shows the shape of every solution. Type an equation, click to trace the solution through any point, and download the result as a PNG or SVG.

Latest curve passes through (0, 1), where the slope is 1.

Window

Type the right-hand side of a differential equation dydx=f(x,y)\frac{dy}{dx} = f(x, y) and the tool draws its slope field: a grid of short segments, each one tilted at the slope the equation gives at that point. Click or tap anywhere on the field to draw the solution curve through that point. You can add up to 12 curves, switch on Euler's method to see the stepwise approximation with its table of values, then download the picture as a PNG or SVG, or copy a link that reopens the same equation, window, and curves.

What a slope field shows

A differential equation such as dydx=x+y\frac{dy}{dx} = x + y does not hand you a function. It hands you a rule for slope. Any solution that passes through (1,2)(1, 2) must have slope 1+2=31 + 2 = 3 there, and any solution through (−2,2)(-2, 2) must have slope −2+2=0-2 + 2 = 0. A slope field applies that rule at many points at once and draws each answer as a short segment, so every segment is a small piece of a tangent line to whichever solution passes through its center.

A solution curve is a curve that agrees with the field everywhere along its length: at each point it passes through, its tangent has the slope the equation assigns to that point. For every preset on this page, exactly one solution passes through each point where the slope is defined, so choosing an initial condition such as y(0)=1y(0) = 1 picks out one curve from the whole family. That one curve is a particular solution. The family of all of them is the general solution, and the field lets you see its shape before you do any integration (Topics 7.3 and 7.4 of the AP Calculus course).

How to read it

The blue segments are the slope field. Each dark red curve is a solution, and the dot on it is the initial point you chose. The Density slider sets how many segments run across the window, from 7 to 41, and the four Window boxes set the smallest and largest xx and yy on screen. To use an exact initial condition, type it into Initial x and Initial y and press Draw curve. Every initial point is listed under those boxes as a small button that removes its curve, and Clear curves removes them all.

  • Find the horizontal segments first. They mark where dydx=0\frac{dy}{dx} = 0. For dydx=x+y\frac{dy}{dx} = x + y they lie along the line y=−xy = -x.
  • Check what the slope depends on. If all the segments in a vertical column are parallel, the slope depends only on xx, as with x2x^2 or sin⁡(x)\sin(x). If all the segments in a horizontal row are parallel, the slope depends only on yy, as with yy or y(1−y)y(1 - y). If neither is true, both variables matter.
  • Read the sign by region. For dydx=x+y\frac{dy}{dx} = x + y the segments rise above the line y=−xy = -x, where x+y>0x + y > 0, and fall below it.

A slope of 11 looks like a 45 degree line only when one unit is the same length on both axes. The starting window, −5≤x≤5-5 \le x \le 5 and −4≤y≤4-4 \le y \le 4, is chosen so the two scales are nearly equal. If you stretch the window in one direction, the segments look steeper or flatter on screen even though the slope values have not changed, exactly as they would on stretched graph paper.

Some equations have no slope at certain points. Where the formula divides a nonzero number by zero, as dydx=xy\frac{dy}{dx} = \frac{x}{y} does along y=0y = 0, the tool draws a vertical segment. Where the formula has no value at all, such as 00\frac{0}{0} at the origin or the logarithm of a negative number, it leaves that grid point empty. A solution curve stops when it reaches a place like this, and for the latest curve the note under the graph gives the xx value where it stopped.

Three things to try

  1. Press the x+yx + y preset, press Clear curves, then type 00 and −1-1 into Initial x and Initial y and press Draw curve. The solution is a straight line, y=−x−1y = -x - 1. Check it: its slope is −1-1 everywhere, and on that line x+y=x+(−x−1)=−1x + y = x + (-x - 1) = -1. Now click a few points above and below the line. Every other solution is y=Cex−x−1y = Ce^{x} - x - 1 with C≠0C \ne 0, so to the left the curves crowd toward the line and to the right they peel away from it, upward above the line and downward below it. Notice that the line of horizontal segments, y=−xy = -x, is not itself a solution; the straight solution sits one unit below it.
  2. Press the −x/y-x/y preset and draw the curve through (0,3)(0, 3). You get the top half of a circle of radius 33, and the note under the graph says it stops near x=−3x = -3 and x=3x = 3. Separating variables explains the shape: y dy=−x dxy\,dy = -x\,dx integrates to x2+y2=Cx^2 + y^2 = C, and the point (0,3)(0, 3) gives C=9C = 9. The curve cannot continue past y=0y = 0 because the tangent is vertical there, and a solution y(x)y(x) has to be a function. Draw the curve through (0,−2)(0, -2) to get the bottom half of a smaller circle.
  3. Press the y(1−y)y(1 - y) preset, the logistic equation with carrying capacity 11. The rows at y=0y = 0 and y=1y = 1 are flat: those are the two equilibrium solutions. Draw the curve through (0,0.5)(0, 0.5) and you get the S-shaped logistic curve, steepest at y=0.5y = 0.5 where the slope is 0.5⋅0.5=0.250.5 \cdot 0.5 = 0.25. Draw the curve through (0,1.5)(0, 1.5) and it falls back toward y=1y = 1 as xx increases. Draw the curve through (0,−0.5)(0, -0.5) and it drops away from y=0y = 0. Solutions approach y=1y = 1 and leave y=0y = 0, which is what stable and unstable equilibrium mean.

What-if questions

  • What if you halve the Euler step? Use x+yx + y with (0,1)(0, 1) as the latest point, turn on Euler's method, and set h=0.5h = 0.5 with 22 steps. The table ends at y=2.5y = 2.5 when x=1x = 1, while the true solution y=2ex−x−1y = 2e^{x} - x - 1 has y(1)=2e−2≈3.437y(1) = 2e - 2 \approx 3.437. Change to h=0.25h = 0.25 with 44 steps and the last row reads about 2.8832.883. The error shrinks from about 0.940.94 to about 0.550.55. Both estimates are too low because the solution is concave up here, so each tangent step runs underneath the curve.
  • What if the slope depends only on xx? Try x2x^2 or sin⁡(x)\sin(x). Every column of segments is parallel, and every solution curve is the same shape shifted up or down, because the solutions are antiderivatives that differ by a constant: y=x33+Cy = \frac{x^3}{3} + C for the first one.
  • What if the starting point sits on an equilibrium? With y(1−y)y(1 - y), type the initial point (0,1)(0, 1). The curve is the horizontal line y=1y = 1. Then click just above and just below it to see nearby solutions close in on the line as xx increases.
  • What if you widen the window? Use x−yx - y, set xx from −10-10 to 1010 and yy from −10-10 to 1010, and click several points. Every curve bends toward the line y=x−1y = x - 1 as xx increases, because the general solution is y=x−1+Ce−xy = x - 1 + Ce^{-x} and the last term dies out. A wider window shows long-run behavior that a narrow one hides.

Where to go next

Put this on a class page

Copy the snippet. Paste it into Google Sites, Canvas, WordPress or anything that accepts HTML. The line under the frame is an optional credit you may keep, edit or remove.

Widget page with a live previewEvery widgetGoogle Sites steps

Common questions

How do you sketch a slope field by hand?

Use the grid of points the problem gives, usually the points with integer coordinates. At each one, substitute xx and yy into the differential equation to get a number, then draw a short segment with that slope through the point. For dydx=x+y\frac{dy}{dx} = x + y, the point (1,0)(1, 0) gets slope 11 and the point (0,−1)(0, -1) gets slope −1-1. Place the horizontal segments first, since the points where the slope is 00 are the quickest to find.

How do you match a slope field to its differential equation?

Test the features that are easiest to see. Find where the segments are horizontal and check which equation equals zero there. Look at whether the slopes change only from left to right (the equation contains only xx), only from bottom to top (only yy), or both ways. Then check the sign of the slope in one quadrant. Two or three of these checks usually rule out every wrong choice.

What is Euler's method?

Euler's method approximates a solution by following tangent lines in short steps. From a known point, find the slope from the differential equation, move hh units in xx, change yy by hh times that slope, and repeat from the new point. For dydx=x+y\frac{dy}{dx} = x + y starting at (0,1)(0, 1) with h=0.5h = 0.5, two steps give y=1.5y = 1.5 and then y=2.5y = 2.5 at x=1x = 1. It is Topic 7.5, a BC-only topic.

Why does a solution curve stop before the edge of the graph?

A solution is a function y(x)y(x), so it cannot continue through a point where its tangent would be vertical or the slope is undefined. For dydx=−xy\frac{dy}{dx} = -\frac{x}{y} the curve through (0,3)(0, 3) is the top half of the circle x2+y2=9x^2 + y^2 = 9, and it ends as it reaches y=0y = 0 at x=−3x = -3 and x=3x = 3. The tool also stops a curve that runs a full window height above or below the picture.

How do I download a slope field as an image?

Set the equation, the window, and any solution curves you want, then press Download PNG for an image you can paste into notes or slides, or Download SVG for a file that stays sharp at any size and can be edited in a vector drawing program. The saved file has a white background with the equation printed under the graph. Copy link gives a URL that reopens the same picture.