ScienForge

Quadratic equation solver

Solve ax² + bx + c = 0 with real or complex roots, and see the discriminant, vertex, axis of symmetry and Vieta's relations.

Solving 1x² + -3x + 2 = 0

Two distinct real roots
x = 2 and x = 1
Discriminant b² − 4ac1
Vertex(1.5, -0.25)
Axis of symmetryx = 1.5
Sum of roots3
Product of roots2
Opensupward

Any equation of the form ax² + bx + c = 0, with a ≠ 0, is solved by the quadratic formula. It is derived by completing the square on the general form, so it works for every case rather than only the ones that factorise cleanly.

x = ( −b ± √(b² − 4ac) ) / 2a

The discriminant tells you the answer before you compute it

The expression under the square root, Δ = b² − 4ac, decides the character of the solution:

  • Δ > 0 — two distinct real roots. The parabola crosses the x-axis twice.
  • Δ = 0 — one repeated root. The parabola touches the axis at its vertex.
  • Δ < 0 — two complex conjugate roots. The parabola never crosses the axis.

If a, b and c are integers and Δ is a perfect square, the roots are rational and the expression factorises over the integers. That is a fast way to check whether factoring is worth attempting.

Vieta’s relations

The roots are tied to the coefficients directly, without solving:

x₁ + x₂ = −b / a   x₁ · x₂ = c / a

These are useful both as a check on your arithmetic and as a shortcut in competition problems where you need a symmetric function of the roots but not the roots themselves.

The vertex

The parabola is symmetric about x = −b / 2a, which is the average of the two roots. Substituting back gives the vertex height. If a is positive the parabola opens upward and the vertex is a minimum; if a is negative it opens downward and the vertex is a maximum. This is the standard route to optimisation problems in introductory calculus courses, before derivatives are available.

A numerical trap worth knowing

When b² is much larger than 4ac, one of the two roots is computed as the difference of two nearly equal numbers, and floating-point precision collapses. The stable approach is to compute the well-conditioned root first:

q = −½ ( b + sign(b)·√(b² − 4ac) )  then  x₁ = q/a, x₂ = c/q

This matters in physics simulations and ray tracers, where a quadratic is solved millions of times with wildly different coefficient magnitudes.

Where quadratics turn up

  • Projectile height as a function of time, which is why time of flight is a quadratic solve.
  • Ray–sphere intersection in graphics: the discriminant tells you whether the ray hits.
  • Equilibrium concentrations in chemistry, where an ICE table produces a quadratic in x.
  • The characteristic equation of a second-order circuit or a mass–spring–damper system, where the discriminant separates overdamped, critically damped and underdamped behaviour.