Slope Field & ODE Solver

Read a first-order differential equation as a field of tiny tangent lines. Click the plot to add initial conditions and trace the matching solution curves.

Loading interactive simulation...

Lesson

The theory — Slope Field & ODE Solver

A first-order differential equation dy/dx = f(x,y) never states what y is. It states how fast y is changing at each point. A solution is any curve whose slope at every point equals f there — and there is a whole family of them, one through each starting point.

What each symbol means

dy/dx
the slope of a solution curve — the quantity the equation prescribes, rather than the one it solves for.
f(x,y)
the right-hand side: a rule returning a slope for any point. The five presets here are y, x*y, -y/x, y*(1-y) and x^2-y.
(x₀,y₀)
an initial condition — one point the solution is required to pass through. It is what selects a single curve out of the family, and it is what a click on the plot supplies.

How to read what you see

The panel counts what has been drawn rather than describing it: 21 x 21 = 441 slope marks on the default grid, the largest finite slope currently in view, the plot window, and how many solution curves you have started. Each click adds an initial condition, and the RK4 solver then traces the matching curve both forward and backward in x.

Assumes
That the equation is first-order and already rearranged for dy/dx, and that f returns exactly one slope per point. The grid is a sample of the field, not the field itself — raising the density draws more marks without changing a single solution.
Breaks when
Choose -y/x and the counter changes to 421 finite, 20 vertical/singular. Those are the grid points sitting on the y-axis, where x = 0 leaves the slope undefined: the field genuinely has no direction there, and no solution curve crosses it. A slope field also cannot show you where a solution escapes to infinity at a finite x — the picture stays perfectly calm while the solution does not.

The picture answers the equation without ever solving it 🖖

A slope field represents a first-order ordinary differential equation dy/dx = f(x,y) by drawing short line segments with slope f(x,y) at points on a grid. This provides a geometric visualization of the flow of potential solution curves without solving the equation analytically. It shows equilibrium solutions (where dy/dx = 0), stable/unstable nodes, and inflection points where concavity shifts.

Following the arrows without solving anything 🖖

Think of the slope field as a set of tiny signposts: at every point, one tells you which way a solution must head next. A solution curve simply follows these directions, like a leaf drifting on a current. Because each point has exactly one direction, choosing a starting point (an initial condition) pins down a single curve — click anywhere and the tool traces that unique path for you.

RK4 secretly becomes Simpson's rule 🖖

The RK4 method the tool uses samples the slope four times per step and blends them with weights 1:2:2:1. When your equation is simply dy/dx = f(x), with no y on the right-hand side, that blend collapses exactly into Simpson's rule for integration: h/6·(f₀ + 4f_m + f₁). So numerically solving an ODE and computing a definite integral are, in this case, the very same calculation.

Practice

Check yourself

Predict the answer first, then use the controls above to find out. Reveal only after you have committed to a guess — that is what makes it practice.

  1. The hyperbolas preset solves y′ = −y/x and reports “Largest finite |slope|” as 10. Raise the grid density to 30 and read that row again — then do the same on the exponential and parabolas presets.

    Show answer
    On hyperbolas the row goes 5 → 10 → 15 for densities 10, 20 and 30. On exponential it stays at 3 and on parabolas at 11, whatever you do. For a singular field that row is describing your grid, not the equation: −y/x has no largest slope at all, since it runs away to infinity as x → 0, so the tool can only report the steepest mark it happened to land on. The nearest column to the axis sits at 8/density, so at density 20 it is x = 0.4, and 4/0.4 = 10 — the number on screen. The 20 marks flagged vertical are the whole x = 0 column, where the slope is not a number. The other two fields really are bounded on their windows, so the grid finds the same maximum every time.
  2. The logistic preset solves y′ = y(1−y), whose growth is famously fastest at y = 1/2, where the rate is 0.25. The panel reports the largest |slope| as 0.75. Where is it finding a slope three times too steep?

    Show answer
    Outside the population. The preset’s window runs from y = −0.5 to 1.5, and at y = −0.5 the rate is (−0.5)(1.5) = −0.75 — steeper than anything between the equilibrium lines, and falling, since the row reports magnitude. Set y min to 0 and y max to 1 and the row drops to 0.25, found at y = 0.5 where the biology puts it. You need not even be that strict: −0.2 to 1.2 also gives 0.25, because (−0.2)(1.2) is only 0.24. The famous number describes a logistic population; the panel describes the rectangle you asked it to draw.

Problems solved in full

  1. The family of curves for y′ = −y/x 6 steps

    y′ = −y/x, over −4 ≤ x ≤ 4 and −4 ≤ y ≤ 4, at a grid density of 20. Before a single solution curve is drawn, count how many of the marks can be given a slope at all, find the steepest one, and then work out what family of curves the field is made of.

    1. The grid is 20 intervals wide, which is 21 sample lines, not 20 — the ends count. A window 8 units across therefore samples every 0.4, and the same spacing runs vertically.

    2. 21 is odd, so one sample line falls exactly on the middle of the window, and the middle of this window is x = 0. That column is where the right-hand side has a zero in the denominator.

    3. On that column every point with y ≠ 0 gives a quotient with no value: a direction, drawn upright, but no number to report. That is 20 of the 21. The last one is the origin, where the ratio is 0/0 and the tool settles it by drawing the mark flat — a choice, not a consequence, and it is why the finite count comes out at 421 rather than 420.

    4. Steepness is |y|/|x|, so the steepest mark is the tallest point over the narrowest non-zero column: 4 divided by 0.4. The winners sit immediately beside the singular line, which is the only interesting thing about them.

    5. Now the curves themselves. The equation separates, and integrating both sides turns a sum of logarithms into a product: xy is constant along every solution, so the family is the rectangular hyperbolas.

    6. Test it at the point (1, 2), where the mark has slope −2. The hyperbola xy = 2 through that point has slope −2 there, so it fits. The circle x² + y² = 5 through the same point has slope −x/y = −0.5, so it does not — perpendicular-to-the-radius is the equation y′ = −x/y, with the x and the y the other way round.

    Answer

    421 finite marks, 20 vertical, and a steepest slope of 10. Only two of those three say anything about the differential equation. Redo the last one with the grid left as a symbol and the steepest slope the grid can see is 4 divided by 8/d, which is d/2 — the number is half the density setting and nothing else. The equation has no steepest slope at all; |y′| grows without bound as x → 0, and the panel is reporting how finely it looked, not how steep the field gets. At a density of 21 the effect is sharper still: 22 sample lines per side straddle x = 0 instead of landing on it, so all 484 marks come out finite and the singular column disappears from the count while remaining exactly as singular as before.

  2. A solution through y = 0.1 for y′ = y(1 − y) 6 steps

    y′ = y(1 − y), drawn over −2 ≤ x ≤ 6 and −0.5 ≤ y ≤ 1.5, at a grid density of 20. Without solving anything, say where the field is flat, which way a solution through y = 0.1 must go, and where in this window the marks are steepest. Then put a number on how long the rise takes.

    1. A mark is horizontal exactly where the right-hand side vanishes, and a product vanishes only when a factor does. Two values, and each of them is a solution in its own right: the constant functions y ≡ 0 and y ≡ 1 satisfy the equation for every x.

    2. Both of them land on sample lines. The 21 y values start at −0.5 and step by 0.1, so 0 and 1 are among them and the two flat rows are actually drawn rather than merely implied by the tilts either side.

    3. Between the flat rows both factors are positive, so every mark tilts up; outside them one factor has flipped sign and the marks tilt down. A solution starting at 0.1 rises, and it can never reach 1 — to pass that line it would have to cross the constant solution sitting on it, and two solutions of this equation cannot cross.

    4. Rising and bounded is not the same as stable, so nudge each equilibrium and watch the sign. Just above 0 the slope is about +ε and pushes further away; just above 1 it is about −ε and pushes back. One equation, two flat lines, opposite verdicts.

    5. The steepest marks are not where the growth is. Inside 0 ≤ y ≤ 1 the fastest change is at y = 0.5 and worth 0.25, but the window runs out to −0.5 and 1.5, where the product is −0.75 — three times steeper, at population values the model is not about.

    6. One quantity makes the curve straight. Differentiate the logarithm of the odds y/(1 − y): the chain rule produces exactly the factor y(1 − y) that the equation supplies, the two cancel, and what is left grows at a flat rate of 1.

    Answer

    Two equilibria, 0 repelling and 1 attracting, and a largest |slope| of 0.75 that lies outside 0 ≤ y ≤ 1 entirely. The last step is the one to keep. Log-odds advance at exactly 1 per unit of x, so the rise from 10% to 90% takes ln(9 ÷ 1/9) = ln 81 = 4.394 in x, whatever the starting value was. Nothing on the panel prints that, and it is the number a modeller actually wants: not the height of the curve but the length of its transition, fixed by the growth rate alone. This window is 8 wide, so a solution that enters near zero on the left spends a little over half of it doing the entire rise and the rest lying flat against y = 1.

References (1)
  • Direction fields, initial-value problems and when a solution is guaranteed to exist: W. E. Boyce & R. C. DiPrima, Elementary Differential Equations and Boundary Value Problems, 10th ed. John Wiley & Sons, 2012. ISBN 978-0-470-45831-0.

Example problems

  • y' = y - 441 marks, flat along y = 0 and steepest at the corners where the slope reads 3. That flat row is itself a solution, and no curve crosses it — so the sign of your first click decides whether the curve climbs or falls, and nothing later can change it.
  • Logistic - Flat marks along two lines, y = 0 and y = 1, and both are solutions. A curve starting between them is trapped and must run to 1. The steepest slope on the grid, 0.75, is not on that S-curve at all: it sits at y = −0.5, below the lower solution.
  • Hyperbolas - The counter splits into 421 finite marks and 20 vertical — the column at x = 0, where −y/x has no value. Now nudge the density from 20 to 21: 484 finite, none singular. The grid stopped landing on the axis. The singularity did not move; the sampling missed it.
  • Parabolas - Flat marks trace the parabola y = x², and every solution crosses it horizontally. The parabola is not itself a solution — on it the equation asks for slope 0 while the curve has slope 2x. The steepest mark, 11, is the bottom-left corner.