Solving Two Linear Equations: Ax = b, Worked
A linear system can be written as a coefficient matrix multiplied by an unknown vector. This makes the relationship between equations explicit and allows the solution to be checked by substituting it back into every original equation.
Worked example · Updated

Build the coefficient matrix
For 2x + y = 5 and x − y = 1, the coefficient rows are [2, 1] and [1, −1]. The right-hand side is the column [5, 1]. Keep the order of unknowns identical in both rows.
In the calculator, semicolons separate matrix rows. Enter lusolve([2, 1; 1, -1], [5; 1]) and press Calculate. The returned column [[2], [1]] corresponds to x = 2 and y = 1.
Verify rather than assume
Substitute the result into both equations: 2 × 2 + 1 = 5 and 2 − 1 = 1. Each left side matches its right side, so both residuals are zero for this example.
A small residual can help check a computed answer, but it does not by itself prove that a poorly conditioned system has an accurate solution.
Understand the limitations
A singular coefficient matrix does not have a unique solution. Nearly dependent equations can also amplify measurement or rounding errors. Do not assume every matrix can be inverted or every linear system has one answer.
Use consistent units and retain enough input precision. For larger or safety-critical work, compare with an independently verified method.
| Equation | Substitute x = 2, y = 1 | Residual |
|---|---|---|
| 2x + y = 5 | 2 × 2 + 1 − 5 | 0 |
| x − y = 1 | 2 − 1 − 1 | 0 |
Continue exploring
Compound interest: formula, assumptions and worked example
Explore P(1 + r/n)^(nt) with a worked monthly-compounding example. Learn rate conventions and assumptions, then open the formula with values already filled in.
MB vs MiB: Decimal vs Binary Data Sizes Explained
Understand why a megabyte differs from a mebibyte. Compare bytes, MB and MiB, then convert decimal and binary storage sizes.