Skip to content
Back to Calculators

Quadratic Formula Calculator

Solve ax² + bx + c = 0: real or complex roots, the discriminant, the formula steps and a graph of the parabola

Decimal (0.5) or fraction (1/2). If a is 0 the equation is linear.

A minus sign is allowed.

Use 0 if there is no constant term; a blank is an error.

The discriminant is computed exactly, and roots use a numerically stable form, so nearly cancelling values stay accurate. Nothing you enter is saved or sent.

Illustrative example shown: x² − 5x + 6 = 0. Enter your own coefficients and press Calculate.

Two real roots
2, 3
D > 0: two distinct real roots
Discriminant D = b² − 4ac
1
D > 0
Vertex
(2.5, -0.25)
opens up; axis x = x = 2.5

Roots

Roots of the equation with exact form, fraction and decimal
RootExact or roundedFractionDecimal
x₁2–2
x₂3–3

Factored form: (x − 2)(x − 3)

Graph of the parabola

-0.63.6-0.259.36
Orange dots: real roots (x-intercepts). Purple dot and dashed line: vertex and axis of symmetry.

The steps

  1. Equation: x² − 5x + 6 = 0, so a = 1, b = -5, c = 6.
  2. Discriminant: D = b² − 4ac = (-5)² − 4 × (1) × (6) = 1. It is computed exactly, so no tolerance is needed to decide its sign.
  3. D > 0, so there are two distinct real roots.
  4. Stable evaluation: q = −(b + sign(b) × √D) ÷ 2, then x₁ = q ÷ a and x₂ = c ÷ q. This avoids subtracting two nearly equal numbers, so a small root next to a very large one keeps its accuracy.
  5. √D = 1. The two roots are 2 and 3.

What the quadratic formula solves

A quadratic equation has the form ax² + bx + c = 0, where a, b and c are numbers and a is not zero. The quadratic formula gives every solution, called a root or zero, directly from the three coefficients: x = (−b ± √(b² − 4ac)) ÷ 2a. Type a, b and c above and the calculator returns the roots, the discriminant, the vertex of the parabola y = ax² + bx + c, the factored form when the roots are rational, a graph and the steps. Coefficients can be decimals or fractions such as 1/2.

The discriminant tells you what kind of roots to expect

The expression under the square root, D = b² − 4ac, is the discriminant. If D is positive there are two different real roots and the parabola crosses the x-axis twice. If D is zero there is one repeated real root and the parabola just touches the axis at its vertex. If D is negative there are no real roots: the two roots are complex conjugates and the parabola never reaches the axis. For x² − 5x + 6 = 0, D = 25 − 24 = 1, so there are two real roots: 2 and 3. For x² + 2x + 1 = 0, D = 0 and the single root is -1. For x² + 1 = 0, D = -4 and the roots are 0 ± 1i. The discriminant is computed exactly from the coefficients, with no tolerance, so a tiny positive or negative value is never mistaken for zero.

Where the formula comes from

The formula is the result of completing the square. Divide ax² + bx + c = 0 by a, move the constant across, add (b/2a)² to both sides to turn the left side into a perfect square, and take square roots. That leaves x + b/2a = ±√(b² − 4ac) ÷ 2a, which rearranges to the formula. The same working shows that the vertex of the parabola sits at x = −b/2a, halfway between the two roots when they exist. The calculator reports that vertex and the axis of symmetry x = −b/2a for every equation.

Irrational and fractional roots

When D is a perfect square of a rational number the roots are rational and are shown exactly, as a fraction and as a decimal. For 2x² − 3x − 2 = 0, D = 25 and the roots are -0.5 and 2, which factors as 2(x + 0.5)(x − 2). When D is not a perfect square the roots are irrational: for x² + x − 1 = 0, D = 5 and the roots are about -1.618033989 and about 0.6180339887. Those are the two numbers related to the golden ratio. The calculator keeps at least 50 digits of the square root internally and shows ten significant digits, marked "about".

Why the calculator does not use the textbook form blindly

In floating-point arithmetic the textbook formula can lose almost all of its accuracy. If b is large and 4ac is small, √(b² − 4ac) is very close to |b|, and subtracting two nearly equal numbers cancels most of the correct digits. For x² − 100,000,000x + 1 = 0 the small root is 1e-8 and the large root is 100000000, but a naive calculation can return 0 for the small one. The standard remedy, described in the numerical analysis literature, is to compute the larger-magnitude root with the sign that avoids cancellation, q = −(b + sign(b)√D) ÷ 2, then take x₁ = q ÷ a and x₂ = c ÷ q, using the fact that the product of the roots is c ÷ a. This calculator does exactly that, on exact rational values, so both roots are accurate.

Reading the graph

The graph plots y = ax² + bx + c across a window chosen to include both roots, the vertex and the y-intercept. Orange dots mark real roots, the purple dot and dashed line mark the vertex and axis of symmetry. A positive a opens the parabola upward, so the vertex is the minimum; a negative a opens it downward, so the vertex is the maximum. When the two roots are extremely far apart, such as in the example above, they cannot both be told apart at one scale, and the page says so and points you to the exact values in the table instead of drawing a misleading picture.

When a is zero, and other special cases

If a = 0 the equation is not quadratic. If b is not zero it is linear with the single solution x = −c ÷ b, and the calculator says so. If a and b are both zero the equation has either no solution (c is not zero) or every number as a solution (c is zero). If c = 0 the equation factors as x(ax + b) = 0, with one root at 0. If b = 0 the roots are ±√(−c ÷ a), real when c and a have opposite signs. Each of these cases is handled explicitly rather than ending in a division by zero.

Using the roots

Roots are the break-even points and turning behaviour in many models: the times a thrown object is at a given height, the quantities where profit changes sign, or the sizes where an area constraint is met. After solving, you may want to tidy the numbers. Use the rounding calculator to round a root to a chosen number of decimal places or significant figures, the fraction calculator to work with exact fractional roots, or the scientific notation calculator for very large or small coefficients.

For background on why subtracting nearly equal numbers loses accuracy, see David Goldberg's classic paper What Every Computer Scientist Should Know About Floating-Point Arithmetic, which discusses the quadratic formula as its example of cancellation.

Quadratic formula questions

What is the quadratic formula?

x = (−b ± √(b² − 4ac)) ÷ 2a. It gives the solutions of ax² + bx + c = 0 for any a that is not zero.

What does the discriminant mean?

It is b² − 4ac. Positive means two real roots, zero means one repeated real root, negative means two complex roots with no x-intercepts.

How do I solve a quadratic with a negative discriminant?

The roots are complex numbers: x = −b ÷ 2a ± i√(4ac − b²) ÷ 2a. For x² + 1 = 0 they are 0 ± 1i. The calculator shows both parts.

Can I enter fractions or decimals as coefficients?

Yes: use 0.5 or 1/2. Coefficients are read exactly, so 0.1 means one tenth and not a binary approximation.

What if a equals zero?

The equation is linear, not quadratic. The calculator solves x = −c ÷ b when b is not zero and explains the no-solution and every-number cases.

Why can one root look different from a calculator that uses the plain formula?

The plain formula can cancel digits when b² is much larger than 4ac. This calculator uses the stable form, so the small root keeps its accuracy.

Get New Free Calculators by Email

Get practical calculator walkthroughs and new tool updates by email. Occasional emails only, unsubscribe at any time.

No spam. See our privacy policy.