Completing the Square Calculator
Convert a quadratic ax²+bx+c to vertex form a(x−h)²+k, find the vertex (h, k), and calculate real roots if they exist.
Did this tool work for you?
How to use this calculator
Completing the square rewrites the quadratic by creating a perfect square trinomial, revealing the vertex of the parabola directly.
- 1
Enter the coefficients a, b, and c from the quadratic equation ax²+bx+c.
- 2
The vertex form a(x−h)²+k is displayed, along with the vertex coordinates.
- 3
If real roots exist (discriminant ≥ 0), they are shown. The axis of symmetry is x = h.
Frequently asked questions
What does completing the square produce?
It rewrites ax² + bx + c as a(x − h)² + k, where h = −b ÷ 2a and k = c − b² ÷ 4a. The point (h, k) is the vertex of the parabola, and x = h is its axis of symmetry. For x² − 4x + 1 the calculator returns (x − 2)² − 3 with vertex (2, −3).
Why does a = 0 give an error?
With a = 0 the expression is linear, not quadratic, so it has no vertex and cannot be completed into a square. The calculator returns the message "Coefficient a cannot be zero (not a quadratic)".
How are the signs displayed in the vertex form?
The form is written as a(x − h)² + k, so a positive h shows as "x − h" and a negative h as "x + |h|". For 2x² + 8x + 3 the vertex form is 2(x + 2)² − 5, because h = −2. Coefficient 1 is omitted and −1 is written as a bare minus sign.
What does it show when the roots are not real?
It states "No real roots (complex)" and still gives the vertex form, the vertex and the discriminant, but does not print the complex values. For x² + 2x + 5 the discriminant is −16 and the roots are −1 ± 2i, which you can read from the vertex form (x + 1)² + 4 = 0.
How does it decide the discriminant is zero?
It compares b² − 4ac against zero with a tiny relative tolerance, so rounding noise in decimal inputs does not turn a repeated root into two nearly identical ones. For x² + 0.2x + 0.01 the result is a repeated root at −0.1.
How many decimals are shown?
Up to six, with trailing zeros removed. Roots such as 3.732051 and 0.267949 are rounded values of 2 ± √3, not exact. The vertex form is built from the rounded h and k.
Does the "Opens" line depend on anything other than a?
No, only the sign of a. Positive a opens upward with a minimum at the vertex, and negative a opens downward with a maximum. The size of b and c just moves the parabola around.
Is the vertex form unique?
Yes. For a given quadratic there is exactly one pair (h, k), so two different-looking answers to the same problem cannot both be correct vertex forms. The tool prints a single layout with the coefficient a in front, the sign of h inside the bracket and the sign of k outside.
Completing the square calculator — vertex form, vertex and roots
The algebra behind it
Start with ax² + bx + c. Factor a out of the first two terms, add and subtract (b ÷ 2a)² inside the bracket to form a perfect square, and simplify. The result is a(x + b ÷ 2a)² + (c − b² ÷ 4a). The calculator reports h = −b ÷ 2a and k = c − b² ÷ 4a, along with the discriminant b² − 4ac that says whether the parabola crosses the x-axis.
| Quantity | Formula | Meaning |
|---|---|---|
| h | −b ÷ 2a | x-coordinate of the vertex and the axis of symmetry |
| k | c − b² ÷ 4a | Minimum value (a > 0) or maximum value (a < 0) |
| Discriminant | b² − 4ac | Positive: two real roots. Zero: one. Negative: none |
| Real roots | (−b ± √D) ÷ 2a | Where the parabola meets the x-axis |
Worked examples
All results come from running the calculator.
| a, b, c | Vertex form | Vertex | Real roots |
|---|---|---|---|
| 1, −4, 1 | (x − 2)² − 3 | (2, −3) | 3.732051 and 0.267949 |
| 2, 8, 3 | 2(x + 2)² − 5 | (−2, −5) | −0.418861 and −3.581139 |
| −1, 6, −9 | −(x − 3)² + 0 | (3, 0) | repeated root at 3 |
| 1, 2, 5 | (x + 1)² + 4 | (−1, 4) | none |
| 3, −12, 7 | 3(x − 2)² − 5 | (2, −5) | 3.290994 and 0.709006 |
| 0.5, 3, 1 | 0.5(x + 3)² − 3.5 | (−3, −3.5) | −0.354249 and −5.645751 |
Walking through 2x² + 8x + 3
Here h = −8 ÷ 4 = −2 and k = 3 − 64 ÷ 8 = −5, so the vertex form is 2(x + 2)² − 5. Setting it equal to zero gives (x + 2)² = 5 ÷ 2, and the roots are −2 ± √2.5, which agree with the two values in the table. Because a is positive, the parabola opens upward and −5 is its lowest value.
Using the vertex for optimisation
The value k is the extreme value of the quadratic, so the vertex answers maximum and minimum problems directly. A downward parabola with a = −1, b = 6 and c = −9 peaks at (3, 0) and touches the x-axis exactly there, which is why it has a single repeated root. For an upward parabola with a negative k, such as the first row, the curve crosses the axis twice.
Cases the page does not expand
With a negative discriminant the page tells you there are no real roots but does not print the complex pair. For x² + 2x + 5, set (x + 1)² + 4 = 0 to get x = −1 ± 2i. Coefficients are plain numbers, so enter fractions as decimals; the six-decimal rounding makes exact values like 2 ± √3 approximate. For a quick sanity check, evaluate the original quadratic at x = h: the answer must equal k.
Learn more from an authoritative source:
WikipediaFOIL Method Calculator
Expand the product (ax+b)(cx+d) using the FOIL method with step-by-step working. Shows First, Outer, Inner, and Last terms separately.
Golden Ratio Calculator
Calculate all three values of a golden ratio division — short side a, long side b, and total length a+b — given any one of them. φ ≈ 1.6180339887.
Pascal's Triangle Calculator
Generate up to 20 rows of Pascal's Triangle and display the nCr (combination) values for any selected row.
Permutation & Combination Calculator
Calculate nPr (permutations) and nCr (combinations) with step-by-step factorial expansion. Supports n and r up to 20.
Fraction / Decimal / Percent Converter
Convert between fractions, decimals, and percentages in any direction. Six conversion modes in one tool.
Decimal to Fraction Calculator
Convert any decimal number to a simplified fraction in lowest terms, with step-by-step working. Handles terminating and long decimals.
Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →