Quadratic equation

Classify the discriminant, then check the roots

Enter three dimensionless real coefficients for a·x²+b·x+c=0. If a=0, the same linear solver handles b·x+c=0. Otherwise, the discriminant is d=b²−4ac: a resolved zero gives one root of multiplicity 2; a negative value gives no real roots or a complex conjugate pair in Complex mode.

Standard arithmetic uses 64 significant decimal digits and scales the coefficients before forming the discriminant. A discriminant too close to cancellation is indeterminate. For positive d, exact rational roots use the quadratic formula. When approximation is needed and b and c are nonzero, the solver uses the coefficients after any scaling to form q=−(b+sign(b)×sqrt(d))/2, then q/a and c/q. Zero b or c uses a simpler branch; the steps identify the branch actually used.

Each root is substituted into the original equation. A zero exact residual or an accepted numerical residual is required before the root is reusable. A small residual alone does not guarantee small root error, especially near a repeated root.

Worked example: x²−3x+2=0

For a=1, b=−3 and c=2, d=(−3)²−4×1×2=1. The roots are (3−1)/2=1 and (3+1)/2=2. Both have multiplicity 1: 1−3+2=0 and 4−6+2=0.

For x²−2x+1=0, d=0 and x=1 has multiplicity 2. In Complex mode, x²+2x+5=0 gives −1−2i and −1+2i. For x²+10^30×x+1=0 in Standard arithmetic, the stable q branch retains the small root near −10^−30 alongside the root near −10^30.

Load example fills the form without calculating. Choose its primary action to work it out.

Sources and related calculators

The method and worked example here are original. Sources describe the underlying mathematics or notation; calculation choices and limits are in the precision and syntax guide.