Cubic and Quartic Equation Solver


Find all real and complex roots of a cubic or quartic with real coefficients. Roots are approximate, include multiplicity and are checked by substitution.

Use consistent units. Enter numbers without thousands separators. Invalid input clears all results.

数値を入力:

4 cubic or 5 quartic coefficients. Include zeros for missing powers.

計算結果:

Inputs and results

Choose the matching mode, then read each field label and note. Results use the same length, time, currency or quantity units as the inputs unless a label says otherwise. A negative change means a decrease.

Formula

For a cubic, substitute x = y - b/(3a) to get y³+py+q=0, then use the real Cardano/trigonometric branches. For a quartic, x = y-b/(4a) gives y⁴+py²+qy+r. When q=0, solve the quadratic in y². Otherwise solve z³+2pz²+(p²-4r)z-q²=0 for positive z=s² and factor into two quadratics.

Worked example

x³-6x²+11x-6 = (x-1)(x-2)(x-3), so the roots are 1, 2 and 3. x⁴-5x²+4 = (x²-1)(x²-4) has roots -2, -1, 1 and 2.

Limits and edge cases

Exactly degree 3 or 4, real coefficients, each at most 1e6 in magnitude and normalized coefficient ratios at most 1e6. Leading zero is rejected. Nearly repeated roots can be sensitive. The solver rejects results with scaled substitution residual above 1e-7; a small residual is not a guarantee of forward accuracy for ill-conditioned polynomials. Decimal calculations use floating-point arithmetic; displayed values are rounded to 12 significant digits. This is an educational tool, not a guarantee about investments or physical systems.

FAQ

Why are there complex roots?

A real polynomial need not cross the real axis at every root; nonreal roots occur in conjugate pairs.

Why are some roots repeated?

Multiplicity is part of the solution. For example (x-1)^4 has four roots equal to 1.

Formula reference

Background mathematics. Explanation and examples on this page are independently written.