# System of Linear Equations Solver

> Solves a system of 2 or 3 linear equations with as many unknowns from its coefficient matrix and constants using Cramer's rule, reports the determinants involved, and uses Gaussian elimination to tell a system with no solution from one with infinitely many.

- Calculator id: `linear-system` · Category: Math (`math`) · Tool name: `solve_linear_system`
- Canonical page: https://tttkmbb.com/math/linear-system · This document: https://tttkmbb.com/math/linear-system.md · JSON definition: https://tttkmbb.com/math/linear-system.json

## Purpose

Solves a system of 2 or 3 linear equations with as many unknowns from its coefficient matrix and constants using Cramer's rule, reports the determinants involved, and uses Gaussian elimination to tell a system with no solution from one with infinitely many.

**Use when:** You have 2 or 3 linear equations in 2 or 3 unknowns (x, y, z) with numeric coefficients and need the unique solution or a diagnosis of why there is none.

**Do not use when:** The system has more than 3 unknowns, is non-linear, or you only need the line through two points (use slope) or a determinant on its own (use matrix-determinant).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `coefficients` | number_list |  | required | Coefficients of x, y (and z) equation by equation, 4 values for a 2×2 system or 9 for a 3×3 system. For 2x + y − z = 8 the first row is 2, 1, −1. |
| `constants` | number_list |  | required | The constant term of each equation, in the same order. |
| `size` | integer |  | optional | 2 or 3. Optional: inferred from the number of constants when omitted. (min 2, max 3) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `x` | number |  | Value of the first unknown, D_x / D. |
| `y` | number |  | Value of the second unknown, D_y / D. |
| `z` | number |  | Value of the third unknown, D_z / D (3×3 systems only). |
| `solution` | number_list |  | [x, y] or [x, y, z]. |
| `solution_text` | string |  | The solution written as 'x = …, y = …, z = …'. |
| `determinant` | number |  | Determinant of the coefficient matrix; non-zero for a unique solution. |
| `cramer_determinants` | number_list |  | [D_x, D_y, (D_z)]: determinants with the respective column replaced by the constants. |

## Formula

`D = det(A); D_i = det(A with column i replaced by the constants b); x_i = D_i / D (Cramer's rule). D = 0: rank(A) < rank([A|b]) → no solution, rank(A) = rank([A|b]) < n → infinitely many solutions`

## Data Sources

- Wikipedia – Cramer's rule — https://en.wikipedia.org/wiki/Cramer%27s_rule (reference, retrieved 2026-09-24)
- Wikipedia – Gaussian elimination — https://en.wikipedia.org/wiki/Gaussian_elimination (reference, retrieved 2026-09-24)
- Wolfram MathWorld – Cramer's Rule — https://mathworld.wolfram.com/CramersRule.html (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/linear-system?coefficients=…&constants=…`
- `POST https://tttkmbb.com/api/v1/calculate/linear-system` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/linear-system · OpenAPI operationId `solve_linear_system` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "linear-system", "inputs": {…}}`

## Example

- 2x + y − z = 8, −3x − y + 2z = −11, −2x + y + 2z = −3: inputs `{"coefficients":[2,1,-1,-3,-1,2,-2,1,2],"constants":[8,-11,-3],"size":3}` → `{"x":2,"y":3,"z":-1,"solution":[2,3,-1],"solution_text":"x = 2, y = 3, z = -1","determinant":-1,"cramer_determinants":[-2,-3,1]}`
- x + y = 10, x − y = 2: inputs `{"coefficients":[1,1,1,-1],"constants":[10,2]}` → `{"x":6,"y":4,"solution":[6,4],"solution_text":"x = 6, y = 4","determinant":-2,"cramer_determinants":[-12,-8]}`

```
GET https://tttkmbb.com/api/v1/calculate/linear-system?coefficients=2%2C1%2C-1%2C-3%2C-1%2C2%2C-2%2C1%2C2&constants=8%2C-11%2C-3&size=3
```

## Limitations

The system has more than 3 unknowns, is non-linear, or you only need the line through two points (use slope) or a determinant on its own (use matrix-determinant). All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**How do I enter the equations?**

Write each equation as ax + by (+ cz) = k with every unknown present (use 0 for a missing one) and list the coefficients row by row, then the k values in the same order.

**What does 'no unique solution' mean?**

The determinant is 0, so the equations are dependent or contradictory; the error message says whether the system has no solution (inconsistent) or infinitely many.

## Related

- [Matrix Determinant Calculator](https://tttkmbb.com/math/matrix-determinant.md) — The determinant that decides whether the solution is unique.
- [Matrix Inverse Calculator](https://tttkmbb.com/math/matrix-inverse.md) — Solve A·x = b as x = A⁻¹·b.
- [Slope Calculator](https://tttkmbb.com/math/slope.md) — A single linear equation through two points.
