🌪️Differential Equation Solver - Slope Field & Phase Portrait
Three panels cover the core of an ordinary differential equations course. First-order y′ = f(x, y): draw the slope field and click anywhere to use that point as an initial condition — the solution is traced both ways with adaptive RK45 (Dormand–Prince) or fixed-step RK4. A table runs Euler’s method and RK4 with the same step and compares each step with a high-accuracy reference, so you can see the difference between a first- and a fourth-order method. Planar systems x′ = f(x, y), y′ = g(x, y): direction arrows and both nullclines are drawn, clicking starts a trajectory (solid forward, dashed backward in time), and every equilibrium in view is found with Newton’s method and classified from the Jacobian’s eigenvalues as a saddle, stable or unstable node, spiral or center; Lotka–Volterra, a damped pendulum, the van der Pol oscillator and competing species are built in. Second-order linear equations ay″ + by′ + cy = g(x) with constant coefficients: the characteristic equation, discriminant and roots are shown with the general solution for distinct real, repeated and complex roots; forcing terms can be sums of products of polynomials, e^(kx), sin and cos, solved by undetermined coefficients (multiplying by x or x² on resonance); with initial conditions C₁ and C₂ are found. The answer is substituted back to check the residual and compared with an RK45 numerical solution.
Free · No sign-up · Runs in your browserLast updated:
How to use Differential Equation Solver
- 1Pick a panel: first-order slope field, phase portrait for a system, or second-order linear
- 2Enter the equation (e.g. y′ = x − y, or a, b, c and g(x)) and adjust the view
- 3Click the plot to add initial points; read the equilibrium table, the error comparison or the step-by-step solution
FAQ
- What’s the difference between RK4 and RK45?
- RK4 is the classical fourth-order Runge–Kutta method: four slope evaluations per step with a fixed step size, and halving the step cuts the error to about 1/16. RK45 (Dormand–Prince) computes fourth- and fifth-order results at each step, uses their difference as an error estimate and adapts the step size — long steps where the solution is smooth, short ones where it changes fast — which is usually faster and more reliable for the same accuracy. Solution curves use RK45 by default; you can switch to fixed-step RK4 to compare.
- How are equilibria classified?
- At each equilibrium the Jacobian J (the matrix of partial derivatives) is computed, and its trace and determinant decide the type: det J < 0 is a saddle; with det J > 0, a discriminant tr² − 4 det > 0 gives a node and < 0 a spiral, stable when tr J < 0 and unstable when tr J > 0; tr J = 0 with det J > 0 is a center. This is the linearization result — centers and degenerate cases (det J = 0) can behave differently once nonlinear terms are included.
- When do I multiply the trial solution by x?
- When the e^(λx) in the forcing term (λ = α ± βi for sines and cosines) is a root of the characteristic equation, a trial solution of the same form solves the homogeneous equation, so substituting it gives 0 and no coefficients can be found. This is resonance: multiply the trial by xˢ, where s is the multiplicity of λ as a root (1 or 2). For y″ − 2y′ + y = eˣ, 1 is a double root, so try A·x²·eˣ, giving A = 1/2.
- Which forcing terms g(x) are supported?
- g(x) can be a sum of terms, each a product of a polynomial, an exponential e^(kx) or aˣ, and sin(kx + φ) or cos(kx + φ) — for example 3x², x·e^(−2x), e^x·cos(2x) or 5sin(3x + 1). Terms with the same exponent and frequency are combined. Forcing terms like tan x, 1/x or ln x need variation of parameters rather than undetermined coefficients and are rejected with a message; such equations can still be solved numerically as a first-order system.