Floating-point stability of an expression over variable ranges

$0.005 USDC per call · Developer and security · POST /api/v1/float-stability · Id float-stability

Evaluates a real-valued expression in binary64 (or binary32) on a deterministic grid over the caller's variable ranges and compares each point with a certified arbitrary-precision reference, reporting the decimal digits lost, the worst input, and overflow, underflow or NaN. Recognises and rewrites exp(x)-1, 1-cos(x), log(1+x), sqrt(a)-sqrt(b), a^2-b^2, the quadratic formula, sqrt(x^2+y^2) and log-sum-exp, measures the rewrite on the same grid, and can score a caller-supplied alternative. Samples a finite grid, so it can find instability but not prove its absence; the expression grammar has + - * / ^, the listed functions and no user code.

What you get

Catastrophic cancellation and spurious overflow pass every happy-path test and fail only on the inputs nobody sampled.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/float-stability. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/float-stability \
  -H 'content-type: application/json' \
  -d '{"expression":"exp(x) - 1","variables":[{"name":"x","min":1e-12,"max":1}]}'

Input

FieldTypeRequiredDescription
expressionstring; length 0..500yesExpression in the declared variables, e.g. 'exp(x) - 1'. Operators + - * / ^ (or **); functions sqrt exp expm1 log log1p log2 log10 sin cos tan atan sinh cosh tanh abs pow hypot min max; constants pi, e.
variablesarray<object>; max 6 itemsyesRange of every free variable.
precisionstring; one of "binary64", "binary32"noArithmetic of the code under test. Default binary64.
alternativestring; length 0..500noOptional algebraically equal expression to score on the same grid.
maxDigitsLostinteger; 0..16noFail above this many lost digits. Default 4.

Example request body

{
  "expression": "exp(x) - 1",
  "variables": [
    {
      "name": "x",
      "min": 1e-12,
      "max": 1
    }
  ]
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
precisionstringno
expressionstringnoCanonical form of the parsed expression.
samplesobjectnototal, certified and skipped counts (domain error, uncertified reference, out of binary range).
worstDigitsLostnumberno
worstarray<object>no
patternsarray<object>no
suggestedExpressionstringno
suggestedWorstDigitsLostnumberno
alternativeWorstDigitsLostnumberno
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the code-preflight-kit package.

Machine-readable