# Differential Equation Solver - Slope Field & Phase Portrait

> ODE tool: slope fields with click-to-trace solutions (RK4/RK45), Euler vs RK4 errors, phase portraits with equilibrium types, and 2nd-order linear ODEs.

- URL: https://qilingtools.com/en/math/ode
- Category: Math Tools (https://qilingtools.com/en/math)
- Tags: [Math](https://qilingtools.com/en/tags/math), [Physics](https://qilingtools.com/en/tags/physics)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

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.

## How to use

1. Pick a panel: first-order slope field, phase portrait for a system, or second-order linear
2. Enter the equation (e.g. y′ = x − y, or a, b, c and g(x)) and adjust the view
3. Click the plot to add initial points; read the equilibrium table, the error comparison or the step-by-step solution

## Features

- Slope field with click-to-trace solutions (RK45 / RK4)
- Euler vs RK4 step-by-step error table
- Phase portraits: arrows, nullclines and trajectories
- Automatic equilibria with eigenvalue classification
- Second-order linear ODEs: all three root cases
- Undetermined coefficients with resonance handled
- Initial conditions solved for C₁ and C₂, verified by substitution
- Compared with an RK45 numerical solution; send y(x) to the grapher

## 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.

## Related tools

- [Graphing Calculator](https://qilingtools.com/en/math/graph): Free online function graphing calculator: type sin(x), x^2 or 1/x and see the curve at once, with several functions, parametric and polar curves, PNG export.
- [Scientific Calculator](https://qilingtools.com/en/math/calculator): Free online scientific calculator: type 2*(3+4)^2, sin(pi/6) or log(8,2) and see the answer as you type, with degrees or radians and a history list.
- [Equation Solver](https://qilingtools.com/en/math/equation): Free online equation solver: enter coefficients for linear, quadratic (with discriminant, vertex and complex roots) and cubic equations, plus 2×2 systems.
- [Fraction Calculator](https://qilingtools.com/en/math/fraction): Free online fraction calculator: add, subtract, multiply and divide fractions with automatic reduction, plus fraction ↔ decimal with repeating digits.
- [Percentage Calculator](https://qilingtools.com/en/math/percentage): Free online percentage calculator: X% of Y, X as a percent of Y, increase and decrease, a value after a percentage change and the original behind it.
- [Prime Factorization](https://qilingtools.com/en/math/prime): Free online prime factorization: factor an integer with exponents, list every divisor and their sum, test primality with neighbouring primes, or list a range.
- [GCD and LCM](https://qilingtools.com/en/math/gcd-lcm): Free online GCD and LCM calculator: works with two or more integers, says whether they are coprime, shows each prime factorization and every Euclidean step.
- [Statistics Calculator](https://qilingtools.com/en/math/statistics): Free online statistics calculator: paste a data set for the mean, median, mode, range, quartiles, variance, standard deviation, standard error and outliers.
