Calculation methods

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

Matrix representation of two linear equations with the solution x equals two and y equals one.
2x + y = 5; x − y = 1 → x = 2, y = 1. Illustration, not a live result.

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.

Substitution check for the worked example
EquationSubstitute x = 2, y = 1Residual
2x + y = 52 × 2 + 1 − 50
x − y = 12 − 1 − 10
Check the assumptions. These are educational examples. A conversion or formula does not validate its inputs or replace professional advice. Read the limitations.
All calculation guides