# How do I solve a system of equations?

Solves a system of up to 4 linear equations in up to 4 unknowns (x, y, z, w) by Gauss-Jordan elimination in exact fractions: one solution, infinitely many, or none.

- Page: https://www.acalculator.org/math/system-of-equations-calculator
- JSON spec: https://www.acalculator.org/math/system-of-equations-calculator.json
- Version: 783ef7fe1cb8

## Default answer

Example with the default inputs (Equations [1, 1, 1, 6; 0, 2, 5, -4; 2, 5, -1, 27]): Solving x + y + z = 6; 2y + 5z = -4; 2x + 5y - z = 27 gives: x = 5, y = 3, z = -2.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| m | Equations | One row per equation: the coefficients of x, y, z, w in order, then the constant on the right of the equals sign in the last column. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| solution | Solution | The values of the unknowns as exact fractions, the general solution, or No solution. |
| decimal | Solution in decimals | A single solution in decimals, each rounded half up to 10 significant figures. |
| kind | Number of solutions | One solution, Infinitely many solutions, or No solution. |
| equations | Your equations | The system as read from the grid, one equation per row. |
| steps | Row operations | The Gauss-Jordan row operations on the augmented matrix, in order. |

## Method

Gauss-Jordan elimination on the augmented matrix [A | b] to reduced row echelon form; a pivot in the constant column means no solution, a pivot in every unknown column one solution, and fewer pivots infinitely many.

## Assumptions

- Every coefficient and constant is read as an exact fraction (1/3 is 1/3, 0.1 is 1/10), so the solution has no rounding error.
- The unknowns are x, y, z, w in that order, one column each; the last column holds the constants.
- The pivot in each column is the first row, from the top of the rows not yet used, with a non-zero entry.

## Worked examples

1. m = 1 or 1 or 0 or 2 gives solution = x = 5, y = 3, z = -2, decimal = x = 5, y = 3, z = -2, kind = One solution, equations = x + y + z = 6; 2y + 5z = -4; 2x + 5y - z = 27. Source: OpenStax, College Algebra 2e, §7.1 and §7.2, systems of linear equations (https://openstax.org/books/college-algebra-2e/pages/7-1-systems-of-linear-equations-two-variables).
2. m = 2 or 3 or 1 or -1 gives solution = x = 2, y = 1, kind = One solution, steps = R1 → 1/2 × R1; R2 → R2 − R1; R2 → -2/5 × R2; R1 → R1 − 3/2 × R2.
3. m = 1 or 2 or 3 or -1 gives solution = x = 8/7, y = 10/7, decimal = x = 1.142857143, y = 1.428571429.
4. m = 1 or 1 or 2 or 2 gives solution = No solution, kind = No solution.
5. m = 1 or 2 or 2 or 4 gives solution = x = 1 - z, y = 1 + z, z is any number, kind = Infinitely many solutions.
6. m = 0.5 or 0.333333 or 0.25 or -1 gives solution = x = 20/7, y = -9/7.
7. m = 1 or 1 or 1 or -1 gives solution = x = 1, y = 2, z = 3, w = 4.

## FAQ

### How do I type my equations?

One row per equation, one column per unknown, and the constant last. 2x + 3y = 7 and x − y = 1 become the rows 2, 3, 7 and 1, −1, 1. Use 0 for a missing unknown: y + z = 4 in three unknowns is 0, 1, 1, 4. Move every unknown to the left side first.

### How does the elimination method work?

Add multiples of one equation to another to remove an unknown, until each equation has one unknown left. The calculator does this on the grid of numbers (Gauss-Jordan elimination) and lists every step, such as R2 → R2 − R1 (subtract row 1 from row 2).

### What does "infinitely many solutions" mean?

The equations do not pin every unknown down, because some of them repeat the others. The calculator then writes the answer with free unknowns: x = 1 − z, y = 1 + z, z is any number. Each value of z gives one solution.

### What does "no solution" mean?

The equations contradict each other. x + y = 2 and 2x + 2y = 5 cannot both be true, because doubling the first gives 2x + 2y = 4. On a graph, the lines are parallel and never meet.

### Can I solve by substitution instead?

Yes, and you get the same answer. For 2x + 3y = 7 and x − y = 1: x = 1 + y, so 2(1 + y) + 3y = 7, 5y = 5, y = 1, and x = 2. Elimination is easier to carry out for three or four unknowns.

### Why are the answers fractions?

Solving linear equations with whole numbers gives exact fractions, such as x = 8/7. The calculator works in exact fractions so nothing is lost to rounding, and shows decimals too (8/7 = 1.142857143).

### Can I have more equations than unknowns?

Yes. Up to 4 equations in 1 to 4 unknowns. Extra equations are fine if they agree with the others; if one contradicts them, there is no solution.

## Sources

- OpenStax, College Algebra 2e, §7.1 Systems of Linear Equations: Two Variables and §7.2 Systems of Linear Equations: Three Variables. https://openstax.org/books/college-algebra-2e/pages/7-1-systems-of-linear-equations-two-variables
- OpenStax, College Algebra 2e, §7.6 Solving Systems with Gaussian Elimination (augmented matrices, row operations). https://openstax.org/books/college-algebra-2e/pages/7-6-solving-systems-with-gaussian-elimination
- Gilbert Strang, Introduction to Linear Algebra, 5th edition (2016), §3.3 The Complete Solution to Ax = b.
