Quadratic equation solver
The discriminant decides everything: positive gives two real roots, zero gives one, negative gives a complex pair.
First root
3
- Second root
- 2
- Discriminant
- 1 Two distinct real roots
- Vertex x, and the real part of complex roots
- 2.5
- Imaginary part of the complex roots
- 0.5
- Vertex y
- -0.25
- Sum of the roots
- 5
- Product of the roots
- 6
Show the working
- a = 1
- b = -5
- c = 6
- Discriminant = -5^2 - 4*1*6 = 1
- has_real = 1 >= 0 ? 1 : 0 = 1
- root_disc = sqrt(abs(1)) = 1
- First root = 1 != 0 && 1 >= 0 ? (--5 + 1) / (2*1) : 0 = 3
- Second root = 1 != 0 && 1 >= 0 ? (--5 - 1) / (2*1) : 0 = 2
- Vertex x, and the real part of complex roots = 1 != 0 ? --5 / (2*1) : 0 = 2.5
- Imaginary part of the complex roots = 1 != 0 ? 1 / (2*1) : 0 = 0.5
- Vertex y = 1 != 0 ? 6 - -5^2/(4*1) : 0 = -0.25
- Sum of the roots = 1 != 0 ? --5/1 : 0 = 5
- Product of the roots = 1 != 0 ? 6/1 : 0 = 6
Values are shown to six significant figures here; the arithmetic itself runs on exact fractions and is only rounded where a number is printed.
Scenarios & local history
Compare a saved scenario
Recent calculations
The formula
- x = (-b +/- sqrt(b^2 - 4ac)) / 2a
- discriminant D = b^2 - 4ac
- vertex at x = -b/2a, y = c - b^2/4a
- sum of roots = -b/a, product of roots = c/a
When the discriminant is a perfect square the roots are exact rationals and appear as such, with no rounding at all.
When it is negative the two root fields read zero and the complex pair is real part plus or minus imaginary part.