# Linear solution check

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

Check that a proposed solution x satisfies A x = b exactly over the rationals and report the first row that fails.

**Use when you need to: check a proposed solution of a linear system exactly · does x satisfy A x = b with fractions · substitute a solution into simultaneous equations.**

## Decide before calling

Read the [versioned contract](/v1/tools/linear-solution-check/versions/1.0.0) and the supported scope below. Reuse `linear-solution-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-solution-check@1.0.0` for check a proposed solution of a linear system 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

- check a proposed solution of a linear system exactly
- does x satisfy A x = b with fractions
- substitute a solution into simultaneous equations
- verify my answer to a system of linear equations
- which equation does my solution violate
- exact rational check of a solver output
- בדיקת פתרון למערכת משוואות לינאריות

## Not supported

- solving the system or deciding whether the solution is unique (see matrix-rank)
- tolerance-based or floating-point acceptance of approximate solutions (see linear-residual-check)
- symbolic or complex entries
- inequality constraints or variable bounds

## Behavior

- Exact rationals are strings: an integer, a fraction p/q with q >= 1 or a finite decimal; JSON numbers, exponents, NaN and Infinity are rejected; outputs are canonical (reduced p/q, or an integer).
- matrix is m x n (1-64 each) with equal row lengths; rhs has m entries and solution n entries. Dimensions are checked before any dot product (a mismatch is invalid_input).
- Row i holds when sum_j a_ij x_j = b_i exactly; sums use pairwise addition of unreduced fractions and cross-multiplication, reducing only reported values.
- Rows are checked in order; the first failure gives reason row_not_satisfied and first_discrepancy {check: row, index, computed (Ax)_i, required_relation =, required_value b_i, difference (Ax)_i - b_i}; rows_satisfied counts rows that held before it.
- Only the supplied solution is checked: uniqueness is not claimed or tested. Every output carries reference_version.

## Input

- `matrix` (array of array of string, required): min items 1; max items 64; each min items 1; each max items 64; each each min length 1; each each max length 64; each each pattern `^-?(0|[1-9][0-9]*)(/[1-9][0-9]*|\.[0-9]+)?$`
- `rhs` (array of string, required): min items 1; max items 64; each min length 1; each max length 64; each pattern `^-?(0|[1-9][0-9]*)(/[1-9][0-9]*|\.[0-9]+)?$`
- `solution` (array of string, required): min items 1; max items 64; each min length 1; each max length 64; each pattern `^-?(0|[1-9][0-9]*)(/[1-9][0-9]*|\.[0-9]+)?$`

## Output

- `valid` (boolean, required)
- `reason` (one of "row_not_satisfied", null, required)
- `first_discrepancy` (object or null, required)
- `rows_satisfied` (integer, required): min 0
- `reference_version` (constant "r49-linear-solution-1.0.0 (NIST DLMF section 1.2(v), equation 1.2.34 row-times-column rule; exact rational arithmetic)", required)

## Limits

- max rows: 64
- max columns: 64
- max number chars: 64

## Example

Request input:

```json
{
  "matrix": [
    [
      "2",
      "1",
      "-1"
    ],
    [
      "-3",
      "-1",
      "2"
    ],
    [
      "-2",
      "1",
      "2"
    ]
  ],
  "rhs": [
    "8",
    "-11",
    "-3"
  ],
  "solution": [
    "2",
    "3",
    "-1"
  ]
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reason": null,
    "first_discrepancy": null,
    "rows_satisfied": 3,
    "reference_version": "r49-linear-solution-1.0.0 (NIST DLMF section 1.2(v), equation 1.2.34 row-times-column rule; exact rational arithmetic)"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "linear-solution-check",
  "version": "1.0.0",
  "input": {
    "matrix": [
      [
        "2",
        "1",
        "-1"
      ],
      [
        "-3",
        "-1",
        "2"
      ],
      [
        "-2",
        "1",
        "2"
      ]
    ],
    "rhs": [
      "8",
      "-11",
      "-3"
    ],
    "solution": [
      "2",
      "3",
      "-1"
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/linear-solution-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"matrix":[["2","1","-1"],["-3","-1","2"],["-2","1","2"]],"rhs":["8","-11","-3"],"solution":["2","3","-1"]}'
```

The machine-readable contract is at [/v1/tools/linear-solution-check/versions/1.0.0](/v1/tools/linear-solution-check/versions/1.0.0).

### CLI

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

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Lp primal feasibility check](/tools/lp-primal-feasibility-check): Check that a claimed LP point satisfies x >= 0 and Ax <= b exactly; report the first violated bound or row.
- [Linear inconsistency certificate check](/tools/linear-inconsistency-certificate-check): Check a witness y that A x = b has no solution (yA = 0, yb != 0) or no x >= 0 solution (Farkas: yA >= 0, yb < 0).
- [Linear residual check](/tools/linear-residual-check): Check a claimed residual r = b - A x (per component and/or its max norm) exactly for an approximate solution x.
- [Lp optimality certificate check](/tools/lp-optimality-certificate-check): Check an LP optimum claim from a primal x and dual y: feasibility, complementary slackness and zero duality gap.
- [Rational expression check](/tools/rational-expression-check): Check a claimed exact rational value of an integer/fraction expression; reports the true value and the difference.
- [Rational trace check](/tools/rational-trace-check): Check a step-by-step rational calculation trace; reports the first step whose operand, operator or result disagrees.
