ForHosting KIT · Math

Solving by completing the square

Solve a quadratic the classroom way: x² − 6x + 5 = 0 becomes (x − 3)² = 4, giving the roots 1 and 5. You also see the amount added to both sides and the completed square. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
A
1
B
-6
C
5
You get
Equation
x^2 - 6*x + 5 = 0
Monic equation
x^2 - 6*x + 5 = 0
Monic linear
-6
Monic constant
5

Solving a quadratic equation by completing the square is the classroom method that rewrites a times x squared plus b times x plus c equals zero as a translated perfect square equal to a constant, then takes real square roots. This calculator accepts the three finite coefficients a, b, and c, rejects a zero leading coefficient because the statement would no longer be quadratic, and rejects a negative right-hand side after the square is completed because those roots are complex rather than real. When the completed square is non-negative, the tool returns the ordered real roots together with the monic linear term, the added square, the completed-square identity, and a short formula you can print next to the answer. Classic checks include x squared minus six x plus five becoming the square of x minus three equals four with roots one and five, two x squared minus eight x plus six becoming the square of x minus two equals one with roots one and three, and x squared plus one failing as a complex pair.

How completing the square produces the real roots

Completing the square solves a times x squared plus b times x plus c equals zero by forcing the left-hand side into a translated square rather than by quoting the quadratic formula from memory. First the leading coefficient must be nonzero; if a is zero the statement is linear and this method does not apply. Divide every term by a so the equation becomes monic: x squared plus b over a times x plus c over a equals zero.

Move the constant to the right-hand side, leaving x squared plus b over a times x on the left. Half of that monic linear coefficient is b over two a; add the square of that half to both sides. The left-hand side is then the perfect square of x plus b over two a, and the right-hand side simplifies algebraically to b squared minus four a c, all over four a squared.

That right-hand side must be nonnegative for real roots. When it is strictly positive, two real roots appear as negative b over two a plus or minus the square root of the right-hand side. When it is exactly zero, the square collapses to a repeated real root at the vertex of the parabola.

The identities used are purely algebraic, so the same three numbers always produce the same completed-square string and the same ordered roots, with no random seeds, clocks, or network calls on the path.

Where a solve-by-completing-the-square calculator earns its keep

Secondary-school and college algebra courses teach completing the square before or alongside the quadratic formula, and they grade the method, not only the final numbers. A single trusted oracle that returns the monic form, the added square, the completed-square identity, and the ordered real roots speeds homework checks, tutoring demos, and answer-key generation without skipping the steps the rubric requires.

Exam generators need a deterministic tool that refuses complex pairs and a zero leading coefficient, so auto-graders can mark those items as no real solution or not quadratic instead of silently emitting empty lists. Curriculum authors building interactive lessons want the same shape for monic and non-monic leading coefficients, a repeated root when the right-hand side is zero, and an honest error when x squared plus one is entered.

Programming notebooks and interview screens often hide a complete-the-square rewrite inside a vertex or optimization problem, and engineers need the real roots from that rewrite rather than a formula dump that hides the translation. If you later need a vertex-form rewrite without solving, unrestricted complex roots, or integer factoring, treat those as separate search intents and landings rather than overloading this completing-the-square solver.

Classroom completing-the-square drills

Show the monic equation, the added square (b/(2a))², and (x + b/(2a))² = rhs so learners can verify each algebraic step, not only the final pair of roots.

How is this different from the quadratic formula or a vertex-form rewrite?

This page solves for real roots by completing the square and shows the completed-square identity. A vertex-form calculator rewrites a(x−h)²+k without solving; the quadratic formula is a different method and may return complex pairs.

How do I solve x² − 6x + 5 = 0 by completing the square?

Move the 5 to the right, then add 9, the square of half of −6, to both sides. You get (x − 3)² = 4, so x − 3 is plus or minus 2 and the roots are 1 and 5.

What if the coefficient of x² is not 1?

Divide every term by it first so the equation starts with a plain x². For 2x² − 8x + 6 = 0 that gives x² − 4x + 3 = 0, which completes to (x − 2)² = 1, with roots 1 and 3.

What if the equation has no real roots?

If the right-hand side is negative once the square is completed, the roots are complex and the calculator tells you so instead of inventing them. The equation x² + 1 = 0 is the textbook case.

What happens when both roots are the same?

When the right-hand side after completing the square is exactly zero, the square collapses to a single repeated real root. That root sits at the vertex of the parabola, where the curve just touches the x-axis.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/math/solving-by-completing-the-square

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/math/solving-by-completing-the-square \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":1,"b":-6,"c":5}'
{
  "a": 1,
  "b": -6,
  "c": 5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.solving_by_completing_the_square",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

How completing the square produces the real roots

When it is negative, the square root is not real and this calculator reports invalid_input instead of inventing a complex conjugate pair.

Input contract, response shape, and error behaviour

Example: a equals one, b equals negative six, c equals five yields roots one and five. POST a JSON body with three required finite numbers: a, the nonzero leading coefficient; b, the linear coefficient; and c, the constant term of a x squared plus b x plus c equals zero. Each field may arrive as a JSON number or as a numeric decimal string; missing fields, empty strings, booleans, objects, and non-finite values fail with invalid_input naming the field and are not charged. On success the body echoes a, b, and c; printable equation and monic_equation strings; method completing_the_square; the monic linear and constant coefficients after dividing by a; half_linear equal to b over two a; complete_add, the square that was added; rhs, the nonnegative right-hand side; a completed_square identity such as open parenthesis x minus three close parenthesis squared equals four; the discriminant; root_count; roots sorted ascending and rounded to twelve decimal places for stable goldens; and a short formula restating the method. Pair the response with your own graphing code if you need a sketch of the parabola; this endpoint solves for real x only. Successful API calls use the published base of $0.002 per item.

Where a solve-by-completing-the-square calculator earns its keep

Because this capability is a pure parse engine, the browser tool is free and API pricing is the published base of $0.002 per successful item; failed validation does not consume prepaid balance.

Homework and exam answer keys

Check textbook ax²+bx+c=0 sets against the completed-square identity and the ordered real roots, or catch items that are not quadratic or have no real solution.

LMS auto-grading of method and domain

Accept completing-the-square answers only when real roots exist; reject a = 0 and complex cases as invalid_input instead of inventing a conjugate pair.

How do I solve a quadratic by completing the square with this calculator?

Send finite numbers a (nonzero), b, and c for ax²+bx+c=0. The API divides by a, adds (b/(2a))², and returns the real roots from x = −b/(2a) ± √(rhs) when rhs is nonnegative.

What happens if the roots are complex?

The task fails with invalid_input. After completing the square the right-hand side would be negative, so there are no real roots and the call is not billed.

Why must a be non-zero?

If a is zero, ax²+bx+c=0 is not a quadratic. Completing the square is the wrong tool; the solver rejects a = 0 so it never pretends a linear equation is quadratic.

What does the solving-by-completing-the-square calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →