Polynomial root finder

All real and complex roots of a polynomial up to degree 6, such as a cubic or quartic equation, with repeated roots found exactly and 30-digit accuracy.

Drafted with AI writing toolsUpdated Checked examples: 7

1, -6, 11, -6 means x³ − 6x² + 11x − 6. Include zeros for missing powers.
Try
Roots
1, 2, 3
Roots: 1, 2, 3
Real roots (counted with multiplicity)
3
Largest real root
3
Smallest real root
1
Degree
3

This degree-3 polynomial has 3 real roots and 0 non-real complex roots (counting multiplicity).

p(x) = x³ − 6x² + 11x − 6; xₖ denotes root k in the table.

-2-1012123xp(x)x₁x₂x₃

Complex plane: zₖ denotes root k in the table; dashed circle: unit circle

ReImz₁z₂z₃
Roots Rows: 3
#Real partImaginary partMultiplicity|p(root)|
11010
22010
33010
How it's calculated S
  1. Polynomial

    p(x)=x3−6x2+11x−6p(x) = x^{3} - 6x^{2} + 11x - 6
  2. Durand–Kerner iteration

    zk←zk−p(zk)∏j≠k(zk−zj)z_k \leftarrow z_k - \frac{p(z_k)}{\prod_{j \ne k}(z_k - z_j)}

    Started from powers of 0.4 + 0.9i scaled by the Cauchy bound; ran 12 sweeps, then Newton polishing. Every correction met the 10⁻³⁰ relative tolerance.

  3. Exact rational roots

    x=1,x=2,x=3x = 1,\quad x = 2,\quad x = 3

    Each was confirmed by substituting the fraction into p(x) and getting exactly 0.

  4. Check with Vieta's formulas

    ∑zk=6=−an−1an=6,∏zk=6=(−1)na0an=6\sum z_k = 6 = -\tfrac{a_{n-1}}{a_n} = 6,\qquad \prod z_k = 6 = (-1)^{n}\tfrac{a_0}{a_n} = 6

About the polynomial root finder

A polynomial of degree n has exactly n roots among the complex numbers, counted with multiplicity; this is the fundamental theorem of algebra. The calculator first splits off repeated factors exactly with Yun's square-free algorithm, then finds all remaining roots at once with the Durand–Kerner (Weierstrass) iteration, which refines n guesses together until each correction is below 10⁻³⁰ of the root. Rational roots are confirmed by exact substitution.

Cubic and quartic equations from engineering, physics and algebra courses are typical inputs. The default, 1, −6, 11, −6, is x³ − 6x² + 11x − 6 = (x − 1)(x − 2)(x − 3), so the roots are 1, 2 and 3; they sum to 6 and multiply to 6, as Vieta's formulas require.

Enter coefficients from the highest power down, with zeros for missing powers: x³ − 2 is 1, 0, 0, −2. Degrees 1 to 6 are accepted.

How to find the roots of a polynomial

Set the polynomial equal to zero and list its coefficients from the highest power down, writing 0 for any missing power. x³ − 6x² + 11x − 6 becomes 1, -6, 11, -6, and its roots are 1, 2 and 3. A polynomial of degree n has n roots once complex and repeated roots are counted.

How to write the coefficient list

  • Highest power first. 1, -6, 11, -6 means x³ − 6x² + 11x − 6, and the sign belongs to its coefficient.
  • A zero for every missing power. x³ − 2 is 1, 0, 0, -2, and x⁴ − 1 is 1, 0, 0, 0, -1. Leaving out a zero describes a different polynomial.
  • Everything on one side. x³ = 2 becomes x³ − 2 = 0 before you read off the coefficients.
  • Products multiplied out. (x − 1)(x − 2) is x² − 3x + 2, entered as 1, -3, 2.
  • Degree 1 to 6. That means 2 to 7 coefficients. Fractions and expressions such as 1/2 or sqrt(2) work as coefficients.

Worked examples

PolynomialCoefficients, highest power firstRoots
2x − 32, -33/2
x² + 11, 0, 1±i
x³ − 6x² + 11x − 61, -6, 11, -61, 2, 3
(x − 1)³(x + 2)1, -1, -3, 5, -2−2, 1 (×3)
x⁴ − 11, 0, 0, 0, -1−1, 1, ±i

Check a root by substituting it. For the cubic at x = 2, 8 − 24 + 22 − 6 = 0. Vieta's formulas give a second check: the roots 1, 2 and 3 add to 6 and multiply to 6, matching the coefficients.

x⁴ − 1 has four roots but only two real ones, 1 and −1. The graph of a polynomial crosses the x-axis only at real roots, so the pair ±i never shows on it.

How to express a polynomial as a product of linear factors

Each root r gives a factor (x − r). Keep the leading coefficient a and repeat each factor by its multiplicity m: p(x) = a(x − r₁)^m₁ … (x − rₖ)^mₖ. The multiplicities add up to the degree.

So x³ − 6x² + 11x − 6 = (x − 1)(x − 2)(x − 3). For 2x − 3 the root is 3/2 and the product is 2(x − 3/2), since dropping the 2 changes the polynomial. (x + 2)(x − 1)³ multiplies back to x⁴ − x³ − 3x² + 5x − 2.

Over the complex numbers, x² + 1 = (x − i)(x + i). If every factor must have real coefficients, keep x² + 1 as a quadratic factor: x⁴ − 1 = (x − 1)(x + 1)(x² + 1).

The answer lists roots, so you write the product from them. Exact rational roots give exact factors. A rounded root such as 1.25992105 gives an approximate factor; check a guessed fraction in the original polynomial before using it.

The OpenStax lesson on zeros of polynomial functions explains the factor theorem behind this.

Multiplicity and repeated roots

A root of multiplicity 3 appears three times in the factored form. (x − 1)³(x + 2) has two distinct real roots but four real roots counted with multiplicity, which is why its roots read −2, 1 (×3).

Multiplicity shows on a graph. At a root of odd multiplicity the curve crosses the x-axis; at even multiplicity it touches the axis and turns back. x³ − 3x + 2 = (x − 1)²(x + 2) touches at 1 and crosses at −2.

How the roots are computed

Repeated factors are split off first, exactly, by Yun's square-free algorithm in rational arithmetic, so repeated roots keep full accuracy.

The Durand–Kerner (Weierstrass) iteration then refines all remaining roots together until each correction is below 10⁻³⁰ of the root. If the iteration limit comes first, a warning says the last digits may be off.

Newton steps polish each root, and a rational root is confirmed by exact substitution, which is why 2x − 3 gives exactly 3/2.

Each root's residual |p(root)| is a consistency check, not a bound on its error. Scaling every coefficient changes the residual, and nearly repeated roots can shift a lot when a coefficient changes slightly.

Coefficients must lie between 10⁻⁴⁰ and 10⁴⁰ in size, and leading zeros are dropped. A constant has no roots, and the zero polynomial has every x as a root, so neither gives a root list.

For a single quadratic with the formula worked out, use the quadratic calculator. To do arithmetic with complex roots, use the complex number calculator. For several linear equations in several unknowns, use the linear-system solver.

Worked examples

x³ − 6x² + 11x − 6

Coefficients, highest power first
1, -6, 11, -6
Roots
1, 2, 3
Real roots (counted with multiplicity)
3
Largest real root
3
Smallest real root
1

Checked against: (x − 1)(x − 2)(x − 3) expanded by hand

x³ − 2 (one real, two complex)

Coefficients, highest power first
1, 0, 0, -2
Roots
1.25992105, −0.6299605249 ± 1.091123636i
Real roots (counted with multiplicity)
1
Largest real root
1.2599210499

Checked against: 2^(1/3) and 2^(1/3)·(−1/2 ± i√3/2)

x⁴ − 1

Coefficients, highest power first
1, 0, 0, 0, -1
Roots
−1, 1, ±i
Real roots (counted with multiplicity)
2

Checked against: Fourth roots of unity: ±1, ±i

Repeated root (x − 1)³(x + 2)

Coefficients, highest power first
1, -1, -3, 5, -2
Roots
−2, 1 (×3)
Real roots (counted with multiplicity)
4
Smallest real root
-2

Checked against: (x − 1)³(x + 2) = x⁴ − x³ − 3x² + 5x − 2

Questions

How many roots does a polynomial have?

Exactly as many as its degree, counted with multiplicity, once complex roots are included; this is the fundamental theorem of algebra. x⁴ − 1 has four roots: −1, 1, i and −i. The number of real roots can be smaller: x³ − 2 has one real root, ∛2 ≈ 1.259921, and two complex ones. A root of multiplicity 3, such as x = 1 in (x − 1)³(x + 2), counts three times.

How do you solve a cubic equation?

Look for a rational root first. By the rational root theorem, any rational root p/q of a polynomial with integer coefficients has p dividing the constant term and q dividing the leading coefficient. For x³ − 6x² + 11x − 6, trying divisors of 6 finds x = 1, and dividing by (x − 1) leaves x² − 5x + 6 = (x − 2)(x − 3). Without a rational root, Cardano's formula or a numerical method is needed.

Is there a formula for the roots of a quintic?

No general formula using radicals exists for degree 5 or higher. The Abel–Ruffini theorem, proved by Abel in 1824, shows this, and Galois theory explains which equations can be solved that way. x⁵ − x − 1 is a standard example whose roots cannot be written with radicals. Numerical methods still find them: its only real root is about 1.167304.

What are Vieta's formulas?

They link the roots to the coefficients. For aₙxⁿ + aₙ₋₁xⁿ⁻¹ + … + a₀, the roots add up to −aₙ₋₁/aₙ and multiply to (−1)ⁿa₀/aₙ. For x³ − 6x² + 11x − 6 the roots 1, 2 and 3 sum to 6 and multiply to 6, matching −(−6)/1 and (−1)³ × (−6)/1. The calculator uses both as a check on the roots it finds.

Why do complex roots come in conjugate pairs?

When every coefficient is real, conjugating the equation p(z) = 0 gives p(z̄) = 0, so the conjugate of a root is also a root. x³ − 2 therefore has the pair −0.629961 ± 1.091124i alongside its real root. It follows that a polynomial of odd degree with real coefficients always has at least one real root.

About this calculator

zk←zk−p(zk)∏j≠k(zk−zj)z_k \leftarrow z_k - \frac{p(z_k)}{\prod_{j \ne k} (z_k - z_j)}

Sources

  1. Reinke, Schleicher & Stoll, The Weierstrass root finder is not generally convergent, arXiv:2004.04777, §3 eq. 3.1 — Weierstrass (Durand–Kerner) iteration
  2. D. Y. Y. Yun, On square-free decomposition algorithms, SYMSAC 1976

Checked against references

This calculator includes 7 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.

Put this calculator on your site

Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.

Height
Preview the embed

Keep the credit line. It is the only condition, and it is what keeps these calculators free.