Linear Equation Solver

Solve two- or three-variable simultaneous equations with exact elimination steps and unique, infinite or no-solution results.

Enter your values

Change any field. The result is recalculated on this device.

Formula, example and assumptions
SolutionOne unique solution
Number of variables

One row per equation. Example: 1 1 5 means x + y = 5. Separate numbers with spaces or commas; enter 0 for a missing term.

Your result

Local calculation
SolutionOne unique solution

The solution must satisfy every entered equation at once. The result identifies one solution, infinitely many or none, and shows variable values when there is one unique solution.

Number of variables
Two: x and y
See how this is calculated

Result breakdown

Independent equations
2
x
2
y
3
Maximum relative substitution error
0
View exact elimination and substitution

Swipe or scroll to see every column.

Exact elimination and substitution
StepWorking

Each row lists the x, y (and z) coefficients followed by the right-hand value. Elimination uses exact fractions for the entered finite decimal numbers, so a nonzero pivot is never discarded because it is small. Classification uses exact zero, not a floating-point rank tolerance. Unique solutions are also checked at 80 significant digits with a relative substitution tolerance of 10⁻¹² (residual ÷ sum of absolute equation terms). Long fractions are displayed to 12 significant digits. Near-dependent equations remain sensitive to rounding in your original measurements.

Check the inputs and method

These are your current inputs, not the worked example further down the page.

Number of variables
Two: x and y
Two equation rows: x coefficient, y coefficient, result
1 1 5 2 -1 1

Method

Apply exact elementary row operations to the augmented matrix [A | b]. A nonzero pivot isolates a variable. A row 0 = nonzero is inconsistent; fewer pivots than variables with no contradiction means free variables and infinitely many solutions. A pivot for every variable gives a unique solution, verified by substitution.

Read the worked example and assumptions

How this calculation works

Each entered equation becomes one row of an augmented matrix. Swapping rows, dividing a row by a nonzero pivot and subtracting a multiple of one row from another preserve the solution set. The calculator shows those exact operations, then distinguishes a unique solution from free variables or a contradictory row.

Apply exact elementary row operations to the augmented matrix [A | b]. A nonzero pivot isolates a variable. A row 0 = nonzero is inconsistent; fewer pivots than variables with no contradiction means free variables and infinitely many solutions. A pivot for every variable gives a unique solution, verified by substitution.

Worked example

This example uses illustrative inputs. Your current result is shown above.

For x + y = 5 and 2x − y = 1, subtract twice the first equation from the second: −3y = −9, so y = 3. Substituting in x + y = 5 gives x = 2. Checks: 2 + 3 = 5 and 2×2 − 3 = 1. The three-variable default has x = 1, y = 2 and z = 3.

Assumptions and limits

  • Provide exactly two equations in two variables or three equations in three variables. Every row includes a coefficient for each variable followed by the right-hand value.
  • Finite decimal inputs are interpreted through their JavaScript numeric values, with about 15–17 significant digits. Rescale an equation if its input numbers exceed this range.
  • Exact rational elimination determines rank and contradictions without discarding small nonzero pivots. Fractions are retained when short; long values are displayed to 12 significant digits.
  • A unique solution is additionally checked with 80 significant digits. Relative substitution error must not exceed 10⁻¹², using the sum of the absolute equation terms as denominator.
  • An exact answer to the entered decimals cannot recover precision already lost in rounded measurements. Near-dependent systems can be very sensitive to that rounding.

Questions people ask

How do I enter 2x − y + 3z = 7?

Choose three variables and enter 2 -1 3 7 on one line. Enter the other two equations on separate lines, using 0 for a missing coefficient. The final number in each row is the right-hand value.

What creates infinitely many solutions?

Some equations repeat information already supplied by others. For x + y = 2 and 2x + 2y = 4, one equation is redundant: y can be any value and x = 2 − y. The reduced rows identify the free variables.

What creates no solution?

The equations contradict each other. For x + y = 2 and 2x + 2y = 5, elimination produces 0 = 1. No values of x and y can satisfy both original equations.

Can small coefficients be mistaken for zero?

The solver uses exact fractions formed from the entered finite decimal numbers. It does not discard small nonzero pivots using a rank tolerance. It also substitutes unique solutions numerically at 80 significant digits and checks relative error against 10⁻¹².

Related calculators