Use this URL in any client supporting remote Streamable HTTP MCP. Calls return structured JSON; inputs are processed without persistence.
Call divide_polynomials
Coefficients are ordered by ascending power: [a0,a1,a2] means a0+a1*x+a2*x^2. Inputs are nonempty arrays of integers or quoted finite decimal/fraction strings; JSON floats and booleans are rejected. High-power trailing zeros are removed; every zero polynomial is represented as ["0"] with degree null. A zero divisor fails even when padded with zeros. Quotient and remainder satisfy dividend=divisor*quotient+remainder exactly, with remainder degree strictly below divisor degree unless remainder is zero. exact_division means a zero remainder, not that the quotient has integer coefficients. Constants and a dividend of lower degree are supported. This is algebra over rational coefficients in one formal variable; it does not evaluate expressions, factor polynomials, find roots or perform modular arithmetic.
The HTTP and MCP interfaces execute the same implementation. Validation errors are returned explicitly. See the tool notes above for its supported inputs and behavior.
Rational polynomial division: cancellation, remainder and exactness
Read the explanation
The saved polynomial-division input uses coefficients in ascending power order. Minus one, zero, zero, one represents x cubed minus one, not the reverse ordering. The divisor one, zero, two represents two x squared plus one. Long division starts with the highest remaining term: x cubed divided by two x squared gives one half x. Multiplying the entire divisor by that quotient term produces x cubed plus one half x. The connecting lines represent algebraic dependencies rather than measured magnitudes. This calculation uses the documented rational polynomial contract and saved input; the local preview does not execute the remote HTTP or MCP tool or claim an actual returned result. Subtracting x cubed plus one half x cancels the cubic term exactly, leaving minus one half x minus one. Its degree is one, strictly below the divisor degree two, so division stops. The quotient coefficients are zero and one half; the remainder coefficients are minus one and minus one half. Reconstruct the original: two x squared plus one, multiplied by one half x, plus minus one half x minus one, equals x cubed minus one. The nonzero remainder means exact division is false. Exact arithmetic and exact division are different: this result has exact rational coefficients even though there is a remainder. This derivation does not factor the polynomial, find its roots or evaluate a numerical expression. For a contrasting illustrative input, divide x by the constant two. The quotient is one half x and the remainder is zero, so exact division is true despite a fractional quotient. The tool accepts nonempty arrays of integers or quoted finite decimal and fraction strings; it rejects JSON floats and booleans. Trailing zeros at the high-power end are removed before degree is interpreted. A zero polynomial is represented as the single string zero with degree null, and an all-zero divisor fails even if it contains several padded zeros. When the dividend has lower degree than a nonzero divisor, the quotient is zero and the dividend itself is the remainder. The contract concerns one formal variable over rational coefficients, not modular arithmetic. Because the shared application script is absent offline, native input preservation can be checked here, while service execution remains unverified.
Exact Rational Polynomial Division Interface
How does the agent tool represent and compute exact polynomial quotient and remainder arrays over rational coefficients without floating-point error?
This tool implements deterministic univariate polynomial division over the field of rational numbers (Q[x]). Inputs and outputs represent polynomials as lists of coefficients indexed in ascending degree order (index k holds the coefficient of x^k). By using Python's exact rational Fraction arithmetic rather than binary floating-point numbers, it ensures that the division identity (dividend = divisor * quotient + remainder) holds exactly with remainder degree strictly less than divisor degree.
The tool operates strictly on univariate polynomials with rational coefficients in ascending degree order. It does not parse symbolic algebraic expressions, find roots, factor polynomials, or compute modular reductions over finite rings. Degree of the zero polynomial ["0"] is normalized to null rather than negative infinity, and non-rational or floating-point numbers are rejected.
Try a worked example
The default argument JSON sets dividend to [-1, 0, 0, 1] representing x^3 - 1, and divisor to [1, 0, 2] representing 2*x^2 + 1. Clicking 'Run tool' executes polynomial long division over Q: the leading term x^3 is divided by 2*x^2 to yield (1/2)*x (ascending quotient ["0", "1/2"]). Subtracting (1/2)*x*(2*x^2 + 1) = x^3 + (1/2)*x from x^3 - 1 leaves remainder -1 - (1/2)*x (ascending remainder ["-1", "-1/2"]). The structured result displays quotient ["0", "1/2"], remainder ["-1", "-1/2"], quotient_degree 1, remainder_degree 1, and exact_division false.
Ascending Coefficient Representation
Unlike standard textbook descending order (from highest degree to constant), this service mandates ascending order: index i corresponds to the coefficient of x^i. For instance, [c0, c1, c2] represents c0 + c1*x + c2*x^2. Trailing high-power zeros are stripped during parsing so that polynomials are uniquely represented, with ["0"] serving as the canonical zero polynomial.
Algorithmic Invariant and Termination
The division algorithm iteratively aligns the highest non-zero power of the current remainder with the leading coefficient of the divisor. At each iteration, the quotient term is computed as remainder[-1] / divisor[-1]. Subtracting this scaled monomial decreases the degree of the remainder by at least one, guaranteeing termination when the remainder degree is strictly less than the divisor degree or when the remainder becomes zero.