Descartes rule of signs calculator
x² − 3x + 2 has 2 sign changes, so it has 2 or 0 positive real roots and no negative ones: enter the coefficients from the highest power down and get every possible count before you search for roots. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Coefficients
- 1, -3, 2
- Degree
- 2
- Polynomial
- x^2 - 3x + 2
- Positive sign changes
- 2
- Negative sign changes
- 0
Descartes' rule of signs is the classic first filter before you hunt polynomial roots: from the signs of the coefficients alone it bounds how many positive real roots and how many negative real roots a univariate polynomial can have. Students learn the rule in precalculus and algebra two; contest coaches use it to discard impossible root counts; notebook scripts use it as a cheap pre-check before numeric solvers. This Descartes rule of signs calculator accepts coefficients highest degree first, ignores zero middle terms when counting, builds the coefficient sequence of p of negative x for the negative-root side, and returns both sign-change totals plus the full lists of admissible counts (k, k minus two, down to zero or one).
What Descartes' rule of signs says about real roots
Scan the coefficient list from highest degree to constant and count every time consecutive non-zero coefficients change sign; call that count k. Descartes' rule states that the number of positive real roots of p, counted with multiplicity, is equal to k or is less than k by a positive even integer. In other words the admissible totals are k, k minus two, k minus four, and so on down to either zero or one depending on the parity of k.
Zero coefficients are skipped when scanning signs: a missing power does not create or destroy a change by itself. For negative real roots apply the same procedure to the polynomial q of x equals p of negative x. Expanding p of negative x multiplies each term of odd degree by minus one, which is exactly alternating the signs of the original coefficients from highest degree according to the parity of each power.
If that transformed sequence has m sign changes, the number of negative real roots is m or m minus two and so on. The rule never invents roots and never claims uniqueness: it only narrows the search space. Complex roots come in conjugate pairs for real coefficients, which is why the subtraction is always by an even number.
What you enter, what you get and worked examples
Middle zeros are fine and represent missing powers. Example: coefficients one, negative three, two for x squared minus three x plus two yields two positive sign changes so possible positive roots two or zero, and zero negative sign changes so possible negative roots only zero. Example: one, negative one, one, negative one for x cubed minus x squared plus x minus one yields three positive sign changes (three or one positive roots possible) and zero negative sign changes.
Empty arrays, non-finite entries, and a pure constant after stripping fail validation and are not billed. Pair the counts with the rational root theorem or a numeric solver when you need actual root values; this capability only answers the sign-change question.
Where the rule of signs saves time
Classrooms and tutoring platforms expose a Descartes rule of signs calculator so learners can check sign-change homework without flipping a sign by hand on p of negative x. Exam generators need a deterministic oracle that marks the even-subtraction list correct even when a student only wrote the maximum count. Engineering notebooks use the bound as a cheap preflight before calling a heavier polynomial root finder: if the rule allows zero positive roots, there is no need to scan the positive axis first.
Failed validation does not consume balance. Keep coefficient lists modest, pin the expected possible-root arrays in tests, and you get reproducible educational and automation answers without standing up a computer-algebra system for a sign-scan that textbooks have used for centuries.
What you can do with it
Classroom and homework checks
Let students submit coefficient lists and verify positive and negative sign-change counts plus the full admissible root-count lists against textbook methods.
Exam and LMS auto-grading
Mark Descartes-rule items with a deterministic oracle that accepts any even subtraction from the maximum sign-change total, not only the maximum itself.
Preflight before numeric root finding
Bound possible positive and negative real roots cheaply in notebooks and pipelines before running a full polynomial root solver.
FAQ
How are zero coefficients handled?
Middle zeros are skipped when counting sign changes (a missing power does not force a change). Leading zeros are stripped for degree; an all-zero list is rejected as invalid input.
Does this find the actual roots?
No. Descartes' rule only bounds how many positive and negative real roots are possible. Use a root finder or the rational root theorem when you need explicit values.
How does Descartes' rule of signs work?
Read the coefficients from the highest power down and count each switch between plus and minus, skipping zeros. For x² − 3x + 2 the signs go plus, minus, plus, so there are 2 changes and 2 or 0 positive roots.
Why does the possible count drop by two each time?
With real coefficients, complex roots come in conjugate pairs, so real roots can only disappear two at a time. The list therefore runs k, k − 2 and so on, down to 0 or 1.
How are negative roots counted?
Apply the same count to p(−x), which flips the sign of every odd-power term. For x² − 3x + 2 that gives x² + 3x + 2, with no sign changes, so there are no negative real roots.
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/descartes-rule-of-signs \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"coefficients":[1,-3,2]}'const res = await fetch("https://api.kit.forhosting.com/algebra/descartes-rule-of-signs", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"coefficients": [
1,
-3,
2
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/algebra/descartes-rule-of-signs",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"coefficients": [
1,
-3,
2
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/algebra/descartes-rule-of-signs", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"coefficients":[1,-3,2]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"coefficients":[1,-3,2]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/algebra/descartes-rule-of-signs", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"coefficients": [
1,
-3,
2
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "algebra.descartes_rule_of_signs",
"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
What Descartes' rule of signs says about real roots
Write a real univariate polynomial as p of x equals a_n x to the n plus a sub n minus one times x to the n minus one, down to the constant term a_0, with a_n not zero. This endpoint implements exactly that classical statement—no approximate root finding, no factoring, no floating-point Newton steps—so the answer is a finite discrete list of possible counts, not a guessed numerical zero.
Input contract, response shape, and worked examples
POST a JSON body with one required field, coefficients: a non-empty array of finite numbers highest degree first, degree at least one after any leading zeros are stripped. Aliases coeffs and poly are accepted. Leading coefficient after strip must be non-zero; the zero polynomial is rejected with invalid_input. Each entry may be a JSON number or a numeric string. On success the body echoes the cleaned coefficients and degree, a human-readable polynomial string, positive_sign_changes and negative_sign_changes as integers, possible_positive_roots and possible_negative_roots as descending arrays of admissible counts, the coefficients of p of negative x for auditability, and method set to descartes_rule_of_signs.
Technical questions
How does the Descartes rule of signs calculator work?
Send coefficients highest degree first. The API counts sign changes among non-zero terms for p(x) and for p(−x), then returns each count and the lists k, k−2, … of possible positive and negative real roots (with multiplicity).
What do possible_positive_roots and possible_negative_roots mean?
They are every non-negative integer equal to the sign-change count or less by an even number. For three sign changes the list is [3, 1]; for two it is [2, 0]. The true root count is one of those values, not necessarily the maximum.
What does the Descartes rule of signs calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.