Polynomial from roots calculator
Turn known roots into a polynomial in standard form: roots 1, 2 and 3 give (x − 1)(x − 2)(x − 3), which expands to x³ − 6x² + 11x − 6. List a root twice for a double root. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
A polynomial from roots calculator turns a list of real zeros into the expanded coefficient vector of a univariate polynomial. Enter roots r1 through rn and an optional non-zero leading coefficient a (default one for a monic polynomial). Multiplicity is encoded by repeating a root in the list.
From roots to coefficients: linear factors and expansion
Every non-zero univariate polynomial over the reals factors (up to a leading scale) into linear factors for its real roots and irreducible quadratics for complex conjugate pairs. Multiplying by a non-zero leading coefficient a scales every expanded coefficient uniformly and sets the highest-degree coefficient equal to a when the formal degree is n.
Multiplicity is not a separate field: list the same root twice for a double root, three times for a triple root, and so on, matching the way textbooks write (x minus two) squared as (x minus two) times (x minus two). Expansion proceeds by successive multiplies. Start from the constant one, replace the current coefficient list by its product with the next linear factor (x minus ri)—which is a shift-and-subtract convolution of length one—and after all roots are consumed scale by a.
The resulting sequence is stored constant term first so it lines up with sibling polynomial tools for addition, multiplication, and division. Formal degree is the highest index whose absolute value sits above a tiny epsilon, so floating dust does not inflate the reported degree. Classic checks include roots one and two with leading one yielding x squared minus three x plus two, roots one and negative one with leading two yielding two x squared minus two, and a single root zero yielding the monomial x.
Classroom, automation, and how this differs from root finders
Search intent for a polynomial from roots calculator is the inverse of a polynomial root finder: learners and scripts already know the zeros and need the expanded standard form, not the other way around. Exam generators sample integer roots, expand once, and store both the factored prompt and the coefficient answer key. Control and signal demos that place poles or zeros at design locations expand the characteristic polynomial the same way without importing a full computer-algebra dependency.
Prefer this capability when your source of truth is a root list; prefer the root-finder sibling when your source is already a coefficient vector. Keep root magnitudes and counts inside the published limits so successive multiplies cannot overflow. Round-trip checks are easy when all roots are real and listed with multiplicity: expand here, then feed coefficients to a root finder and compare recovered roots within the same rounding policy.
The landing targets people searching for polynomial from roots, build polynomial from zeros, expand linear factors to coefficients, and monic polynomial from roots online.
What you can do with it
Homework checks for expanding linear factors
Students enter known roots and optional leading coefficient, then compare hand-expanded coefficients and the standard-form string against a deterministic result before submitting.
Exam keys and LMS auto-grading
Generate monic or scaled polynomials from sampled root lists so graders hold stable coefficient answer keys without symbolic software.
FAQ
How do I build a polynomial from a list of roots?
Send roots as a non-empty array of finite numbers and optional leading (default 1).
How are coefficients ordered?
Constant term first: [a0, a1, a2] means a0 + a1·x + a2·x².
How do I encode a repeated root?
List the same value multiple times. A double root at 2 is roots [2, 2], which expands (x−2)².
What if leading is zero or roots is empty?
A zero leading coefficient would collapse degree; an empty root list is missing factor data, not a documented constant-only mode.
How do I set a leading coefficient other than 1?
Enter it as the leading coefficient and every expanded coefficient is scaled by it. With roots 1 and −1 and a leading coefficient of 2, the result is 2x² − 2 instead of x² − 1.
Related tools
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/algebra/polynomial-from-roots \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"roots":[1,2,3]}'const res = await fetch("https://api.kit.forhosting.com/algebra/polynomial-from-roots", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"roots": [
1,
2,
3
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/algebra/polynomial-from-roots",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"roots": [
1,
2,
3
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/algebra/polynomial-from-roots", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"roots":[1,2,3]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"roots":[1,2,3]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/algebra/polynomial-from-roots", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"roots": [
1,
2,
3
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "algebra.polynomial_from_roots",
"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.
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. |
Technical notes
Empty root lists and a zero leading coefficient fail with invalid_input instead of inventing a silent constant or a collapsed degree.
Input contract, response fields, and error behaviour
POST a JSON body with required roots, a non-empty array of at most sixty-four finite numbers, and optional leading (aliases a, leading_coefficient, scale) defaulting to one. Roots also accept aliases zeros, root_list, and r. Each root may arrive as a JSON number or as a strict numeric string; a JSON-encoded array string is accepted for clients that only send text fields. Absolute values must stay within one trillion so intermediate products remain finite in IEEE double precision on the Worker and in the browser. On success the body echoes rounded roots and leading, sets coefficients to the expanded list constant-first, coefficients_high_to_low to the same values reversed for textbook high-power-first displays, degree and root_count to integers, factors_str to a compact product of linear factors with the leading scale prefixed when it is not one, polynomial to a human-readable expanded form with sensible signs and omitted unit coefficients, formula to a short English identity, message to a one-line degree summary, and steps to ordered substitution lines for goldens and classroom screenshots. Failed validation—missing roots, empty arrays, non-arrays, non-finite entries, lists longer than the published maximum, values outside absolute limits, zero leading, or non-finite intermediate coefficients—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item.
Classroom, automation, and how this differs from root finders
Tutoring platforms use this endpoint so students can check hand expansions of (x minus three)(x plus one) against a deterministic coefficient list. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately send empty lists or a zero leading coefficient.
Integration use cases
Unit tests for student polynomial libraries
Produce known-good expansions of ∏(x−ri) plus empty-list and zero-leading rejections for coding kata fixtures and continuous integration.
Technical questions
What does the polynomial from roots calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.