Type a first- or second-order ordinary differential equation and its initial conditions. The solver identifies the type, finds the general and particular solution step by step when a closed form exists (separable, linear, constant-coefficient, Cauchy–Euler), and always computes a numerical RK4 solution with a graph and table.
Last updated:
Write y′ as y' and y″ as y'' (dy/dx also works). Use x or t as the independent variable. Supports + − * / ^, sin, cos, tan, exp, ln, sqrt and more.
Solve and plot for x from … to
Graph of the solution
Advertisement
Advertisement
How to use the Differential Equation Solver
Type the equation using y' and y'' for the derivatives, for example y'' + 3y' + 2y = sin(x) or y' = x*y, or tap an example.
Enter the initial conditions: the point x₀, y(x₀) and, for second-order equations, y′(x₀).
Set the range of x to solve and plot over.
Press Solve equation to see the equation type, the general solution, the solution of your initial value problem and the steps.
Check the graph and table: the dashed exact curve should sit on the RK4 curve. Download the values as CSV if you need them.
Methods used for each type of equation
Equation type
Form
Method
Separable
y′ = g(x)·h(y)
∫ dy/h(y) = ∫ g(x) dx + C, then solve for y
First-order linear
y′ + p(x)y = q(x)
Integrating factor μ = e∫p dx, then (μy)′ = μq
Constant coefficients, homogeneous
ay″ + by′ + cy = 0
Characteristic equation ar² + br + c = 0
Constant coefficients, forced
ay″ + by′ + cy = f(x)
y = yh + yp, undetermined coefficients for yp
Cauchy–Euler
x²y″ + bxy′ + cy = 0
Try y = xr: r(r − 1) + br + c = 0
Anything else (nonlinear, variable coefficients)
y″ = F(x, y, y′)
Numerical fourth-order Runge–Kutta
Homogeneous solution from the characteristic roots
Roots of ar² + br + c = 0
Discriminant b² − 4ac
General solution yh
Behavior
Two real roots r₁ ≠ r₂
> 0
C₁er₁x + C₂er₂x
Overdamped (no oscillation)
One repeated root r
= 0
(C₁ + C₂x)erx
Critically damped
Complex pair α ± βi
< 0
eαx(C₁cos βx + C₂sin βx)
Oscillates; decays if α < 0
Guesses for the particular solution
Right-hand side f(x)
Trial yp
Polynomial of degree n
Anxⁿ + … + A₁x + A₀
k·eax
A·eax
k·cos(bx) or k·sin(bx)
A·cos(bx) + B·sin(bx)
eax·(polynomial)·cos(bx)
eax[P(x)cos(bx) + Q(x)sin(bx)]
If the trial function already solves the homogeneous equation (the exponent a or a ± bi is a characteristic root of multiplicity m), multiply the guess by xm. The solver applies this rule automatically, which is how resonance terms such as x·cos(2x) appear.
Tips
Compare the curves. When a closed form is found, the dashed exact solution is drawn over the RK4 curve and the largest difference is reported, so you can trust the formula.
Logistic growth y′ = ky(1 − y/K) is separable; its solution approaches the carrying capacity K for any positive start value.
Stiff or fast-growing equations may need a shorter range; if the curve stops early, the solution has a vertical asymptote there.
To solve with Laplace transforms, transform both sides, use L{y′} = sY − y(0) and L{y″} = s²Y − s·y(0) − y′(0), solve for Y(s) and invert.
Frequently asked questions
Which differential equations can it solve exactly?
First-order separable equations y′ = g(x)h(y), first-order linear equations y′ + p(x)y = q(x) when the integrating factor is elementary, linear equations of first or second order with constant coefficients and a right-hand side built from polynomials, exponentials, sines and cosines, and homogeneous Cauchy–Euler equations x²y″ + bxy′ + cy = 0. Every other first- or second-order equation is solved numerically.
How do you solve a second-order equation with constant coefficients?
For ay″ + by′ + cy = 0, substitute y = e^(rx) to get the characteristic equation ar² + br + c = 0. Two real roots give C₁e^(r₁x) + C₂e^(r₂x), a repeated root gives (C₁ + C₂x)e^(rx), and complex roots α ± βi give e^(αx)(C₁cos βx + C₂sin βx). A forced equation adds a particular solution found by undetermined coefficients.
What is resonance in the solver output?
When the right-hand side has the same form as a solution of the homogeneous equation, for example y″ + 4y = sin(2x), the usual guess fails and the particular solution gets an extra factor of x: here y_p = −x·cos(2x)/4. The amplitude then grows linearly, which you can see on the graph.
How does the numerical RK4 method work?
The classical fourth-order Runge–Kutta method advances the solution in small steps h, averaging four slope estimates per step: y_(n+1) = y_n + h/6·(k₁ + 2k₂ + 2k₃ + k₄). The solver uses 1,000 steps over the chosen range, and a second-order equation is rewritten as a system of two first-order equations for y and y′. The global error shrinks like h⁴.
What are initial conditions and why do I need them?
A general solution contains arbitrary constants: one for a first-order equation and two for a second-order equation. Initial conditions such as y(0) = 1 and y′(0) = 0 pick out the single solution curve that passes through that point with that slope, which is called an initial value problem.
Why does the curve stop before the end of the range?
Some solutions blow up in finite x. For example y′ = 1 + y² with y(0) = 0 has the solution y = tan(x), which goes to infinity at x = π/2. The numerical solver stops there and tells you where the singularity is.
Can I use t instead of x?
Yes. Write the equation with t, for example y'' + y = cos(t), and the solution is shown in terms of t. Derivatives can also be typed as dy/dx or d2y/dx2.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.