# Linear Algebra Least-Squares Polynomial Fit

> Linear Algebra Least-Squares Polynomial Fit is a paid API for AI agents from linear-algebra.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-29).

Fits a least-squares line or polynomial (degree 1–6) to up to 100 data points, returning coefficients, R-squared, residuals, and optional curve evaluation.

## Facts

- Endpoint: GET https://linear-algebra.x402tookit.com/least-squares?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-29
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/linear-algebra-least-squares-polynomial-fit-6b68bff3
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_GHwfxaPSs4PEkCDhbIi1f

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability linear-algebra-least-squares-polynomial-fit-6b68bff3
```

Example prompt: Fit a degree-2 polynomial to my data points x=[1,2,3,4,5] and y=[2.1,8.9,20.2,35.0,54.8], and evaluate the curve at x=6 — give me the coefficients, R-squared, and residuals.

## When to prefer this

Choose this endpoint when you need least-squares regression with polynomial degrees 1 through 6 on moderate-sized datasets (up to 100 points), and want a single-call solution that returns not just coefficients but also R-squared, residuals, RMSE, and an optional point evaluation. Prefer it over general-purpose compute endpoints when the output format (coefficients, fit statistics, conditioning notes) matches your downstream needs directly.

## Known failure modes

- Fewer data points than degree+1 causes underdetermined system error
- Mismatched x and y array lengths returns validation error
- Degree outside 1–6 range rejected
- More than 100 points exceeds limit
- Ill-conditioned data (e.g. duplicate x values) may return degraded flag or NaN coefficients
- Malformed JSON in x or y query params returns parse error

## How this service works

Least-squares line or polynomial fit (degree 1 to 6, up to 100 points) with coefficients, R-squared and residuals.

## Output

Returns a JSON object with the fitted polynomial coefficients (ordered from constant to highest degree), R-squared goodness-of-fit, slope and intercept (for degree-1), residuals array, RMSE, residual standard error, sum of squared residuals, fitted values at each input point, optional evaluated value at a requested x, number of points used, conditioning metadata (centering/scaling info), and any warnings or degraded-quality flags.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "x",
      "y"
     ],
     "properties": {
      "x": {
       "type": "string",
       "description": "x values, JSON like [1,2,3,4] or 1,2,3,4 (up to 100)"
      },
      "y": {
       "type": "string",
       "description": "y values, same count as x"
      },
      "at": {
       "type": "number",
       "description": "Optional x at which to evaluate the fitted curve"
      },
      "degree": {
       "type": "integer",
       "description": "Polynomial degree 1 to 6 (default 1 = straight line); needs at least degree+1 points"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "rmse": {
       "type": [
        "null",
        "number"
       ]
      },
      "slope": {
       "type": [
        "null",
        "number"
       ]
      },
      "degree": {
       "type": [
        "null",
        "number"
       ]
      },
      "fitted": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "number"
       }
      },
      "points": {
       "type": [
        "null",
        "number"
       ]
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "verdict": {
       "type": [
        "null",
        "string"
       ]
      },
      "degraded": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "rSquared": {
       "type": [
        "null",
        "number"
       ]
      },
      "intercept": {
       "type": [
        "null",
        "number"
       ]
      },
      "residuals": {
       "type"
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/linear-algebra-least-squares-polynomial-fit-6b68bff3/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from linear-algebra.x402tookit.com](https://www.zero.xyz/host/linear-algebra.x402tookit.com/llms.txt)
