Tools for agents: Exact polynomial interpolation

Recover an exact rational polynomial from sample points, with coefficients, residuals and evaluations.

Connect with MCP

{
  "mcpServers": {
    "super-agent-tools": {
      "url": "https://app.getsupers.com/sites/agent-polynomial-interpolation/mcp"
    }
  }
}
Streamable HTTP · No API key · Stateless

Use this URL in any client supporting remote Streamable HTTP MCP. Calls return structured JSON; inputs are processed without persistence.

Call interpolate_polynomial

Coefficients are ordered constant first: c[0] + c[1]*x + c[2]*x^2. The unique interpolating polynomial has degree below the number of distinct input x values. All numbers returned are exact fraction strings. JSON floats and booleans are rejected; quote decimal values. Equivalent duplicate x coordinates are rejected even when their y values agree. The zero polynomial has degree null and coefficients ["0"]. Residuals follow input point order; evaluations follow query order. Extrapolated flags identify queries outside the sample x range. This is exact interpolation, not noisy-data regression or a guarantee of predictive accuracy. Intended for small exact datasets. Arithmetic: https://docs.python.org/3/library/fractions.html

Input and output schemas
{
  "name": "interpolate_polynomial",
  "title": "Exact polynomial interpolation",
  "description": "Interpolate distinct rational (x,y) points; return ascending-power coefficients, exact residuals and evaluations. Integers or quoted rational/decimal strings only.",
  "inputSchema": {
    "properties": {
      "points": {
        "items": {
          "maxItems": 2,
          "minItems": 2,
          "prefixItems": [
            {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "string"
                }
              ]
            },
            {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "string"
                }
              ]
            }
          ],
          "type": "array"
        },
        "title": "Points",
        "type": "array"
      },
      "evaluate_at": {
        "items": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "string"
            }
          ]
        },
        "title": "Evaluate At",
        "type": "array"
      }
    },
    "required": [
      "points",
      "evaluate_at"
    ],
    "title": "interpolate_polynomialArguments",
    "type": "object"
  },
  "outputSchema": {
    "additionalProperties": true,
    "title": "interpolate_polynomialDictOutput",
    "type": "object"
  },
  "icons": null,
  "annotations": {
    "title": null,
    "readOnlyHint": true,
    "destructiveHint": false,
    "idempotentHint": true,
    "openWorldHint": false
  },
  "meta": null,
  "execution": null
}

Run the example to see the actual result.

HTTP alternative

POST https://app.getsupers.com/sites/agent-polynomial-interpolation/call
Content-Type: application/json

{
  "points": [
    [
      0,
      1
    ],
    [
      1,
      3
    ],
    [
      2,
      7
    ]
  ],
  "evaluate_at": [
    "1/2",
    3
  ]
}

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.

Exact samples determine a polynomial, not a forecast

Read the explanation

The saved example supplies three distinct sample coordinates: zero with value one, one with value three, and two with value seven. A polynomial of degree below three has three coefficient slots. Substituting zero fixes the constant at one. The other two equations give the linear and quadratic coefficients one each, so the polynomial is one plus x plus x squared. At eighty pixels per count, three samples and three coefficient slots each measure two hundred forty; degree two measures one hundred sixty. This derivation is exact arithmetic from the supplied fixture, not an executed backend response. At x equal to one half, the terms are one, one half and one quarter, giving seven fourths. At x equal to three they are one, three and nine, giving thirteen. At twenty pixels per value, the half query measures thirty five pixels and the three query two hundred sixty. The sample domain spans zero through two, so three is extrapolated while one half is inside. At the same scale the maximum sample coordinate two measures forty. Exact interpolation fits supplied samples; it does not establish that an extrapolated value predicts a real process. Substitution at zero, one and two returns one, three and seven, making all three mathematical residuals zero. At forty pixels per output value the bars measure forty, one hundred twenty and two hundred eighty. The saved contract rejects floating JSON numbers and booleans, accepts integers or quoted rational decimals, and rejects equivalent duplicate x values. Zero polynomial degree is null rather than an invented degree. The page exposes an HTTP and MCP interface, but the shared client asset is absent in this offline snapshot. We verify the native argument text and preserve layout without claiming an actual server call, structured result or copy operation.

Exact Rational Polynomial Interpolation for Agents

How does the interpolate_polynomial tool construct exact rational polynomials and evaluate query coordinates without floating-point error?

The interpolate_polynomial service implements Newton's divided difference algorithm to reconstruct the unique polynomial of minimal degree passing through distinct sample points. All arithmetic is carried out using exact rational fractions rather than IEEE-754 binary floating-point numbers. It outputs ascending monomial coefficients, exact sample residuals, and requested evaluations, flagging any query outside the minimum and maximum sample abscissae as extrapolated.

The solver requires strictly distinct x coordinates; duplicate or equivalent rational abscissae cause an immediate validation error. It performs exact interpolation rather than regression or curve smoothing, meaning it does not filter noise and can exhibit severe oscillation (Runge's phenomenon) when interpolating high-degree sets. Floating-point numbers and boolean values in input JSON are rejected to prevent precision loss.

Try a worked example

Submitting the default JSON arguments with sample points (0, 1), (1, 3), and (2, 7) and evaluation queries '1/2' and 3 sends a POST request that populates the structured result. The service returns ascending coefficients ['1', '1', '1'] corresponding to 1 + x + x², degree 2, exact zero residuals ['0', '0', '0'], and evaluations of '7/4' for x = '1/2' (extrapolated: false) and '13' for x = 3 (extrapolated: true).

Exact Rational Representation

The tool parses integer inputs and string representations of fractions or terminating decimals into Python Fraction instances, ensuring exact rational representation without binary floating-point approximations. fractions — Rational numbers — Python documentation

Newton Divided Differences and Monomial Expansion

The implementation computes divided differences in an in-place array to obtain the Newton basis coefficients. It then iteratively multiplies linear factors (x - x_i) to convert the polynomial into standard ascending monomial order, returning string representations of each coprime fraction.

Evaluations are calculated using Horner's method over exact rational fractions. Query coordinates outside the interval [min(xs), max(xs)] are explicitly marked with extrapolated set to true.

Sources and further reading