Completing the square with worked steps
The completing the square with worked steps API takes the three coefficients of a quadratic expression — a, b and c in ax² + bx + c — and rewrites it in completed-square form, also called vertex form: a(x − h)² + k.
Run — free
It returns the vertex-form coefficients h and k, the vertex of the parabola, and the full sequence of worked steps that leads from the standard form to the vertex form: factoring out a, halving the x coefficient, adding and subtracting its square, and collapsing the perfect square trinomial. The whole rewrite is one deterministic pass of exact arithmetic — h = −b/(2a) and k = c − b²/(4a) — so the same coefficients always produce the same form and the same steps. Use it to teach the method, to check homework line by line, or to normalize quadratic terms in a larger pipeline.
What completing the square actually means
A quadratic written as ax² + bx + c tells you its shape only indirectly. The same expression rewritten as a(x − h)² + k tells you the two things most people actually want at a glance: where the parabola's vertex sits, at the point (h, k), and whether it opens upward or downward, from the sign of a. The technique behind the rewrite — completing the square — takes the x² and x terms and adds and subtracts exactly the constant needed to turn them into a perfect square trinomial, which then collapses into the squared binomial. Nothing about the expression changes: substitute any value of x into either form and you get the same number. What changes is what you can read off directly. The coefficient a is carried through untouched, so the leading coefficient you send is the same one that multiplies the squared term in the answer. This endpoint performs the rearrangement symbolically over the three numeric coefficients and also reports each intermediate manipulation as a readable step, which means it works for integer, decimal and negative values alike, and it refuses the single degenerate case — a equal to zero — where the expression is really a line and the completed-square form has no meaning at all.
How the coefficients and the steps are computed
The two vertex-form parameters come from two closed-form identities. The horizontal shift is h = −b/(2a), which is exactly the x-coordinate of the parabola's axis of symmetry. The vertical shift is k = c − b²/(4a), the value the quadratic takes on that axis — equivalently, what you get by evaluating the original expression at x = h. Because these are exact formulas rather than an iterative search, the result is deterministic: run it twice on the same coefficients and you receive byte-identical output, which makes the response safe to cache, compare and embed in automated tests. The worked steps mirror the classroom procedure: factor a out of the x terms, take half of the resulting x coefficient, add and subtract its square inside the parentheses, then collapse the trinomial into the squared binomial and absorb the leftover constant into k. Each step is returned as a plain string so you can render the derivation line by line. Rounding is the only place where choice enters: by default the intermediate values, h and k are rounded to ten decimal places so the output is stable across machines and languages, and you can ask for anywhere between zero and fifteen places with the optional precision field. Exact integers stay integers at any precision. Coefficients may be sent as numbers or numeric strings, and every coefficient must be finite — Infinity and NaN are rejected with a clear error.
Where the worked form fits in practice
Completing the square is rarely the final goal; it is the step that unlocks the next one. It is the standard route to the quadratic formula, the fastest way to find a vertex without calculus, and the move that turns the equation of a circle or an ellipse into its center-radius form. Because this capability returns the worked steps alongside the result, it is especially useful in teaching products: you can show the factor-half-square-collapse sequence next to the answer so students see not just what the vertex form is but how it falls out of the original coefficients. In a homework-checking flow you can compare a student's intermediate line against the corresponding returned step instead of only marking the final answer right or wrong. In a graphics, physics or optimization pipeline the coefficients alone may be enough: fit ax² + bx + c to your samples, send the three numbers, and read the peak position h and peak value k directly off the response. The capability runs as pure arithmetic on our edge with nothing stored, and the same code runs free in your browser on this page — paste the three coefficients, watch the rewrite happen step by step, and pay only when you wire it into an automated flow at $0.002 per request.
What you can do with it
Show every step of the rewrite
Send a, b and c and get back the vertex form plus the factor-half-square-collapse sequence as readable lines, ready to render in a lesson or worked solution.
Check a student's work line by line
Compare each intermediate line of a handwritten completing-the-square solution against the corresponding returned step, not just the final answer.
Read off a vertex without calculus
The vertex of the parabola is simply (h, k): send the three coefficients and get the turning point and the extremum value as clean numbers.
FAQ
What does it cost?
$0.002 per request via the API. It is also free to run in your browser on this page.
What exactly does it return?
The coefficient a unchanged, the vertex-form coefficients h and k, the rewritten form as a string a(x−h)²+k, the vertex as an (x, y) point, and the worked steps of the rewrite as an array of strings.
Why does it reject a = 0?
Because with a zero leading coefficient the expression is linear, not quadratic, and the completed-square form is undefined — dividing by 2a would not make sense.
Can I send the coefficients as strings?
Yes. Numbers and numeric strings are both accepted, but every coefficient must be a finite number; Infinity and NaN are rejected.
Is anything stored?
No. The computation is pure arithmetic on the three coefficients you send; nothing is logged or kept.
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/math/completing-the-square-works \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"a":1,"b":6,"c":2}'const res = await fetch("https://api.kit.forhosting.com/math/completing-the-square-works", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"a": 1,
"b": 6,
"c": 2
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/completing-the-square-works",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"a": 1,
"b": 6,
"c": 2
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/completing-the-square-works", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"a":1,"b":6,"c":2}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"a":1,"b":6,"c":2}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/completing-the-square-works", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"a": 1,
"b": 6,
"c": 2
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.completing_the_square_works",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_abs_coeff | 1000000000000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |