Equation Solver

Solve degree 1–4 equations with step-by-step working

If a term is missing, enter 0 in its box.Press Enter to jump to the next box. Fractions (1/2), decimals (0.5) and negatives (-3) are handled exactly; irrationals like √5, 2√3, √(2)/2, ∛2 and π are computed numerically.

About Equation Solver

This solver handles polynomial equations of degree 1 to 4 and nothing higher. Coefficients can be integers, fractions, decimals or small expressions with √, ∛, π and e (2√5, π−1). When the coefficients can be read as exact rationals, the roots are shown in closed form, such as √2 or (−3 + √17)/4; roots that have no tidy closed form appear as six-decimal approximations. Complex roots are always listed, so an equation of degree n always shows n roots, counting repeated ones.

The method changes with the equation. A quadratic with a perfect-square discriminant is factored; otherwise you get the quadratic formula and completing the square. A cubic with a rational root goes through the rational root theorem and synthetic division; a cubic with three real but irrational roots is solved by trigonometric substitution; Cardano's formula is always offered as the general alternative. Quartics use biquadratic substitution, synthetic division or Ferrari's method, and when none of those is clean the Durand–Kerner iteration approximates all four roots at once. The first method listed is the one that suits that particular equation best.

Why it stops at degree four: the Abel–Ruffini theorem

Quadratics have the quadratic formula, cubics have Cardano's formula and quartics have Ferrari's method, so their roots can always be written using arithmetic and radicals applied to the coefficients. From degree five on, no such general formula exists. Paolo Ruffini published an incomplete proof in 1799 and Niels Henrik Abel a complete one in 1824; Galois later explained exactly which equations can be solved by radicals.

The theorem does not say the formula is still waiting to be discovered; it says one cannot exist. The real root of x⁵ − x − 1 = 0 (about 1.1673) cannot be written with radicals at all. Equations like that are solved numerically, to as many digits as you need. Because this tool accepts at most degree four, reduce the degree first when you can: x⁶ − 5x³ + 4 = 0 becomes the quadratic t² − 5t + 4 = 0 with t = x³, giving t = 1 or 4 and then x = 1 or ∛4 as the real roots.

When the quadratic formula goes wrong on a computer

The roots of x² + 100,000,000x + 1 = 0 are roughly −100,000,000 and −0.00000001. Computing the small one as (−b + √(b² − 4ac)) ÷ 2a subtracts two numbers that agree in almost every digit: −10⁸ and √(10¹⁶ − 4). Double-precision floating point carries about 16 significant digits, so the subtraction wipes out the leading digits and leaves mostly rounding error. Numerical analysts call this catastrophic cancellation. In double precision the formula returns about −0.00000000745 instead of −0.00000001, an error of 25%.

The standard fix, described in Goldberg's classic paper on floating-point arithmetic, is what this solver uses: compute the large root first with the sign that adds magnitudes, x₁ = (−b − √D) ÷ 2a when b is positive (+√D when b is negative), and then get the small one from Vieta's relation x₂ = c ÷ (a·x₁). No subtraction of near-equal numbers happens, so entering 1, 100000000, 1 gives the small root as −1e-8 (−1 × 10⁻⁸), correct to about 16 significant digits. A small root that would round to 0 at six decimals is shown in exponent notation. The same sign choice is applied when a cubic or quartic is reduced to a quadratic via a rational root, and inside the cube roots of Cardano's formula.

The opposite problem, a discriminant that should be zero but comes out slightly positive, is handled inside the tool. It judges the sign of b² − 4ac relative to the size of b² and 4ac rather than against a fixed threshold, so 10⁶(x − √5)², whose computed discriminant is about 0.0078, is still recognized as having a double root.

Cubics with three real roots and imaginary numbers in the formula

x³ − 3x + 1 = 0 has three real roots (about 1.532, 0.347 and −1.879), yet Cardano's formula puts the square root of a negative number inside its cube roots. Sixteenth-century algebraists called this the casus irreducibilis, and it has since been proved that no formula in real radicals can avoid it. It was this case that forced mathematicians to take imaginary numbers seriously: the imaginary parts cancel, but only after you work through them.

For such cubics the solver leads with trigonometric substitution. The triple-angle identity cos 3θ = 4cos³θ − 3cos θ has the same shape as a depressed cubic, so setting x = 2cos θ turns the equation into cos 3θ = −1/2 and gives the three real roots directly, with no complex arithmetic.

Things to check when the roots come out as decimals

  • Type 1/3, not 0.333. Fractions are read as exact rationals, which lets the solver use the rational root theorem and closed forms; 0.333 is a different equation.
  • If a quartic shows the Durand–Kerner method first, it has no rational roots and is neither biquadratic nor palindromic. The roots are iterative approximations.
  • A leading coefficient of 0 lowers the degree automatically. All zeros is an identity (every number is a solution); a lone nonzero constant has no solution.
  • On the graph, each crossing of the x-axis is a real root; a point where the curve just touches the axis is a repeated root.

Worked examples

A quadratic that factors

Input
1, −5, 6
Output
x = 3, 2 (factoring)

The discriminant 1 is a perfect square, so it factors as (x − 2)(x − 3) = 0.

Irrational roots in closed form

Input
2, 3, −1
Output
x = (−3 ± √17)/4

17 is not a square, so the quadratic formula is shown first.

Catastrophic cancellation

Input
1, 100000000, 1
Output
x = −1e-8, −100000000

The small root comes from c ÷ (a·x₁) = 1 ÷ (−10⁸), so it is −1 × 10⁻⁸ with no cancellation. The textbook formula would give about −7.45 × 10⁻⁹.

The casus irreducibilis

Input
1, 0, −3, 1
Output
x ≈ 1.532089, −1.879385, 0.347296

Trigonometric substitution is listed first; Cardano's formula follows as the alternative.

A quartic that needs numerics

Input
1, 0, 0, 1, −1
Output
x ≈ 0.724492, −1.220744, 0.248126 ± 1.033982i

Two real roots and a complex-conjugate pair, found by Durand–Kerner.

Pure cubic

Input
1, 0, 0, −2
Output
x = ∛2, ∛2·(−1/2 ± (√3/2)i)

Solved by taking the cube root directly; the complex pair is ∛2 times the other cube roots of unity.

How to use it

  1. Choose the degree and enter coefficients from the highest power down to the constant; use 0 for missing terms.
  2. Fractions such as 1/3 and expressions with √ or π can be typed as they are.
  3. Read the roots, then the recommended method, the alternatives and the graph.

Frequently asked questions

Why can't it solve a quintic?

There is no general formula in radicals for degree five or higher (Abel–Ruffini). Such equations must be solved numerically, and this tool accepts degree four at most.

Does it give complex roots?

Yes. Non-real roots are shown as a ± bi pairs, and the real and complex roots are counted separately.

Can I get an exact answer instead of a decimal?

Enter coefficients exactly (fractions, √) and the solver returns closed forms such as √2/2 where it can. Roots from the numerical method are approximations.

Can I trust the small root when the coefficients differ hugely?

Yes. The textbook quadratic formula loses the small root to cancellation, but this solver computes the large root first and then small root = c ÷ (a × large root). Very small roots are shown in exponent notation, such as −1e-8.

Why does the cubic formula show imaginary numbers when all roots are real?

That is the casus irreducibilis. Use the trigonometric solution the tool shows first; it stays in real numbers.

Sources

Last reviewed:

Privacy and how data is handled