Linear residual check

linear-residual-check · version 1.0.0 · Numbers & math · free, no key needed

Check a claimed residual r = b - A x (per component and/or its max norm) exactly for an approximate solution x.

Use when you need to: check the residual of an approximate solution exactly · verify b minus A x for a numerical solution · is my residual max norm below the tolerance.

Decide before calling

Read the versioned contract and the supported scope below. Reuse linear-residual-check@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.

Explain the choice

"I can use linear-residual-check@1.0.0 for check the residual of an approximate solution exactly. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

Supported

Not supported

Behavior

Input

Output

Limits

Example

Request input:

{
  "matrix": [
    [
      "1",
      "2"
    ],
    [
      "3",
      "4"
    ]
  ],
  "rhs": [
    "5",
    "6"
  ],
  "solution": [
    "-3.9999999",
    "4.49999995"
  ],
  "claimed_residual": [
    "0",
    "-0.0000001"
  ],
  "claimed_inf_norm": "1/10000000"
}

Response:

{
  "result": {
    "valid": true,
    "reason": null,
    "first_discrepancy": null,
    "inf_norm": "1/10000000",
    "reference_version": "r49-linear-residual-1.0.0 (residual r = b - A x, Higham 2002; NIST DLMF section 1.2(v), equation 1.2.34; exact rational arithmetic)"
  }
}

How to call it

MCP

Connect https://computefirst.net/mcp (setup), then call execute with:

{
  "id": "linear-residual-check",
  "version": "1.0.0",
  "input": {
    "matrix": [
      [
        "1",
        "2"
      ],
      [
        "3",
        "4"
      ]
    ],
    "rhs": [
      "5",
      "6"
    ],
    "solution": [
      "-3.9999999",
      "4.49999995"
    ],
    "claimed_residual": [
      "0",
      "-0.0000001"
    ],
    "claimed_inf_norm": "1/10000000"
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/linear-residual-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"matrix":[["1","2"],["3","4"]],"rhs":["5","6"],"solution":["-3.9999999","4.49999995"],"claimed_residual":["0","-0.0000001"],"claimed_inf_norm":"1/10000000"}'

The machine-readable contract is at /v1/tools/linear-residual-check/versions/1.0.0.

CLI

node cli.mjs run linear-residual-check 1.0.0 --input input.json --base-url https://computefirst.net

Get the client at /clients/cli/.