Differential Equation Solver

Solve simple first-order DEs y'=f(x).

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Type an equation the way your textbook writes it (y' + 2y = x, y'' + 3y' + 2y = 0, y^(4) − y = 0, d²y/dx² + y = tan x, (2xy+3)dx + (x²−1)dy = 0, or a system such as x' = 3x + y; y' = x + 3y) and add initial conditions like y(0)=1, y'(0)=0. The tool names the method, shows the steps, substitutes the answer back into the equation (the Checked line), and falls back to Runge–Kutta 4 when no closed form exists.

How to use

1
Step 1
Type the equation: y' = f(x, y), dy/dx =..., y'' + p y' + q y = g(x), y^(4) notation, M dx + N dy = 0, or two equations separated by a semicolon for a system.
2
Step 2
Add initial conditions in the second box, separated by commas: y(0)=1, y'(0)=0 for second order, x(0)=1, y(0)=0 for a system. Leave it empty for a general solution with C, C1, C2.
3
Step 3
Enter an x value if you want y there; for equations with no closed form this value and all starting values are required.
4
Step 4
Leave the method on Auto, or force closed form or numeric, and press Calculate. The Method used row says what ran and the Checked row shows the residual of the substitution test.

How it works

First order: y' = f(x) is integrated; y' = f(x)g(y) is separated; y' + P(x)y = Q(x) is solved with the integrating factor μ = exp(∫P dx), so that (μy)' = μQ; Bernoulli equations y' + Py = Qyⁿ use v = y^(1−n); homogeneous equations y' = F(y/x) use y = vx and become separable; M dx + N dy = 0 is tested for exactness (M_y = N_x), then the potential ψ is built and ψ = C is the solution (an integrating factor depending on x only or y only is tried when it is not exact). Autonomous equations y' = f(y) also report their equilibrium points and whether each is stable, unstable or semi-stable. Higher order: for linear equations with constant coefficients the characteristic polynomial is solved (distinct, repeated and complex-conjugate roots, any order), the forcing term is handled by undetermined coefficients for polynomial × e^(ax) × sin/cos combinations including resonance (the trial solution is multiplied by x^s), and by variation of parameters in second order when the integrals can be done (tan, sec, 1/sin, e^x/x). Cauchy–Euler equations use the indicial equation of y = x^r. When y or x is missing, p = y' reduces the order. The constants are found from your conditions by a linear solve (conditions at two points also work). Systems x' = Ax in two unknowns use the eigenvalues and eigenvectors of A (real, repeated with a generalized eigenvector, complex). Everything that is not solvable this way goes to Runge–Kutta 4 on the equivalent first-order system, with the step count doubled from your value until the half-step error estimate is below 1e-9 or 20,000 steps are reached.

y' + Py = Q: y = (1/μ)(∫μQ dx + C), μ = e^(∫P dx)      ar² + br + c = 0 → e^(rx), x·e^(rx), e^(αx)cos βx, e^(αx)sin βx      RK4: yₙ₊₁ = yₙ + (h/6)(k₁ + 2k₂ + 2k₃ + k₄)

Worked example

A second-order initial-value problem

Input
y'' + 3y' + 2y = 0, y(0) = 1, y'(0) = 0, x = 1
Output
y = -exp(-2*x) + 2*exp(-x), y(1) = 0.6004236
Walkthrough
The characteristic equation r² + 3r + 2 = 0 has roots −2 and −1, so y = C1·e^(−2x) + C2·e^(−x). The conditions give C1 + C2 = 1 and −2C1 − C2 = 0, so C1 = −1 and C2 = 2. The tool substitutes the result into the equation at eight test points (largest relative residual about 2e-16), and a step-controlled Runge–Kutta 4 run of the equivalent system agrees with y(1) = 0.6004236.

Limitations

  • Closed forms exist only for the families above: first-order separable, linear, Bernoulli, homogeneous and exact equations; linear constant-coefficient equations of any order; second-order Cauchy–Euler (nonhomogeneous only through variation of parameters); reduction of order when y or x is missing; and homogeneous 2×2 constant-coefficient systems. Other linear equations with variable coefficients (Bessel, Airy, Legendre) go to the numeric method.
  • Undetermined coefficients needs a forcing term that is a sum of polynomial × e^(ax) × sin/cos(bx) terms. Variation of parameters is implemented for second order only, and only when the integrals can be done: y'' + y = tan x works, y'' + y = 1/x does not (it needs Si and Ci), and the tool says so instead of guessing.
  • Exact equations are given as the implicit relation ψ(x, y) = C, and the answer is labelled implicit; it is solved for y only when ψ is linear in y. Separable results such as the logistic equation also stay implicit, with y at your x taken from RK4.
  • Reduction of order needs the reduced first-order equation to have an explicit solution; y'' = 2yy' with y(0)=0, y'(0)=1 gives the implicit atan(y) = x. Systems with a forcing term or more than two unknowns are solved numerically, not in closed form.
  • The numeric method needs all starting values at one x, an end x, and an equation that is first degree in its highest derivative. It stops with a message if the solution blows up. Step control doubles the count from your value; it is capped at 20,000 steps, and stiff equations may need more.
  • The substitution check uses eight test points, which catches algebra slips but is not a proof. Cauchy–Euler solutions are valid for x > 0, and formulas with roots or logarithms hold on the interval around your starting point where they stay defined.

Questions

What is the solution of y' + 2y = x with y(0) = 1?
y = x/2 − 1/4 + (5/4)e^(−2x). The integrating factor is e^(2x); then (e^(2x)y)' = xe^(2x), and y(0) = 1 gives C = 5/4. At x = 1 the value is 0.4191691.
What is y(1) for y' = x + y with y(0) = 1?
y = 2e^x − x − 1, so y(1) = 2e − 2 = 3.4365637. It is a linear equation, so it is solved exactly by an integrating factor and RK4 only cross-checks it.
How do I enter a second-order equation with conditions?
Type y'' + 3y' + 2y = 0 (or d^2y/dx^2 + 3 dy/dx + 2y = 0) and put y(0)=1, y'(0)=0 in the initial-condition box. y^(4) is accepted for higher derivatives.
What does the tool do with a forcing term like e^x when e^x is already a solution?
That is resonance. For y'' − 3y' + 2y = e^x the particular solution is −x·e^x, because the trial solution is multiplied by x once; the step text says so, and the general solution is y = C1·e^x + C2·e^(2x) − x·e^x.
Can it solve y'' + y = tan x?
Yes, by variation of parameters: y = C1 cos x + C2 sin x − cos x · ln|sec x + tan x|. The tool shows u₁' and u₂', the integrals, and the substitution check.
How are systems written?
Separate the equations with a semicolon or a new line: x' = 3x + y; y' = x + 3y, with x(0)=1, y(0)=0. The independent variable is t unless you write dx/dt or use the variable field. The answer is x(t) = e^(2t)/2 + e^(4t)/2, y(t) = −e^(2t)/2 + e^(4t)/2.
How do I know the answer is right?
Every closed form is substituted back into the equation at several test points; the Checked row reports the largest residual and the initial conditions are re-tested. Implicit answers are checked by implicit differentiation, exact equations by ψ_x = M and ψ_y = N.
What happens if there is no closed form?
In Auto mode with starting values and an end x, the tool converts the equation to a first-order system, runs Runge–Kutta 4 with step control and says why it did. In closed-form-only mode, or without starting values, it stops with a message instead of a wrong answer.

Features

  • First-order: linear, Bernoulli, exact, homogeneous
  • Any-order linear equations and Cauchy–Euler
  • 2×2 systems and RK4 for any order
  • Every closed form checked by substitution

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • Variables, expressions, and equations

    Khan Academy

    Algebra language shared by many math calculators.

    Watch on YouTube
  • Definite integrals intro

    Khan Academy

    Definite integral basics for area-under-curve calculators.

    Watch on YouTube
  • Math is Fun

    Math is Fun

    Clear explainers that pair well with calculator-style tools.

  • OpenStax Math

    OpenStax

    Free textbooks for algebra through calculus.