Quadratic Equation Solver

Enter a, b and c for ax² + bx + c = 0. You'll get the roots (real or complex), the working, the factorised form, the vertex and a graph.

Coefficients

ax² + bx + c = 0
Examples:
The parabola y = ax² + bx + c, centred on its vertex

Solution

Roots
x₁ = 3, x₂ = 2
Δ > 0, so there are two different real roots

Working

Reading the result

The roots are the values of x that make the equation true, which are also where the parabola crosses the x-axis. The discriminant Δ = b² − 4ac decides what kind of answer you get before you even take the square root:

  • Δ > 0: two different real roots. The curve cuts the x-axis twice.
  • Δ = 0: one repeated root. The vertex sits exactly on the x-axis.
  • Δ < 0: no real roots. The curve never reaches the axis, and the solutions are a pair of complex numbers p ± qi.
Worked example

A ball is thrown upwards at 20 m/s from 1.5 m above the ground. Its height after t seconds is roughly h = −4.9t² + 20t + 1.5. When does it land?

Set h = 0, so a = −4.9, b = 20, c = 1.5. Then Δ = 20² − 4(−4.9)(1.5) = 400 + 29.4 = 429.4, and √Δ ≈ 20.722.

t = (−20 ± 20.722) / (−9.8) gives t ≈ 4.155 s or t ≈ −0.074 s. The negative answer is the moment the ball would have left the ground if it had been thrown from ground level, so it's discarded. The ball lands after about 4.16 seconds, and the vertex tells you it peaks at about 21.9 m after 2.04 s. Press the "Thrown ball" example above to see it.

Where the formula comes from

Start from ax² + bx + c = 0 and complete the square:

  1. Divide by a: x² + (b/a)x = −c/a
  2. Add (b/2a)² to both sides so the left becomes a perfect square: (x + b/2a)² = (b² − 4ac) / 4a²
  3. Take the square root of both sides: x + b/2a = ±√(b² − 4ac) / 2a
  4. Rearrange: x = (−b ± √(b² − 4ac)) / 2a

The same steps give you the vertex. The squared term is smallest (zero) when x = −b/2a, so that's the axis of symmetry, and substituting it back gives the turning value k = c − b²/4a.

Why this solver doesn't use the textbook formula directly

When b² is much larger than 4ac, √(b² − 4ac) is almost equal to |b|, and one of the two roots comes from subtracting two nearly equal numbers. In floating-point arithmetic that throws away most of the significant digits. For x² + 100000000x + 1 = 0, the textbook formula in double precision gives the small root as −7.45 × 10⁻⁹, which is 25% out. The true value is −1.00 × 10⁻⁸.

Kalkuli avoids this by computing the larger root first, using whichever sign avoids the subtraction, and then getting the other from the fact that the two roots multiply to c/a. Both roots then keep full precision. There's more on this kind of error in the precision guide.

Where quadratics turn up

  • Projectile motion: under constant gravity, height against time is a quadratic, so the roots are launch and landing times.
  • Area problems: a rectangle with perimeter 30 m and area 50 m² has sides satisfying x² − 15x + 50 = 0, so 10 m by 5 m.
  • Maximising revenue: if demand falls linearly with price, revenue is a downward parabola and the vertex gives the best price.
  • Optics: a parabolic dish reflects every ray parallel to its axis through a single focus, at distance 1/4a from the vertex.