Slope fields in this visualization
A first-order differential equation prescribes a slope at every point of the plane. Its slope field (also called a direction field) draws that slope as a short segment at each point of a lattice. A solution is a differentiable function whose graph is tangent to the segments everywhere; an initial-value problem asks for the one through a given point . When f is continuous and locally Lipschitz in y, exactly one solution passes through each point, on some interval of x — so the slopes alone determine every solution.
Drag P and the whole curve through it moves continuously (on any closed interval where the solution exists). For the eight preset equations the curves are closed-form solutions; for an equation you type they are computed numerically with an adaptive Runge–Kutta method (Dormand–Prince 5(4), relative tolerance ). If y′ depends on x only, solutions differ by a constant: is a vertical shift. If it depends on y only, the zeros of f are horizontal equilibrium solutions, and the solutions lying between two neighbouring equilibria are horizontal shifts of each other.
Euler’s method follows the slope read at the current point for one step of length h, then reads again. Here it runs from P to the end X (its last step shortened to land on X). For a smooth solution its error at X is roughly proportional to h: the red key halves h level by level, and each halving roughly halves the error, so the ratio of successive errors tends to 2.
Things to notice
- The segments have equal length and no arrowheads: only their slope means something. A slope field is the vector field with every arrow’s length thrown away.
- A solution need not exist for every x. For the solution through (0, 1) is , which grows without bound as x approaches 1; the page stops it at the dashed line and never joins it to the other branch. For the solution through (0, 2) is a half circle that ends where its slope turns vertical. Euler still returns a number past such a point; the solution’s value is then marked as not existing.
- Without the Lipschitz condition a solution need not be unique: and both solve through (0, 0), and so does any curve that rests on y = 0 for a while and then leaves. Euler’s method from (0, 0) stays at 0 at every step size.
- Isoclines are the curves where the slope is constant, ; along each one the segments are parallel, which is how slope fields are sketched by hand. With h = π/n, Euler on from (0, 0) to π returns exactly h.
Controls
- Click empty space to add another solution (up to six); the one you touched last is P, the one Euler starts from. With Pan on, dragging moves the picture instead.
- Drag the ▲ on the x axis, or turn its wheel, to move Euler’s end X. The red key starts from the current h; at the end it starts again from h = 1. The Approach record window collects each level’s value, error and ratio, even while it is closed.
Related
Euler’s method on from (0, 1) to 1 gives , the compound-interest factor. A system of two equations is drawn as a phase portrait.
- D05Derivative
- D18Fundamental theorem of calculus
- E22Vector field
- G07Phase portraitPlanned
- A11Compound interest
Further reading: Wikipedia: Slope field; OpenStax, Calculus Volume 2, 4.2 Direction Fields and Numerical Methods.