Home/Tools/polynomial_gcd

Polynomial GCD

Greatest common divisor of two polynomials.

Endpoint: POST /api/v1/polynomial_gcd

When to use

Greatest common divisor of two univariate polynomials.

Input schema

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

{
  "type": "object",
  "properties": {
    "a": {
      "type": "string",
      "minLength": 1,
      "description": "First polynomial"
    },
    "b": {
      "type": "string",
      "minLength": 1,
      "description": "Second polynomial"
    }
  },
  "required": [
    "a",
    "b"
  ],
  "additionalProperties": false
}

Response shape

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

FieldTypeDescription
resultstringResulting expression in nerdamer syntax.

Example

Request

{
  "a": "x^2 - 1",
  "b": "x^2 - 2*x + 1"
}

Response

{
  "ok": true,
  "result": {
    "result": "-x+1"
  }
}

curl

curl -X POST https://tools.aieo.se/api/v1/polynomial_gcd \
  -H 'Content-Type: application/json' \
  -d '{"a":"x^2 - 1","b":"x^2 - 2*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_gcd",
    "arguments": {
      "a": "x^2 - 1",
      "b": "x^2 - 2*x + 1"
    }
  }
}

Common errors

  • 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`.