Completing the Square Calculator
Rewrite a quadratic ax2 + bx + c into vertex form a(x - h)2 + k by completing the square. Choose whether you want the vertex form only, or go further to solve the equation for its roots - including complex roots when the discriminant is negative. Every step of the algebra is shown.
Formula
Worked example
For x2 - 6x + 5: a = 1, b = -6, c = 5. Then h = -(-6) / (2x1) = 3 and k = 5 - (-6)2 / (4x1) = 5 - 9 = -4. Vertex form: (x - 3)2 - 4, vertex (3, -4). Discriminant: 36 - 20 = 16 > 0, so two real roots: x = 3 +/- 2, giving x = 5 and x = 1.
What completing the square does
Completing the square rewrites a quadratic ax2 + bx + c as a perfect square plus a constant: a(x - h)2 + k. The trick works because (x - h)2 expands to x2 - 2hx + h2, so matching the linear term forces h = -b/(2a). Once you have the perfect square, k is whatever constant keeps the expression equal to the original: k = c - b2/(4a). This form is the most direct route to the vertex of a parabola and to deriving the quadratic formula itself.
Reading the vertex, axis of symmetry, and extreme value
In vertex form a(x - h)2 + k, the point (h, k) is the vertex and x = h is the axis of symmetry. When a is positive the parabola opens upward and k is the minimum value; when a is negative it opens downward and k is the maximum. The squared term (x - h)2 is never negative, so the function can never go below k (or above it when a is negative). That is why the vertex marks the turning point and why vertex form is ideal for graphing, optimization problems, and reading the range of a quadratic at a glance.
Solving for roots and the discriminant
Setting a(x - h)2 + k = 0 and solving gives x = h +/- sqrt(-k/a), which is the quadratic formula in disguise. The sign of the quantity inside the square root tells you everything about the roots before you calculate: when b2 - 4ac (the discriminant) is positive there are two distinct real roots on either side of the axis of symmetry; when it is zero the vertex sits exactly on the x-axis and there is one repeated root; when it is negative the parabola never crosses the x-axis and the roots are complex conjugates of the form h +/- sqrt(|disc|)/(2a) times i.
Complex roots and what they mean
When the discriminant is negative, the quadratic still has roots - they just require the imaginary unit i = sqrt(-1). A complex root of the form p + qi and its conjugate p - qi arise in conjugate pairs for real-coefficient quadratics. They appear in oscillation problems, control theory, and signal processing. Enabling the complex-roots mode in this calculator shows the exact values; the real part p equals the x-coordinate of the vertex h, and qi is the imaginary displacement.
Discriminant guide
| Discriminant | Number of real roots | Parabola behaviour | Root type |
|---|---|---|---|
| > 0 | 2 | Crosses x-axis twice | Two distinct real roots |
| = 0 | 1 | Touches x-axis once | One repeated real root |
| < 0 | 0 | Never crosses x-axis | Two complex conjugate roots |
The discriminant b2 - 4ac controls how many real roots the parabola has.
Frequently asked questions
Why must a not be zero?
If a is zero the x2 term disappears and the expression becomes a straight line bx + c, which has no vertex and cannot be written as a square. Completing the square only applies to genuine quadratics, so this calculator requires a non-zero a.
What if a is not 1?
The same formulas hold: h = -b/(2a) and k = c - b2/(4a). Internally you factor a out of the first two terms before completing the square, but the vertex and the final form a(x - h)2 + k come out directly from those two formulas regardless of a. The worked steps in this calculator show the division step explicitly when a is not 1.
How is this related to the quadratic formula?
The quadratic formula is what you get by completing the square on a general ax2 + bx + c = 0 and solving for x. That is why both share the term -b/(2a): it is h, the x-coordinate of the vertex and the midpoint between the two roots when they exist.
What does the discriminant tell me?
The discriminant is b2 - 4ac. When it is positive the equation has two distinct real solutions; when it is zero there is exactly one solution (a repeated root) at the vertex; when it is negative there are no real solutions and the roots are a pair of complex conjugate numbers. The sign of the discriminant is the fastest way to classify a quadratic before solving it fully.
How do I find the roots from vertex form?
Set a(x - h)2 + k = 0, then (x - h)2 = -k/a, then x - h = +/- sqrt(-k/a). So x = h + sqrt(-k/a) and x = h - sqrt(-k/a). When -k/a is negative (meaning a and k share the same sign) those square roots produce imaginary numbers - the complex-roots mode will show them.
Can I use this for equations not in standard form?
Yes. Expand and collect your equation into ax2 + bx + c = 0 first, then enter a, b, and c. For example, 2x2 = 4x - 3 becomes 2x2 - 4x + 3 = 0, so a = 2, b = -4, c = 3.