A differential equation links an unknown function to its derivatives: says that a quantity loses 10 % of itself per unit of time, describes a spring that oscillates forever. Solving it means finding every function that satisfies the relation, and then the one function that also matches the starting data, the initial conditions.
This differential equation solver covers the ordinary differential equations (ODEs) met in a first course, each with its exact closed-form answer and the working:
- First-order linear with constant coefficients, , solved with an integrating factor.
- Exponential growth or decay, , and the logistic model , with doubling time, half-life or inflection time.
- Second-order linear with constant coefficients, : characteristic equation, the three root cases and the constants fitted to and .
- Any first-order equation , solved numerically with the fourth-order Runge–Kutta method (RK4) and compared with Euler’s method.
Every result comes with a graph of over the interval and a table of values, so you can see the shape of the solution, not only one number.
How to use this calculator
- Choose the equation type.
- Enter the coefficients. For type and ; for the second-order equation type , , and the constant (leave for a homogeneous equation).
- Enter the initial conditions: the starting point and , plus for a second-order equation. The growth models start at .
- Enter the point where you want the value, or . The chart and the table run from the start to that point.
- For the numerical mode, type the right-hand side — for example
x + yorsin(x) - y— and the number of steps . More steps give a smaller error. - Open the steps to follow the method line by line.
The formula
First-order linear. Multiply by the integrating factor : the left side becomes , and integrating gives
Growth models. Separating variables in gives , with doubling time (or half-life) . The logistic equation gives
and the curve is steepest when , at .
Second order. Substituting into gives the characteristic equation :
| Discriminant | Roots | General solution |
|---|---|---|
| real | ||
| repeated | ||
A constant right-hand side adds the particular solution (or if , if ). and then follow from and .
RK4. With step :
where , , and . Its global error shrinks like ; Euler’s only like .
Worked example
First order (the default). For with : and , so . At the solver gives and a slope of 0.541341; every solution approaches the stable equilibrium .
Distinct roots. , , : has roots 2 and 1, the conditions give , , so and .
Complex roots. , , : roots , so and .
Repeated root. , , : twice, so and .
Logistic. , , : , , inflection at , and .
RK4. , from 0 to 1 in 100 steps gives 2.71828183 — to eight decimals — while Euler gives 2.70481383.
A diff eq solver with steps, not just an answer
“Diff eq” is the usual student shorthand for differential equations, and most searches for a diff eq solver or a diff equation calculator come from someone checking homework. That is why each mode prints its working: the standard form, the integrating factor or the characteristic equation, the general solution with its constants , , , the values fitted to the initial conditions, and the final value. Compare your own lines with these to find exactly where a sign slipped.
The page is also a differential equation solution calculator in the practical sense: it evaluates the solution at any point, gives the slope there, and tabulates the curve. For derivatives and antiderivatives of the formulas themselves, use the derivative calculator and the integral calculator; to plot other functions, the graphing calculator.
Existence, uniqueness and when to go numerical
If and are continuous near , the initial value problem , has exactly one solution on some interval around (the Picard–Lindelöf theorem). The linear equations on this page have continuous coefficients everywhere, so their solutions exist and are unique for all .
Uniqueness can fail: with has the solution but also for . A solution can also blow up in finite time — , gives , which explodes at ; the solver stops with an error when the values explode instead of printing a meaningless number.
Most equations, such as , have no formula in elementary functions. Then RK4 is the standard tool: with 100 steps it is usually accurate to many digits on a short interval. If halving (doubling ) barely changes the result, you can trust it.
Frequently asked questions
What is a differential equation?
An equation that contains an unknown function and its derivatives, such as y′ = 3y or y″ + y = 0. Its solution is a function, not a number. The order is the highest derivative that appears; “ordinary” means one independent variable.
Why do I need initial conditions?
Integration produces arbitrary constants: one for a first-order equation, two for a second-order one. Each initial condition — y(x₀), and y′(x₀) for second order — fixes one constant, so you get a single particular solution instead of a whole family.
Can this diff eq solver handle non-linear equations?
Yes, in the numerical mode. Type any f(x, y), for example x*y^2 or sin(y) - x, and RK4 integrates it step by step. The closed-form modes cover the linear constant-coefficient and logistic cases, which have exact formulas.
How accurate is RK4 compared with Euler’s method?
For y′ = y over [0, 1], 100 RK4 steps match e to about 10 significant digits, while Euler is off by 0.0135. Halving the step divides the RK4 error by about 16 and the Euler error by only about 2.
What do complex roots mean physically?
Oscillation. For a y″ + b y′ + c y = 0 with roots α ± βi, the solution oscillates with angular frequency β; α < 0 means it dies out (a damped spring), α = 0 means it oscillates forever, and α > 0 means it grows.
Sources
- OpenStax — Calculus Volume 2, chapter 4: Introduction to Differential Equations
- OpenStax — Calculus Volume 2, §4.4: The Logistic Equation
- OpenStax — Calculus Volume 3, chapter 7: Second-Order Differential Equations
- Paul’s Online Notes (Lamar University) — Second Order Differential Equations
- MIT OpenCourseWare — 18.03SC Differential Equations: Numerical Methods
Last updated: