Tools for agents: Exact linear-system solver

Solve rational linear equations and return a verifiable solution, nullspace basis, or explicit inconsistency.

Connect with MCP

{
  "mcpServers": {
    "super-agent-tools": {
      "url": "https://app.getsupers.com/sites/agent-linear-system/mcp"
    }
  }
}
Streamable HTTP · No API key · Stateless

Use this URL in any client supporting remote Streamable HTTP MCP. Calls return structured JSON; inputs are processed without persistence.

Call solve_linear_system

Solves A*x=b. Send integers or quoted decimal/fraction strings; JSON floats are rejected to avoid binary rounding. All numeric results are exact fraction strings. Columns are zero-based. For infinite solutions, x = particular_solution + sum(t_i * nullspace_basis[i]), with arbitrary rational parameters t_i. An inconsistent system has no particular solution or residual; its returned basis still describes the homogeneous system A*x=0. Intended for small exact systems; not a floating-point least-squares solver. Rational arithmetic uses Python fractions: https://docs.python.org/3/library/fractions.html

Input and output schemas
{
  "name": "solve_linear_system",
  "title": "Exact linear-system solver",
  "description": "Solve A*x=b exactly using rational arithmetic. Input integers or decimal/fraction strings. Return a particular solution, nullspace basis, RREF and exact residual; report inconsistent systems explicitly.",
  "inputSchema": {
    "properties": {
      "coefficients": {
        "items": {
          "items": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              }
            ]
          },
          "type": "array"
        },
        "title": "Coefficients",
        "type": "array"
      },
      "constants": {
        "items": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "string"
            }
          ]
        },
        "title": "Constants",
        "type": "array"
      }
    },
    "required": [
      "coefficients",
      "constants"
    ],
    "title": "solve_linear_systemArguments",
    "type": "object"
  },
  "outputSchema": {
    "properties": {
      "status": {
        "enum": [
          "unique",
          "infinite",
          "inconsistent"
        ],
        "title": "Status",
        "type": "string"
      },
      "rank": {
        "title": "Rank",
        "type": "integer"
      },
      "variables": {
        "title": "Variables",
        "type": "integer"
      },
      "pivot_columns": {
        "items": {
          "type": "integer"
        },
        "title": "Pivot Columns",
        "type": "array"
      },
      "free_columns": {
        "items": {
          "type": "integer"
        },
        "title": "Free Columns",
        "type": "array"
      },
      "particular_solution": {
        "anyOf": [
          {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          {
            "type": "null"
          }
        ],
        "title": "Particular Solution"
      },
      "nullspace_basis": {
        "items": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "title": "Nullspace Basis",
        "type": "array"
      },
      "reduced_augmented_matrix": {
        "items": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "title": "Reduced Augmented Matrix",
        "type": "array"
      },
      "residual": {
        "anyOf": [
          {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          {
            "type": "null"
          }
        ],
        "title": "Residual"
      }
    },
    "required": [
      "status",
      "rank",
      "variables",
      "pivot_columns",
      "free_columns",
      "particular_solution",
      "nullspace_basis",
      "reduced_augmented_matrix",
      "residual"
    ],
    "title": "LinearResult",
    "type": "object"
  },
  "icons": null,
  "annotations": {
    "title": null,
    "readOnlyHint": true,
    "destructiveHint": false,
    "idempotentHint": true,
    "openWorldHint": false
  },
  "meta": null,
  "execution": null
}

Run the example to see the actual result.

HTTP alternative

POST https://app.getsupers.com/sites/agent-linear-system/call
Content-Type: application/json

{
  "coefficients": [
    [
      2,
      1,
      -1
    ],
    [
      -3,
      -1,
      2
    ],
    [
      -2,
      1,
      2
    ]
  ],
  "constants": [
    8,
    -11,
    -3
  ]
}

The HTTP and MCP interfaces execute the same implementation. Validation errors are returned explicitly. See the tool notes above for its supported inputs and behavior.

Exact elimination distinguishes a solution from inconsistent equations

Read the explanation

The supplied system has three equations in three variables. Coefficients in its first row are two, one and negative one with right hand side eight. A solution x two, y three and z negative one gives contributions four, three and one, summing eight. At thirty pixels per contribution those bars measure one hundred twenty, ninety and thirty. These calculations verify a proposed fixture solution without executing the saved API. The input schema requires exact integers or quoted rational values rather than JSON floating point values. Substitute the same solution into the second equation: negative three times two, minus three and twice negative one sum negative eleven. The third equation is negative two times two plus three plus twice negative one, giving negative three. All three residuals are zero. Matrix determinant is negative one, so the three independent equations give a unique solution and no free variables. At eighty pixels per count three variables and rank three each measure two hundred forty while free variable count zero has zero width. Exact zero residual checks algebra rather than measurements or least squares. The documented contract also handles infinite and inconsistent systems. A hypothetical pair x plus y equals two and twice x plus twice y equals four has rank one and two variables, leaving one free parameter. Changing the second right hand side to five yields zero equals one after elimination, so no particular solution exists. At one hundred pixels per count variables two measure two hundred, rank one one hundred and free parameter one one hundred. Inconsistent output may still return a basis for homogeneous A x equals zero. This is explanatory algebra, not a new backend result. The shared app is missing in the saved offline page, so actual solver requests remain unverified.

Exact Linear-System Solver via Rational Elimination

How does exact rational elimination solve linear systems without rounding errors, and how are infinite or inconsistent systems identified?

This tool solves linear systems A*x = b using Gauss-Jordan elimination over exact rational numbers rather than standard binary floating-point numbers. Every coefficient and constant is converted into a reduced fraction, eliminating rounding drift and cancellation errors. The algorithm reduces the augmented matrix [A | b] to reduced row echelon form (RREF) to identify the rank, pivot columns, and free columns. It distinguishes unique solutions, parametric infinite solution spaces spanned by a nullspace basis, and inconsistent equations where a pivot appears in the augmented constants column.

This implementation is designed for small exact rational linear systems. It does not perform least-squares fitting or handle overdetermined noisy observational data. Because rational arithmetic maintains arbitrary-precision integer numerators and denominators, large or dense systems can experience intermediate coefficient growth. Binary floating-point values are rejected by schema to ensure exact parsing.

Try a worked example

Leaving the preset 3x3 system in the 'JSON arguments' textarea and clicking 'Run tool' executes the elimination. The tool returns status 'unique' with rank 3, pivot columns [0, 1, 2], an empty free column list, and particular_solution ["2", "3", "-1"]. The exact residual vector is ["0", "0", "0"], confirming that A * [2, 3, -1]^T exactly equals [8, -11, -3]^T without floating-point approximations.

Exact Rational Representation and Fraction Parsing

Floating-point numbers in standard IEEE-754 binary arithmetic cannot represent numbers like 1/3 or 0.1 exactly without rounding errors. The Python fractions module represents rational numbers as exact pairs of coprime integers (numerator and positive denominator). fractions — Rational numbers — Python 3.14.8 documentation

The solver parses integer and finite decimal or fraction strings directly into Fraction instances. Strings with slashes or decimal points convert precisely into reduced rational values, enabling exact algebraic operations throughout row reduction. fractions — Rational numbers — Python 3.14.8 documentation

Gauss-Jordan Elimination and Solution Classification

The solver augments matrix A with vector b and iteratively finds non-zero pivot elements to scale rows and eliminate column entries above and below each pivot. If a pivot occurs in the augmented rightmost column (column index n), the system represents 0 = 1 and is classified as inconsistent.

When consistent, columns without pivots are marked as free variables. For each free variable, a basis vector for the nullspace is constructed, allowing all infinite solutions to be represented as x = particular_solution + sum(t_i * nullspace_basis[i]) with rational parameters t_i.

Sources and further reading