# Trend Line Calculator (Linear Regression)

> Trend Line Calculator (Linear Regression) is a paid API for AI agents from x402.forgemesh.io, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-13).

Fits a least-squares straight trend line through x/y data pairs, returning slope, y-intercept, and R-squared fit quality for linear trend analysis.

## Facts

- Endpoint: POST https://x402.forgemesh.io/trend-line-calculator
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/trend-line-calculator-linear-regression-e650d9bc
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_IATsfozCH58KPV8NeUgBR

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 trend-line-calculator-linear-regression-e650d9bc -d '<json body>'
```

Example prompt: Fit a straight trend line through these data points and tell me the slope, y-intercept, and how good the linear fit is: x = [1, 2, 3, 4, 5] and y = [2.1, 3.9, 6.2, 8.0, 10.1].

## When to prefer this

Choose this endpoint when you need an exact, analytically computed linear regression with no sampling error on a set of numeric x/y pairs — especially when validating linearity (via R-squared) before making downstream decisions, detecting growth trends in time-series data, or forecasting the next value from a historical sequence. Prefer this over general-purpose ML or statistics APIs when you need a fast, cheap, precise result for simple linear trend fitting without standing up your own compute.

## Known failure modes

- Mismatched array lengths between x and y inputs — returns error
- Fewer than 2 data points provided — insufficient for regression
- Non-numeric values in input arrays — schema validation failure
- All x values identical — division by zero in slope calculation
- Payment failure or insufficient USDC balance — 402 response

## How this service works

Fits a straight trend line through a set of x/y data pairs and returns slope, y-intercept, and R-squared fit quality. Useful for spotting growth trends, forecasting next values from historical data, and validating whether a relationship is actually linear before an agent bases a decision on it. Computed exactly, with no sampling error.

## Output

Returns the slope (rate of change), y-intercept (value when x=0), and R-squared coefficient (0-1 fit quality) of the best-fit straight line through the provided x/y data pairs. R-squared close to 1 indicates a strong linear relationship.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "x": {
   "type": "array",
   "items": {
    "type": "number"
   }
  },
  "y": {
   "type": "array",
   "items": {
    "type": "number"
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "slope": 1.9,
  "equation": "y = 1.9x + -0.5",
  "intercept": -0.5,
  "r_squared": 0.966
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/trend-line-calculator-linear-regression-e650d9bc/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.forgemesh.io](https://www.zero.xyz/host/x402.forgemesh.io/llms.txt)
