# How to complete the square?

Completes the square of ax² + bx + c to a(x − h)² + k and solves ax² + bx + c = 0 by completing the square, with each step and exact, simplified roots.

- Page: https://www.acalculator.org/math/complete-the-square-calculator
- JSON spec: https://www.acalculator.org/math/complete-the-square-calculator.json
- Version: 53e46d6b13a0

## Default answer

Example with the default inputs (a 1, b −3, c −5): Completing the square gives (x − 3/2)² − 29/4. Solutions: x = 3/2 ± √29/2 ≈ −1.192582404 and 4.192582404.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| a | a | The coefficient of x². It may not be 0. |
| b | b | The coefficient of x. |
| c | c | The constant term. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| form | Completed square | ax² + bx + c written as a(x − h)² + k. |
| solutions | Solutions of ax² + bx + c = 0 | x = h ± √q, exact and simplified, then as decimals. |
| h | h | h = −b ÷ (2a), as a decimal. |
| k | k | k = c − b² ÷ (4a), as a decimal. |
| square | Square to add | The square of half the x coefficient after dividing by a: (b ÷ (2a))². |
| steps | Steps | Each step of completing the square. |

## Method

Divide by a, move c/a across, add (b/(2a))² to both sides, write (x − h)² = q with h = −b/(2a) and q = (b² − 4ac)/(4a²), then x = h ± √q; a(x − h)² + k with k = c − b²/(4a).

## Assumptions

- a may not be 0. Coefficients are read as the exact decimals typed, so h, k and q are exact fractions.
- √q is simplified exactly when q’s top times its bottom is at most 10¹⁵.

## Worked examples

1. a = 1, b = -3, c = -5 gives form = (x − 3/2)² − 29/4, solutions = x = 3/2 ± √29/2 ≈ −1.192582404 and 4.192582404, square = 9/4, steps = Move the constant: x² − 3x = 5; Add (−3/2)² = 9/4 to both sides: x² − 3x + 9/4 = 29/4; Write the left side as a square: (x − 3/2)² = 29/4; Take the square root: x − 3/2 = ± √29/2; x = 3/2 ± √29/2 ≈ −1.192582404 and 4.192582404. Source: OpenStax, Algebra and Trigonometry 2e, §2.5 Quadratic Equations, Example 8 (x² − 3x − 5 = 0 gives x = 3/2 ± √29/2), https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-5-quadratic-equations.
2. a = 1, b = 4, c = 1 gives form = (x + 2)² − 3, solutions = x = −2 ± √3 ≈ −3.732050808 and −0.2679491924. Source: OpenStax, Algebra and Trigonometry 2e, §2.5 Quadratic Equations, completing the square (x² + 4x + 1 = 0 gives (x + 2)² = 3 and x = −2 ± √3), https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-5-quadratic-equations.
3. a = 1, b = -6, c = -13 gives form = (x − 3)² − 22, solutions = x = 3 ± √22 ≈ −1.69041576 and 7.69041576. Source: OpenStax, Algebra and Trigonometry 2e, §2.5 Quadratic Equations, Try It #7 (x² − 6x = 13), https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-5-quadratic-equations.
4. a = 2, b = -6, c = 7 gives form = 2(x − 3/2)² + 5/2, h = 1.5, k = 2.5, solutions = No real solution; complex: x = 3/2 ± (√5/2)i, steps = Divide by a = 2: x² − 3x + 7/2 = 0; Move the constant: x² − 3x = −7/2; Add (−3/2)² = 9/4 to both sides: x² − 3x + 9/4 = −5/4; Write the left side as a square: (x − 3/2)² = −5/4; Take the square root: x − 3/2 = ± (√5/2)i; x = 3/2 ± (√5/2)i. Source: OpenStax, Algebra and Trigonometry 2e, §5.1 Quadratic Functions, Example 3 (f(x) = 2x² − 6x + 7 = 2(x − 3/2)² + 5/2), https://openstax.org/books/algebra-and-trigonometry-2e/pages/5-1-quadratic-functions.
5. a = -0.5, b = 2, c = 6 gives form = −(1/2)(x − 2)² + 8, solutions = x = −2 and x = 6, k = 8.

## FAQ

### How do I complete the square?

For x² + bx + c = 0: move c to the right side, add (b/2)² to both sides, and write the left side as (x + b/2)². For x² − 3x − 5 = 0: x² − 3x = 5, add 9/4, (x − 3/2)² = 29/4.

### What if the x² coefficient is not 1?

Divide every term by a first. 2x² − 6x + 7 = 0 becomes x² − 3x + 7/2 = 0, then complete the square as usual. For the form a(x − h)² + k, multiply back by a: 2(x − 3/2)² + 5/2.

### How do I get the solutions after completing the square?

Take the square root of both sides, with ±. From (x − 3/2)² = 29/4, x − 3/2 = ±√29/2, so x = 3/2 ± √29/2.

### What if the number on the right is negative?

A real square cannot be negative, so the equation has no real solution. The calculator gives the complex solutions with i = √−1: (x − 3/2)² = −5/4 gives x = 3/2 ± (√5/2)i.

### How is completing the square related to the vertex?

a(x − h)² + k is the vertex form: the vertex of y = ax² + bx + c is (h, k), with h = −b ÷ (2a) and k = c − b² ÷ (4a).

### How is it related to the quadratic formula?

Completing the square on ax² + bx + c = 0 in general gives (x + b/(2a))² = (b² − 4ac)/(4a²), which leads straight to the quadratic formula x = (−b ± √(b² − 4ac)) ÷ (2a).

## Sources

- OpenStax, Algebra and Trigonometry 2e, §2.5 Quadratic Equations (completing the square: move the constant, add (b/2)² to both sides, factor the perfect square, use the square root property; Example 8: x² − 3x − 5 = 0 gives x = 3/2 ± √29/2; x² + 4x + 1 = 0 gives x = −2 ± √3; Try It #7: x² − 6x = 13). https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-5-quadratic-equations (retrieved 2026-10-05)
- OpenStax, Algebra and Trigonometry 2e, §5.1 Quadratic Functions (f(x) = a(x − h)² + k with h = −b/(2a); Example 3: 2x² − 6x + 7 = 2(x − 3/2)² + 5/2). https://openstax.org/books/algebra-and-trigonometry-2e/pages/5-1-quadratic-functions (retrieved 2026-10-05)
