Differential Equation Solver, Explained

After reading this you will know how to write an ODE for the solver, how to read the general solution with its free constants, and how initial conditions turn that general answer into one specific curve.

A differential equation links a function to its own rate of change. The unknown is not a number but a whole function y(x). Solving it means finding every function whose derivatives satisfy the equation. This solver handles first and second order ordinary differential equations symbolically, so the answer comes back as an exact formula rather than a table of approximate points.

Here is the hook. Type y'' + y = 0 and you get y = C_1 \cos x + C_2 \sin x. That single formula describes every oscillation of a frictionless spring. Add the conditions y(0) = 1 and y'(0) = 0 and the answer collapses to exactly y = \cos x. The whole workflow of this page is in that sentence: solve, then pin down.

What the solver does and what the notation means

Write the unknown function as y. Write its first derivative as y' and its second derivative as y''. The independent variable is x. So y'' + 3*y' + 2*y = 0 means "the second derivative plus three times the first derivative plus twice the function equals zero."

Order
The highest derivative present. y' = y is first order. y'' + y = 0 is second order. This tool covers both.
Linear
The equation involves y, y' and y'' only to the first power, with no products like y*y'. Linear equations are the ones with clean symbolic answers.
Homogeneous
The right-hand side is zero, as in y'' + y = 0. A nonzero right side, such as y'' + y = x, makes it inhomogeneous.
General solution
The full family of solutions, carrying free constants. A first order equation carries one constant, a second order equation carries two.

When to use this tool, and when not to

Reach for the symbolic solver when the equation is linear with constant coefficients, or one of the standard separable and first order linear forms. Those cases have closed-form answers you can differentiate by hand to check.

Symbolic methods fail on many nonlinear equations. There is no elementary formula for y' = x^2 + y^2, for example. When the equation resists a symbolic answer, or you only need values on a specific interval, switch to a numerical approach and evaluate the function pointwise.

A symbolic solution is not always the practical one. Even when a formula exists it can be a page of special functions. If you need a graph on [0, 10], a numerical method is often faster and clearer than an exact expression you cannot read.

The characteristic equation, and why it works

For a linear equation with constant coefficients, guess an exponential solution y = e^{rx}. Because y' = r e^{rx} and y'' = r^2 e^{rx}, every term shares the factor e^{rx}. Divide it out and you are left with an algebraic equation in r.

a y'' + b y' + c y = 0 \;\Rightarrow\; a r^2 + b r + c = 0

That polynomial is the characteristic equation. Its roots r_1 and r_2 control the shape of every solution. Here a, b and c are the coefficients of y'', y' and y. The three possible root types give three solution families.

Solution form by root type for a r^2 + b r + c = 0
DiscriminantRootsGeneral solution
b^2 - 4ac \gt 0real, distinct r_1, r_2C_1 e^{r_1 x} + C_2 e^{r_2 x}
b^2 - 4ac = 0repeated r(C_1 + C_2 x) e^{r x}
b^2 - 4ac \lt 0complex \alpha \pm \beta ie^{\alpha x}(C_1 \cos \beta x + C_2 \sin \beta x)

For y'' + y = 0 the characteristic equation is r^2 + 1 = 0, giving r = \pm i. So \alpha = 0 and \beta = 1, and the solution is C_1 \cos x + C_2 \sin x. That matches the third row exactly.

Worked example: reproducing the demo

Solve y'' + y = 0 with y(0) = 1 and y'(0) = 0

  1. Read off the coefficients: a = 1, b = 0, c = 1.
  2. Characteristic equation: r^2 + 1 = 0, so r = \pm i, meaning \alpha = 0, \beta = 1.
  3. General solution: y = C_1 \cos x + C_2 \sin x.
  4. Apply y(0) = 1. Since \cos 0 = 1 and \sin 0 = 0, this gives C_1 = 1.
  5. Differentiate: y' = -C_1 \sin x + C_2 \cos x. At x = 0 that is C_2. Apply y'(0) = 0, so C_2 = 0.
  6. Particular solution: y = \cos x.

Check it by hand. If y = \cos x then y'' = -\cos x, so y'' + y = -\cos x + \cos x = 0. The conditions hold: y(0) = \cos 0 = 1 and y'(0) = -\sin 0 = 0.

The particular solution passes through (0, 1) with a flat slope there, exactly as the conditions require.

How initial conditions choose the constants

The general solution is a whole family. Every choice of C_1 and C_2 is a valid solution of the differential equation. Initial conditions are the extra facts that select one member of that family.

A second order equation needs two conditions, usually the value and the slope at one point, y(x_0) and y'(x_0). Those two numbers give two linear equations in the two unknown constants, and you solve for them. A first order equation needs just one condition, so you leave the slope field empty.

Watch the effect directly below. Both constants shift the curve while the underlying equation stays fixed.

For y'' + y = 0 the solution is y = C_1 \cos x + C_2 \sin x. With C_1 = 1, C_2 = 0 you get cos x. With C_1 = 0, C_2 = 1 you get sin x. With C_1 = 1, C_2 = 1 the curve is \sqrt{2}\,\sin(x + \pi/4), an oscillation of amplitude about 1.414.

Reading and interpreting the result

When you leave the initial-condition fields blank the answer contains C1 and C2. As the footnote on the calculator says, these are free constants fixed by initial conditions. They are not errors and not something the tool failed to compute. They are the honest report that infinitely many functions solve the equation.

Read the exponents to read the behavior. A term like e^{-2x} decays: at x = 1 it is 0.135, at x = 3 it is 0.00248. A term like e^{2x} blows up: 7.389 at x = 1, 403.4 at x = 3. Sine and cosine terms oscillate forever with constant amplitude. A factor e^{-0.5x}\cos x oscillates while shrinking, the picture of a damped spring.

Sanity-check any answer by substituting it back. Differentiate the reported y, plug into the left side, and confirm it equals the right side. The Derivative & Integral Calculator does the differentiation for you if the algebra is heavy.

Common mistakes

Three errors account for most confusion.

  • Forgetting a multiplication sign. Write 3*y', not 3y'. An implied product can be misread.
  • Giving one condition to a second order equation. You need both y(x_0) and y'(x_0) to eliminate both constants. With only y(0) = 1 for y'' + y = 0, one constant survives: y = \cos x + C_2 \sin x.
  • Expecting a formula for a nonlinear equation. Products such as y*y' or powers such as (y')^2 usually have no elementary solution. A blank or "no closed form" result is often correct, not a bug.

One subtler point: the sign of the discriminant decides whether you see exponentials or oscillations. Change y'' + y = 0 to y'' - y = 0 and the roots flip from \pm i to \pm 1. The answer changes from C_1 \cos x + C_2 \sin x to C_1 e^{x} + C_2 e^{-x}. Bounded waves become one growing and one decaying exponential.

A negative root shrinks toward zero, a zero root stays flat, a positive root grows fast. The sign of r is the whole story of long-term behavior.

Related tools

Once you have a symbolic solution, several other pages help you use it. The Function Analyzer & Grapher finds zeros, extrema and asymptotes of the solution curve. The Taylor & Maclaurin Series tool builds a polynomial approximation near a point, useful when the exact solution is awkward. For long-run behavior use the Limit Calculator to test whether the solution tends to a finite value or grows without bound.

When no formula exists and you only need numbers, tabulate the solution and pass it to the Interpolation Calculator to fill in between points, or integrate a right-hand side with the Numerical Integrator.

Frequently asked questions

What do C1 and C2 mean in the answer?

They are free constants. Every value of them gives a valid solution of the equation. For y'' + y = 0, choosing C_1 = 1, C_2 = 0 gives cos x; choosing C_1 = 0, C_2 = 1 gives sin x. Supply initial conditions to fix them.

How many initial conditions do I need?

One for a first order equation, two for a second order equation. The count equals the order, which equals the number of free constants. Two conditions for a second order equation are typically y(x_0) and y'(x_0).

Why did I get no answer for my equation?

Most likely it is nonlinear, such as y' = y^2 + x, and has no elementary closed form. Check that you used * for products and that derivatives are written y' and y''. If it is genuinely nonlinear, use a numerical method instead.

Can it handle a nonzero right-hand side?

Yes for standard linear forms. For y'' + y = x the answer is C_1 \cos x + C_2 \sin x + x: the homogeneous part plus a particular solution. Verify by differentiating, since y'' = -C_1\cos x - C_2\sin x and adding y leaves x.

Does the choice of x0 matter?

The general solution does not depend on x0, but the particular solution does. Applying y(0) = 1 to y'' + y = 0 gives C_1 = 1, while applying y(\pi/2) = 1 gives C_2 = 1 instead, because \sin(\pi/2) = 1. Same family, different member.