---
name: z87:solve
description: Computation engine: symbolic algebra, statistics, regression, finance, graph algorithms, Monte Carlo simulation. No stored data — send input, get computed results.
---

Anonymous: 600 tok/min. Key: `GET https://z87.ai/api/use` → `X-Api-Key` header, 6000 tok/min. On `429`, wait 1s.

Computation engine. Symbolic algebra, descriptive/inferential statistics, curve fitting, financial math, graph algorithms, Monte Carlo simulation.

## Algebra (POST JSON or GET)

Two input formats — use whichever is clearer:
- `expr` (infix): `"F = m * v^2 / r"`, `"v = u + a*t"`
- `sexp` (s-expression): `"(= F (/ (* m (^ v 2)) r))"`

/solve: solve single equation. /solve-system: system of equations. /rearrange: symbolic only. /simplify: expand + collect. /convert: unit conversion (GET).

Units in `known`: bare number (SI) or `[value, "unit"]`. Supports kg, g, m, km, cm, mm, nm, s, ms, A, K, degC, degF, mol, N, J, kJ, eV, W, kW, Pa, atm, bar, Hz, MHz, GHz, C, V, Ω, F, μF, T, H, Sv, rad, deg, L, m/s, km/h, mph, m/s^2, J/(kg K), bit, B, kB, MB, GB, TB, KiB, MiB, GiB, bps, Mbps, Gbps.

## Statistics (POST JSON)

/stats: POST `{"data": [numbers]}`. Full analysis: mean, median, stddev, variance, skewness, kurtosis, percentiles, outliers (IQR), normality test (KS), histogram.
/stats/compare: POST `{"a": [...], "b": [...], "paired": false}`. Compare two samples: Welch's t-test + Mann-Whitney U + Cohen's d. Set `paired: true` for before/after (adds paired t-test + Wilcoxon signed-rank).
/stats/anova: POST `{"groups": [[...], [...], ...]}`. One-way ANOVA + Kruskal-Wallis. Parametric and non-parametric comparison across 3+ groups.
/stats/proportion: `{"x1": 52, "n1": 100, "x2": 45, "n2": 100}`. Two-proportion z-test (A/B testing).
/stats/chi-square: POST `{"observed": [...], "expected": [...]}`. Chi² goodness-of-fit.
/stats/correlation: POST `{"x": [...], "y": [...]}`. Pearson r, R², Spearman ρ.
/stats/histogram: POST `{"data": [...], "bins": 20}`. Custom bin count (default 20 included in /stats).
/stats/portfolio: POST `{"returns": [...], "risk_free_rate": 0.02, "periods_per_year": 252, "benchmark": [...]}`. Sharpe, Sortino, max drawdown, VaR, CVaR, beta, alpha, Calmar, win rate, profit factor.
/stats/moving-average: POST `{"data": [...], "window": 5, "method": "sma"}`. Methods: sma, ema.
/stats/ks-test: POST `{"a": [...], "b": [...]}`. Two-sample Kolmogorov-Smirnov test.
/stats/covariance: POST `{"variables": [[...], [...]]}`. Covariance + correlation matrices.
/stats/weighted: POST `{"data": [...], "weights": [...]}`. Weighted mean, variance, stddev.
/stats/power: `{"effect_size": 0.5, "alpha": 0.05, "power": 0.8}`. Sample size calculation.
/stats/bootstrap: POST `{"data": [...], "statistic": "mean", "n_resamples": 10000, "confidence": 0.95}`. Bootstrap confidence interval.

## Regression (POST JSON)

/regression: POST `{"x": [...], "y": [...], "model": "linear|polynomial|exponential|logarithmic|power|auto", "degree": 2}`. Returns coefficients, R², formula, predictions. `auto` tries all models and ranks by R².

## Finance (POST JSON)

/finance/npv: `{"rate": 0.10, "cash_flows": [-1000, 300, 420, 680]}`. Net present value.
/finance/irr: `{"cash_flows": [-1000, 300, 420, 680]}`. Internal rate of return via Newton's method.
/finance/amortization: `{"principal": 200000, "annual_rate": 0.06, "periods": 360}`. Full schedule.
/finance/compound: `{"principal": 1000, "annual_rate": 0.05, "years": 10, "compounds_per_year": 12}`. Future value.
/finance/black-scholes: `{"spot": 100, "strike": 100, "time": 1.0, "rate": 0.05, "volatility": 0.20}`. Call/put prices, Greeks.

## Graph (POST JSON)

/graph/shortest-path: `{"edges": [["A","B",1], ["B","C",2]], "from": "A", "to": "C"}`. Dijkstra.
/graph/pagerank: `{"edges": [["A","B",1], ...], "damping": 0.85, "iterations": 100}`. Returns sorted ranks.
/graph/components: `{"edges": [["A","B",1], ...]}`. Connected components (undirected).

## Monte Carlo (POST JSON)

/monte-carlo/simulate: `{"distribution": {"type": "normal", "mean": 100, "stddev": 15}, "n": 100000}`. Types: normal, uniform, triangular, lognormal, bernoulli.
/monte-carlo/expression: `{"variables": {"price": {"type": "uniform", "min": 90, "max": 110}, "qty": {"type": "normal", "mean": 100, "stddev": 10}}, "expression": "price * qty", "n": 100000}`. Simulate formula with random inputs.

## Matrix (POST JSON)

/matrix/determinant: `{"matrix": [[6,1,1],[4,-2,5],[2,8,7]]}`. LU decomposition.
/matrix/inverse: `{"matrix": [[4,7],[2,6]]}`. Gauss-Jordan. Returns error if singular.
/matrix/multiply: `{"a": [[1,2],[3,4]], "b": [[5,6],[7,8]]}`. A * B.
/matrix/transpose: `{"matrix": [[1,2,3],[4,5,6]]}`. Flip rows/cols.
/matrix/eigenvalues: `{"matrix": [[2,1],[1,2]]}`. QR algorithm (max 30x30).
/matrix/rank: `{"matrix": [[1,2,3],[4,5,6],[7,8,9]]}`. Row reduction.
/matrix/trace: `{"matrix": [[1,2],[3,4]]}`. Sum of diagonal.

## Number Theory (GET)

/number-theory/factorize?n=360: Prime factorization.
/number-theory/is-prime?n=104729: Primality test.
/number-theory/gcd?a=48&b=18: GCD and LCM.
/number-theory/mod-pow?base=3&exponent=100&modulus=1000000007: Modular exponentiation.
/number-theory/mod-inverse?a=3&modulus=7: Modular multiplicative inverse.
/number-theory/primes?limit=100: Sieve of Eratosthenes (max 10M).

## Combinatorics (GET)

/combinatorics/factorial?n=20: n! (returns value + ln for large n).
/combinatorics/permutations?n=10&r=3: P(n,r).
/combinatorics/combinations?n=52&r=5: C(n,r) = 2,598,960.
/combinatorics/multinomial: POST `{"n": 10, "groups": [3, 3, 4]}`. Multinomial coefficient.
/combinatorics/binomial-probability?n=10&k=5&p=0.5: P(X=k) and cumulative P(X<=k).

## Interpolation (POST JSON)

/interpolate: `{"x": [0,1,2,3], "y": [0,1,4,9], "at": [0.5, 1.5, 2.5], "method": "cubic_spline"}`. Methods: linear, cubic_spline. Returns interpolated values at query points.

## Integration (POST JSON)

/integrate: `{"x": [0,0.5,1.0], "y": [0,0.25,1.0]}`. Numerical integration of tabular (x,y) data. Returns trapezoidal area + Simpson's (when applicable: uniform spacing, even segments).

## ODE Solver (POST JSON)

/ode: `{"expr": "y * (1 - y)", "y0": 0.01, "t_start": 0, "t_end": 10, "steps": 1000}`. Runge-Kutta 4th order. Expression uses variables `t` and `y`. Returns trajectory points.

## Geodesic Distance (GET)

/geo/distance?lat1=51.5074&lon1=-0.1278&lat2=48.8566&lon2=2.3522: Haversine distance in km, miles, nautical miles.

All endpoints accept both **GET with query parameters** and **POST with JSON body**.

## Endpoints

### `https://z87.ai/api/solve/solve`

Solve a single equation. Use expr (infix) or sexp (s-expression).

| Param | Type | Required | Default |
|-------|------|----------|---------|
| expr | string | no | — |
| sexp | string | no | — |
| known | object | no | — |
| solve | string | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/solve`
```json
{
  "expr": "F = m * v^2 / r",
  "known": {"m": [5, "kg"], "v": [36, "km/h"], "r": [200, "cm"]},
  "solve": "F"
}
```
**Response:**
```json
{
  "expression": {"sexp": "(= F (/ (* m (^ v 2)) r))", "infix": "F = m × v² / r"},
  "steps": [],
  "input_conversions": [{"symbol": "m", "given": [5.0, "...1 more"], "si": [5.0, "...1 more"]}, "...2 more"],
  "result": {"symbol": "F", "value": 250.0, "unit": "N"},
  "verified": true
}
```

### `https://z87.ai/api/solve/solve-system`

Solve a system of equations. Use equations (infix) or sexps (s-expression).

| Param | Type | Required | Default |
|-------|------|----------|---------|
| equations | array | no | — |
| sexps | array | no | — |
| known | object | no | — |
| solve | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/solve-system`
```json
{
  "equations": ["v = u + a*t", "s = u*t + 0.5*a*t^2"],
  "known": {"s": 100, "u": 0, "t": 5},
  "solve": ["a", "v"]
}
```
**Response:**
```json
{
  "results": [{"symbol": "a", "value": 8.0}, "...1 more"],
  "steps": [
    {
      "action": "select_equation",
      "why": "equation 2 has exactly 1 unknown (a) after substituting known values",
      "to": {"sexp": "(= s (+ (* u t) (* 0.5 a (^ t 2))))", "infix": "s = u × t + 0.5 × a × t²"}
    },
    "...6 more"
  ],
  "verified": true
}
```

### `https://z87.ai/api/solve/rearrange`

Symbolic rearrangement only — no evaluation. Use expr (infix) or sexp.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| expr | string | no | — |
| sexp | string | no | — |
| solve | string | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/rearrange`
```json
{"expr": "p * V = n * R * T", "solve": "T"}
```
**Response:**
```json
{
  "expression": {"sexp": "(= T (/ (* V p) (* R n)))", "infix": "T = V × p / (R × n)"},
  "steps": [
    {
      "action": "swap_sides",
      "why": "move the side containing the target to the left",
      "from": {"sexp": "(= (* p V) (* n R T))", "infix": "p × V = n × R × T"},
      "to": {"sexp": "(= (* n R T) (* p V))", "infix": "n × R × T = p × V"}
    },
    "...1 more"
  ]
}
```

### `https://z87.ai/api/solve/simplify`

Expand, collect like terms, and simplify an expression.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| expr | string | no | — |
| sexp | string | no | — |

**Example:** `POST https://z87.ai/api/solve/simplify`
```json
{"expr": "(x^2 + 8)^2 - (x^2 - 4)^2"}
```
**Response:**
```json
{"expression": {"sexp": "(+ 48 (* 24 (^ x 2)))", "infix": "48 + 24 × x²"}}
```

### `https://z87.ai/api/solve/convert`

Unit conversion.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| value | f64 | **yes** | — |
| from | string | **yes** | — |
| to | string | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/convert?value=36&from=km/h&to=m/s`

**Response:**
```json
{"result": 10.0}
```

### `https://z87.ai/api/solve/stats`

Full analysis of a dataset: descriptive stats, percentiles, outliers (IQR), normality test (KS), histogram.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| data | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/stats`
```json
{"data": [2, 4, 4, 4, 5, 5, 7, 9]}
```
**Response:**
```json
{
  "count": 8,
  "mean": 5.0,
  "median": 4.5,
  "min": 2.0,
  "max": 9.0,
  "variance": 4.571428571428571,
  "stddev": 2.138089935299395,
  "skewness": 0.65625
}
```

### `https://z87.ai/api/solve/stats/compare`

Compare two samples. Returns Welch's t-test, Mann-Whitney U, Cohen's d. Set paired:true for before/after (adds paired t-test + Wilcoxon signed-rank).

| Param | Type | Required | Default |
|-------|------|----------|---------|
| a | array | **yes** | — |
| b | array | **yes** | — |
| paired | bool | no | false |

**Example:** `POST https://z87.ai/api/solve/stats/compare`
```json
{"a": [23, 25, 28, 30, 32], "b": [20, 22, 24, 26, 28]}
```
**Response:**
```json
{
  "welch_t": {
    "t_statistic": 1.6676677966034863,
    "degrees_of_freedom": 7.842681209144425,
    "p_value": 0.13469588675426117,
    "mean_difference": 3.6000000000000014,
    "confidence_interval_95": [-1.395413524397445, "...1 more"],
    "cohens_d": 1.054725723556286
  },
  "mann_whitney": {"u_statistic": 5.5, "p_value": 0.1436721619362605, "rank_sum_a": 34.5, "rank_sum_b": 20.5}
}
```

### `https://z87.ai/api/solve/stats/anova`

One-way ANOVA + Kruskal-Wallis. Parametric and non-parametric comparison across 3+ groups.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| groups | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/stats/anova`
```json
{"groups": [[85, 90, 88], [78, 82, 80], [92, 95, 93]]}
```
**Response:**
```json
{
  "f_statistic": 31.81578947368419,
  "p_value": 0.0006397864256912911,
  "df_between": 2,
  "df_within": 6,
  "ss_between": 268.6666666666665,
  "ss_within": 25.333333333333332,
  "group_means": [87.66666666666667, "...2 more"],
  "grand_mean": 87.0
}
```

### `https://z87.ai/api/solve/stats/proportion`

Two-proportion z-test for A/B testing.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| x1 | u64 | **yes** | — |
| n1 | u64 | **yes** | — |
| x2 | u64 | **yes** | — |
| n2 | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/stats/proportion?x1=52&n1=100&x2=45&n2=100`

**Response:**
```json
{
  "z_statistic": 0.9903952718561734,
  "p_value": 0.3219809678982093,
  "p1": 0.52,
  "p2": 0.45,
  "difference": 0.07,
  "confidence_interval_95": [-0.06819042513864698, "...1 more"]
}
```

### `https://z87.ai/api/solve/stats/chi-square`

Chi-square goodness-of-fit test.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| observed | array | **yes** | — |
| expected | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/stats/chi-square`
```json
{"observed": [90, 60, 104, 95, 51], "expected": [80, 80, 80, 80, 80]}
```
**Response:**
```json
{"chi_square": 26.775, "degrees_of_freedom": 4, "p_value": 0.000022073335288141926}
```

### `https://z87.ai/api/solve/stats/correlation`

Pearson r, R-squared, and Spearman rho.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| x | array | **yes** | — |
| y | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/stats/correlation`
```json
{"x": [1, 2, 3, 4, 5], "y": [2, 4, 6, 8, 10]}
```
**Response:**
```json
{"pearson_r": 1.0, "r_squared": 1.0, "spearman_rho": 1.0}
```

### `https://z87.ai/api/solve/stats/histogram`

Histogram with custom bin count (a 20-bin histogram is included in /stats).

| Param | Type | Required | Default |
|-------|------|----------|---------|
| data | array | **yes** | — |
| bins | u32 | no | 20 |

**Example:** `POST https://z87.ai/api/solve/stats/histogram`
```json
{"data": [1, 1, 2, 3, 3, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10], "bins": 5}
```
**Response:**
```json
{"bins": [{"low": 1.0, "high": 2.8, "count": 3}, "...4 more"]}
```

### `https://z87.ai/api/solve/stats/portfolio`

Portfolio analytics: Sharpe, Sortino, max drawdown, VaR, CVaR, beta, alpha, Calmar, win rate, profit factor.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| returns | array | **yes** | — |
| risk_free_rate | f64 | no | 0 |
| periods_per_year | u32 | no | 252 |
| benchmark | array | no | — |

**Example:** `POST https://z87.ai/api/solve/stats/portfolio`
```json
{
  "returns": [0.01, -0.02, 0.015, 0.005, -0.01, 0.02, -0.005, 0.01, 0.008, -0.003],
  "risk_free_rate": 0.02,
  "periods_per_year": 252
}
```
**Response:**
```json
{
  "sharpe_ratio": 3.77440860530468,
  "sortino_ratio": 6.308959910600025,
  "max_drawdown": 0.019999999999999997,
  "max_drawdown_duration": 1,
  "annualized_return": 1.0913158679881234,
  "annualized_volatility": 0.1949974358805777,
  "var_95": 0.02,
  "cvar_95": 0.02
}
```

### `https://z87.ai/api/solve/stats/moving-average`

Simple (SMA) or exponential (EMA) moving average.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| data | array | **yes** | — |
| window | u32 | **yes** | — |
| method | string | no | sma |

**Example:** `POST https://z87.ai/api/solve/stats/moving-average`
```json
{"data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "window": 3, "method": "sma"}
```
**Response:**
```json
{"method": "sma", "window": 3, "values": [2.0, "...7 more"]}
```

### `https://z87.ai/api/solve/stats/ks-test`

Two-sample Kolmogorov-Smirnov test. Are two samples from the same distribution?

| Param | Type | Required | Default |
|-------|------|----------|---------|
| a | array | **yes** | — |
| b | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/stats/ks-test`
```json
{"a": [1, 2, 3, 4, 5], "b": [2, 3, 4, 5, 6]}
```
**Response:**
```json
{"statistic": 0.20000000000000007, "p_value": 0.9996217060535832, "n1": 5, "n2": 5}
```

### `https://z87.ai/api/solve/stats/covariance`

Covariance and correlation matrices for multiple variables.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| variables | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/stats/covariance`
```json
{"variables": [[1, 2, 3, 4, 5], [2, 4, 5, 4, 5], [5, 3, 4, 2, 1]]}
```
**Response:**
```json
{
  "covariance_matrix": [[2.5, "...2 more"], "...2 more"],
  "correlation_matrix": [[0.9999999999999998, "...2 more"], "...2 more"],
  "means": [3.0, "...2 more"],
  "stddevs": [1.5811388300841898, "...2 more"],
  "n": 5,
  "p": 3
}
```

### `https://z87.ai/api/solve/stats/weighted`

Weighted mean, variance, stddev.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| data | array | **yes** | — |
| weights | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/stats/weighted`
```json
{"data": [80, 90, 95], "weights": [0.3, 0.3, 0.4]}
```
**Response:**
```json
{
  "weighted_mean": 89.0,
  "weighted_variance": 39.0,
  "weighted_stddev": 6.244997998398398,
  "total_weight": 1.0,
  "n": 3
}
```

### `https://z87.ai/api/solve/stats/power`

Power analysis: how many samples needed? Given effect size, alpha, power.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| effect_size | f64 | **yes** | — |
| alpha | f64 | no | 0.05 |
| power | f64 | no | 0.8 |

**Example:** `GET https://z87.ai/api/solve/stats/power?effect_size=0.5&alpha=0.05&power=0.8`

**Response:**
```json
{"required_n": 32.0, "effect_size": 0.5, "alpha": 0.05, "power": 0.8}
```

### `https://z87.ai/api/solve/stats/bootstrap`

Bootstrap confidence interval via resampling.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| data | array | **yes** | — |
| statistic | string | no | mean |
| n_resamples | u32 | no | 10000 |
| confidence | f64 | no | 0.95 |
| seed | u64 | no | 42 |

**Example:** `POST https://z87.ai/api/solve/stats/bootstrap`
```json
{"data": [2, 4, 4, 4, 5, 5, 7, 9], "statistic": "mean", "confidence": 0.95}
```
**Response:**
```json
{
  "ci_lower": 3.75,
  "ci_upper": 6.5,
  "point_estimate": 5.0,
  "confidence": 0.95,
  "n_resamples": 10000,
  "se": 0.7097934016395651
}
```

### `https://z87.ai/api/solve/regression`

Curve fitting. Models: linear, polynomial, exponential, logarithmic, power, auto.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| x | array | **yes** | — |
| y | array | **yes** | — |
| model | string | no | auto |
| degree | u32 | no | 2 |

**Example:** `POST https://z87.ai/api/solve/regression`
```json
{"x": [1, 2, 3, 4, 5], "y": [2.1, 3.9, 6.2, 7.8, 10.1], "model": "linear"}
```
**Response:**
```json
{
  "model": "linear",
  "coefficients": [0.0500000000000016, "...1 more"],
  "r_squared": 0.9973053289009772,
  "formula": "y = 0.050000 + 1.990000 * x",
  "predictions": [2.040000000000002, "...4 more"]
}
```

### `https://z87.ai/api/solve/finance/npv`

Net present value.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| rate | f64 | **yes** | — |
| cash_flows | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/finance/npv`
```json
{"rate": 0.1, "cash_flows": [-1000, 300, 420, 680]}
```
**Response:**
```json
{"npv": 130.72877535687434, "rate": 0.1}
```

### `https://z87.ai/api/solve/finance/irr`

Internal rate of return via Newton's method.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| cash_flows | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/finance/irr`
```json
{"cash_flows": [-1000, 300, 420, 680]}
```
**Response:**
```json
{"irr": 0.16340560068898932, "npv_at_irr": 5.684341886080803e-14}
```

### `https://z87.ai/api/solve/finance/amortization`

Loan amortization schedule.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| principal | f64 | **yes** | — |
| annual_rate | f64 | **yes** | — |
| periods | u32 | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/finance/amortization`
```json
{"principal": 200000, "annual_rate": 0.06, "periods": 360}
```
**Response:**
```json
{
  "payment": 1199.101050305518,
  "total_paid": 431676.3781099864,
  "total_interest": 231676.37810997345,
  "schedule": [
    {
      "period": 1,
      "payment": 1199.101050305518,
      "principal": 199.1010503055179,
      "interest": 1000.0,
      "balance": 199800.89894969447
    },
    "...359 more"
  ]
}
```

### `https://z87.ai/api/solve/finance/compound`

Compound interest calculator.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| principal | f64 | **yes** | — |
| annual_rate | f64 | **yes** | — |
| years | f64 | **yes** | — |
| compounds_per_year | u32 | no | 12 |

**Example:** `POST https://z87.ai/api/solve/finance/compound`
```json
{"principal": 1000, "annual_rate": 0.05, "years": 10, "compounds_per_year": 12}
```
**Response:**
```json
{"future_value": 1647.00949769028, "total_interest": 647.0094976902801}
```

### `https://z87.ai/api/solve/finance/black-scholes`

Black-Scholes option pricing with Greeks.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| spot | f64 | **yes** | — |
| strike | f64 | **yes** | — |
| time | f64 | **yes** | — |
| rate | f64 | **yes** | — |
| volatility | f64 | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/finance/black-scholes`
```json
{"spot": 100, "strike": 100, "time": 1.0, "rate": 0.05, "volatility": 0.2}
```
**Response:**
```json
{
  "call_price": 10.450575415435084,
  "put_price": 5.573517865506496,
  "call_delta": 0.6368305860070302,
  "put_delta": -0.36316941399296976,
  "gamma": 0.018762017345846895,
  "vega": 0.3752403469169379,
  "call_theta": -0.017572678434062402,
  "put_theta": -0.004542138372408784
}
```

### `https://z87.ai/api/solve/graph/shortest-path`

Dijkstra's shortest path. Edges: [[from, to, weight], ...].

| Param | Type | Required | Default |
|-------|------|----------|---------|
| edges | array | **yes** | — |
| from | string | **yes** | — |
| to | string | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/graph/shortest-path`
```json
{"edges": [["A", "B", 1], ["B", "C", 2], ["A", "C", 10]], "from": "A", "to": "C"}
```
**Response:**
```json
{"distance": 3.0, "path": ["A", "...2 more"]}
```

### `https://z87.ai/api/solve/graph/pagerank`

PageRank on a directed graph.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| edges | array | **yes** | — |
| damping | f64 | no | 0.85 |
| iterations | u32 | no | 100 |

**Example:** `POST https://z87.ai/api/solve/graph/pagerank`
```json
{"edges": [["A", "B", 1], ["B", "C", 1], ["C", "A", 1]]}
```
**Response:**
```json
{"ranks": [["A", "...1 more"], "...2 more"], "iterations": 100}
```

### `https://z87.ai/api/solve/graph/components`

Connected components (undirected).

| Param | Type | Required | Default |
|-------|------|----------|---------|
| edges | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/graph/components`
```json
{"edges": [["A", "B", 1], ["B", "C", 1], ["D", "E", 1]]}
```
**Response:**
```json
{"count": 2, "components": [["A", "...2 more"], "...1 more"]}
```

### `https://z87.ai/api/solve/monte-carlo/simulate`

Monte Carlo simulation of a distribution. Types: normal, uniform, triangular, lognormal, bernoulli.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| distribution | object | **yes** | — |
| n | u32 | no | 10000 |
| seed | u64 | no | 42 |

**Example:** `POST https://z87.ai/api/solve/monte-carlo/simulate`
```json
{"distribution": {"type": "normal", "mean": 100, "stddev": 15}, "n": 10000}
```
**Response:**
```json
{
  "n": 10000,
  "mean": 100.03149534197686,
  "median": 100.06139353928891,
  "stddev": 14.937881654705937,
  "min": 44.56320783275633,
  "max": 156.6819819531267,
  "percentiles": {
    "p5": 75.41864746936244,
    "p10": 80.87908268632177,
    "p25": 90.01906386048417,
    "p50": 100.06139353928891,
    "p75": 109.8856140776896,
    "p90": 119.27593113655898,
    "p95": 124.86055255627788,
    "p99": 134.568563231089
  },
  "histogram": [
    {"low": 44.56320783275633, "high": 50.169146538774854, "count": 5, "frequency": 0.0005},
    "...19 more"
  ]
}
```

### `https://z87.ai/api/solve/monte-carlo/expression`

Monte Carlo simulation of a formula with random variable inputs.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| variables | object | **yes** | — |
| expression | string | **yes** | — |
| n | u32 | no | 10000 |
| seed | u64 | no | 42 |

**Example:** `POST https://z87.ai/api/solve/monte-carlo/expression`
```json
{
  "variables": {
    "price": {"type": "uniform", "min": 90, "max": 110},
    "qty": {"type": "normal", "mean": 100, "stddev": 10}
  },
  "expression": "price * qty",
  "n": 10000
}
```
**Response:**
```json
{
  "n": 10000,
  "mean": 9982.07596425842,
  "median": 9950.400296597389,
  "stddev": 1143.383980122018,
  "min": 6050.305756140787,
  "max": 14334.09538445847,
  "percentiles": {
    "p5": 8134.756649166626,
    "p10": 8530.709955079361,
    "p25": 9187.591722555995,
    "p50": 9950.400296597389,
    "p75": 10768.330962444985,
    "p90": 11444.478896386394,
    "p95": 11871.375610046454,
    "p99": 12720.497964020064
  },
  "histogram": [
    {"low": 6050.305756140787, "high": 6464.495237556671, "count": 9, "frequency": 0.0009},
    "...19 more"
  ]
}
```

### `https://z87.ai/api/solve/matrix/determinant`

Matrix determinant via LU decomposition.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| matrix | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/matrix/determinant`
```json
{"matrix": [[6, 1, 1], [4, -2, 5], [2, 8, 7]]}
```
**Response:**
```json
{"determinant": -306.0, "size": 3}
```

### `https://z87.ai/api/solve/matrix/inverse`

Matrix inverse via Gauss-Jordan elimination.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| matrix | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/matrix/inverse`
```json
{"matrix": [[4, 7], [2, 6]]}
```
**Response:**
```json
{"matrix": [[0.6000000000000001, "...1 more"], "...1 more"], "size": 2}
```

### `https://z87.ai/api/solve/matrix/multiply`

Matrix multiplication. A * B.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| a | array | **yes** | — |
| b | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/matrix/multiply`
```json
{"a": [[1, 2], [3, 4]], "b": [[5, 6], [7, 8]]}
```
**Response:**
```json
{"matrix": [[19.0, "...1 more"], "...1 more"], "rows": 2, "cols": 2}
```

### `https://z87.ai/api/solve/matrix/transpose`

Matrix transpose.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| matrix | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/matrix/transpose`
```json
{"matrix": [[1, 2, 3], [4, 5, 6]]}
```
**Response:**
```json
{"matrix": [[1.0, "...1 more"], "...2 more"], "rows": 3, "cols": 2}
```

### `https://z87.ai/api/solve/matrix/eigenvalues`

Eigenvalues via QR algorithm (max 30x30, symmetric matrices converge best).

| Param | Type | Required | Default |
|-------|------|----------|---------|
| matrix | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/matrix/eigenvalues`
```json
{"matrix": [[2, 1], [1, 2]]}
```
**Response:**
```json
{"eigenvalues": [2.9999999999999987, "...1 more"], "iterations": 22}
```

### `https://z87.ai/api/solve/matrix/rank`

Matrix rank via row reduction.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| matrix | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/matrix/rank`
```json
{"matrix": [[1, 2, 3], [4, 5, 6], [7, 8, 9]]}
```
**Response:**
```json
{"rank": 2, "size": [3, "...1 more"]}
```

### `https://z87.ai/api/solve/matrix/trace`

Sum of diagonal elements.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| matrix | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/matrix/trace`
```json
{"matrix": [[1, 2], [3, 4]]}
```
**Response:**
```json
{"trace": 5.0, "size": 2}
```

### `https://z87.ai/api/solve/number-theory/factorize`

Prime factorization.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| n | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/number-theory/factorize?n=360`

**Response:**
```json
{"n": 360, "factors": [[2, "...1 more"], "...2 more"], "is_prime": false}
```

### `https://z87.ai/api/solve/number-theory/is-prime`

Primality test.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| n | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/number-theory/is-prime?n=104729`

**Response:**
```json
{"n": 104729, "is_prime": true}
```

### `https://z87.ai/api/solve/number-theory/gcd`

GCD and LCM of two numbers.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| a | u64 | **yes** | — |
| b | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/number-theory/gcd?a=48&b=18`

**Response:**
```json
{"gcd": 6, "lcm": 144, "a": 48, "b": 18}
```

### `https://z87.ai/api/solve/number-theory/mod-pow`

Modular exponentiation: base^exp mod modulus.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| base | u64 | **yes** | — |
| exponent | u64 | **yes** | — |
| modulus | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/number-theory/mod-pow?base=3&exponent=100&modulus=1000000007`

**Response:**
```json
{"result": 886041711, "base": 3, "exponent": 100, "modulus": 1000000007}
```

### `https://z87.ai/api/solve/number-theory/mod-inverse`

Modular multiplicative inverse via extended Euclidean algorithm.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| a | u64 | **yes** | — |
| modulus | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/number-theory/mod-inverse?a=3&modulus=7`

**Response:**
```json
{"result": 5, "a": 3, "modulus": 7}
```

### `https://z87.ai/api/solve/number-theory/primes`

All primes up to limit (sieve of Eratosthenes, max 10M).

| Param | Type | Required | Default |
|-------|------|----------|---------|
| limit | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/number-theory/primes?limit=100`

**Response:**
```json
{"primes": [2, "...24 more"], "count": 25}
```

### `https://z87.ai/api/solve/combinatorics/factorial`

Factorial. Returns value and ln(n!) for large n.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| n | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/combinatorics/factorial?n=20`

**Response:**
```json
{"n": 20, "value": 2.432902008204852e+18, "ln_value": 42.33561646076508}
```

### `https://z87.ai/api/solve/combinatorics/permutations`

P(n, r) = n! / (n-r)!

| Param | Type | Required | Default |
|-------|------|----------|---------|
| n | u64 | **yes** | — |
| r | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/combinatorics/permutations?n=10&r=3`

**Response:**
```json
{"n": 10, "r": 3, "value": 720.0000000005718}
```

### `https://z87.ai/api/solve/combinatorics/combinations`

C(n, r) = n! / (r! * (n-r)!)

| Param | Type | Required | Default |
|-------|------|----------|---------|
| n | u64 | **yes** | — |
| r | u64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/combinatorics/combinations?n=52&r=5`

**Response:**
```json
{"n": 52, "r": 5, "value": 2598960.0000175247}
```

### `https://z87.ai/api/solve/combinatorics/multinomial`

Multinomial coefficient: n! / (k1! * k2! * ... * km!)

| Param | Type | Required | Default |
|-------|------|----------|---------|
| n | u64 | **yes** | — |
| groups | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/combinatorics/multinomial`
```json
{"n": 10, "groups": [3, 3, 4]}
```
**Response:**
```json
{"n": 10, "groups": [3, "...2 more"], "value": 4200.0000000036935}
```

### `https://z87.ai/api/solve/combinatorics/binomial-probability`

Binomial probability P(X=k) and cumulative P(X<=k).

| Param | Type | Required | Default |
|-------|------|----------|---------|
| n | u64 | **yes** | — |
| k | u64 | **yes** | — |
| p | f64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/combinatorics/binomial-probability?n=10&k=5&p=0.5`

**Response:**
```json
{"n": 10, "k": 5, "p": 0.5, "probability": 0.24609375000021727, "cumulative": 0.6230468750005193}
```

### `https://z87.ai/api/solve/interpolate`

Interpolate tabular data. Methods: linear, cubic_spline.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| x | array | **yes** | — |
| y | array | **yes** | — |
| at | array | **yes** | — |
| method | string | no | cubic_spline |

**Example:** `POST https://z87.ai/api/solve/interpolate`
```json
{"x": [0, 1, 2, 3, 4], "y": [0, 1, 4, 9, 16], "at": [0.5, 1.5, 2.5, 3.5], "method": "cubic_spline"}
```
**Response:**
```json
{"method": "cubic_spline", "values": [{"x": 0.5, "y": 0.33928571428571425}, "...3 more"]}
```

### `https://z87.ai/api/solve/integrate`

Numerical integration of tabular (x,y) data. Trapezoidal + Simpson's rule.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| x | array | **yes** | — |
| y | array | **yes** | — |

**Example:** `POST https://z87.ai/api/solve/integrate`
```json
{"x": [0, 0.25, 0.5, 0.75, 1.0], "y": [0, 0.0625, 0.25, 0.5625, 1.0]}
```
**Response:**
```json
{"trapezoidal": 0.34375, "simpsons": 0.3333333333333333, "n": 5}
```

### `https://z87.ai/api/solve/ode`

Solve ODE dy/dt = f(t, y) via Runge-Kutta 4th order.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| expr | string | **yes** | — |
| y0 | f64 | **yes** | — |
| t_start | f64 | no | 0 |
| t_end | f64 | **yes** | — |
| steps | u32 | no | 1000 |

**Example:** `POST https://z87.ai/api/solve/ode`
```json
{"expr": "y * (1 - y)", "y0": 0.01, "t_start": 0, "t_end": 10, "steps": 1000}
```
**Response:**
```json
{"points": [{"t": 0.0, "y": 0.01}, "...1000 more"], "steps": 1000, "method": "rk4"}
```

### `https://z87.ai/api/solve/geo/distance`

Geodesic (Haversine) distance between two points.

| Param | Type | Required | Default |
|-------|------|----------|---------|
| lat1 | f64 | **yes** | — |
| lon1 | f64 | **yes** | — |
| lat2 | f64 | **yes** | — |
| lon2 | f64 | **yes** | — |

**Example:** `GET https://z87.ai/api/solve/geo/distance?lat1=51.5074&lon1=-0.1278&lat2=48.8566&lon2=2.3522`

**Response:**
```json
{"km": 343.55606034104164, "miles": 213.4757727701734, "nautical_miles": 185.50549967356784}
```

## License

The z87 API code is MIT licensed. Each dataset carries its upstream license:
- **solve**: MIT


---

## Other z87 Datasets

- [chess](https://z87.ai/api/chess/SKILL.md) — 1B+ Lichess games (2000+ Elo, 2013-2026)
- [colors](https://z87.ai/api/colors/SKILL.md) — Unified paint color database: ~30K colors across 20+ brands with cross-brand matching via CIEDE2000 perceptual distance, color harmony generation, coordinating color strips, and palette suggestions.
- [companies_uk](https://z87.ai/api/companies_uk/SKILL.md) — 5.7M UK companies from Companies House
- [countries](https://z87.ai/api/countries/SKILL.md) — 247 countries with 282 indicators (57 static, 225 timeseries) across economics, health, demographics, energy, environment, education, and more
- [design](https://z87.ai/api/design/SKILL.md) — 1,003 production-grade frontend designs with HTML, screenshots, prompts, and structured metadata (26 categories, 40 styles, 4K+ tags)
- [food](https://z87.ai/api/food/SKILL.md) — Recipes, FDC ingredients, and food products: 13.5K recipes with nutrition, 8K+ FDC ingredients, curated products with Nutri-Score and NOVA ratings.
- [gbif](https://z87.ai/api/gbif/SKILL.md) — GBIF Backbone Taxonomy: 7.7 million taxa with full taxonomic hierarchy, synonym resolution, tree navigation, and full-text search across the tree of life.
- [gutenberg](https://z87.ai/api/gutenberg/SKILL.md) — 60,000 Project Gutenberg books with chapter-level access, BM25 full-text search, cover art, illustrations, and AI-generated tags (genre, mood, era, locations, five-word summaries).
- [holidays](https://z87.ai/api/holidays/SKILL.md) — 3,391 public holidays across 121 countries (2026–2027)
- [home](https://z87.ai/api/home/SKILL.md) — Unified smart home device database
- [jokes](https://z87.ai/api/jokes/SKILL.md) — 41,000 jokes from three sources, AI-tagged with category, rating, topics, and offensive score
- [manpages](https://z87.ai/api/manpages/SKILL.md) — 142K Linux man pages with AI-generated cheat cards, category tags, use-frequency scores, and plain-english descriptions
- [movies](https://z87.ai/api/movies/SKILL.md) — 360K+ movies with 40-axis taste profiles, cast, themes, ratings, and soundtrack data
- [mtg](https://z87.ai/api/mtg/SKILL.md) — 29K Magic: The Gathering cards with synergy graph engine, combo detection, and Commander deck builder.
- [music](https://z87.ai/api/music/SKILL.md) — 651K artists, 500K+ albums, 1M+ songs from MusicBrainz with genre, country, and member data
- [osm](https://z87.ai/api/osm/SKILL.md) — 46M+ OpenStreetMap POIs with Hilbert-curve spatial index and BM25 text search
- [podcast](https://z87.ai/api/podcast/SKILL.md) — 1M+ podcasts from PodcastIndex with categories, language, episode counts, popularity scores, and cadence estimates
- [restaurants](https://z87.ai/api/restaurants/SKILL.md) — 10K London restaurants with menus, Michelin stars, ingredient category scores (seafood, meat, game, etc.), and capacity data
- [wikipedia](https://z87.ai/api/wikipedia/SKILL.md) — 7.2 million English Wikipedia articles with full markdown content, infoboxes, inter-article links, and geographic coordinates.
- [wiktionary](https://z87.ai/api/wiktionary/SKILL.md) — 8M+ Wiktionary entries across 4,000+ languages

Full index: [https://z87.ai/api/SKILL.md](https://z87.ai/api/SKILL.md)
