Home/Tools/polynomial_division

Polynomial division

Divide one polynomial by another and return quotient and remainder.

Endpoint: POST /api/v1/polynomial_division

When to use

Long-divide one polynomial by another. Quotient `q` and remainder `r` satisfy `dividend = q·divisor + r`.

Input schema

Validated server-side with Zod. The same schema feeds OpenAPI and the MCP tool list.

{
  "type": "object",
  "properties": {
    "dividend": {
      "type": "string",
      "minLength": 1
    },
    "divisor": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "dividend",
    "divisor"
  ],
  "additionalProperties": false
}

Response shape

All tools return { ok: true, result } on success and { ok: false, error } on failure. The result object contains:

FieldTypeDescription
quotientstringPolynomial quotient.
remainderstringPolynomial remainder (degree < divisor).

Example

Request

{
  "dividend": "x^3 - 1",
  "divisor": "x - 1"
}

Response

{
  "ok": true,
  "result": {
    "quotient": "1+x+x^2",
    "remainder": "0"
  }
}

curl

curl -X POST https://tools.aieo.se/api/v1/polynomial_division \
  -H 'Content-Type: application/json' \
  -d '{"dividend":"x^3 - 1","divisor":"x - 1"}'

MCP call (JSON-RPC)

MCP clients call this tool as tools/call against /api/mcp:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "polynomial_division",
    "arguments": {
      "dividend": "x^3 - 1",
      "divisor": "x - 1"
    }
  }
}

Common errors

  • Divisor is zero or non-polynomial.
    Nerdamer throws.
  • A required field is missing or has the wrong type.
    Zod validation error, e.g. `Required` or `Expected string, received number`.
  • Nerdamer cannot parse the expression (unbalanced parens, unknown function, stray characters).
    `Unexpected token …` or `… is not a valid expression`.