HOW IT WORKS
Quadratic formula, discriminant, and complex roots
Every quadratic equation in standard form ax² + bx + c = 0 (with a ≠ 0) has two solutions over the complex numbers given by the quadratic formula.
Discriminant (Δ = b² − 4ac)
If Δ > 0, there are two distinct real roots; if Δ = 0, one repeated real root; and if Δ < 0, two complex conjugate roots −b/(2a) ± i·√|Δ|/(2|a|).
Numerically Stable Evaluation
When Δ > 0 and b ≠ 0, we compute q = −0.5 × (b + sign(b)√Δ) and return q/a and c/q to avoid floating-point cancellation when 4ac is small.