How do I solve a system of equations?
Type one equation per row (the numbers in front of x, y, z, w, then the number after the equals sign). The system of equations calculator solves it exactly and shows the row operations.
- Solution
- x = 5, y = 3, z = -2
Solving x + y + z = 6; 2y + 5z = -4; 2x + 5y - z = 27 gives: x = 5, y = 3, z = -2.
- Solution in decimals
- x = 5, y = 3, z = -2
- Number of solutions
- One solution
- Your equations
- x + y + z = 6; 2y + 5z = -4; 2x + 5y - z = 27
- Row operations
- R3 → R3 − 2 × R1; R2 → 1/2 × R2; R1 → R1 − R2; R3 → R3 − 3 × R2; R3 → -2/21 × R3; R1 → R1 + 3/2 × R3; R2 → R2 − 5/2 × R3
Solution: x = 5, y = 3, z = -2. Solving x + y + z = 6; 2y + 5z = -4; 2x + 5y - z = 27 gives: x = 5, y = 3, z = -2.
Which row operations solve it?
How to calculate
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.
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.
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.
- 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
Each example is checked against the calculator on every build.
- Equations 1, 1, 1, 6; 0, 2, 5, -4; 2, 5, -1, 27 gives Solution x = 5, y = 3, z = -2, Solution in decimals x = 5, y = 3, z = -2, Number of solutions One solution, Your 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)
- Equations 2, 3, 7; 1, -1, 1 gives Solution x = 2, y = 1, Number of solutions One solution, Row operations R1 → 1/2 × R1; R2 → R2 − R1; R2 → -2/5 × R2; R1 → R1 − 3/2 × R2.
- Equations 1, 2, 4; 3, -1, 2 gives Solution x = 8/7, y = 10/7, Solution in decimals x = 1.142857143, y = 1.428571429.
- Equations 1, 1, 2; 2, 2, 5 gives Solution No solution, Number of solutions No solution.
- Equations 1, 2, -1, 3; 2, 4, -2, 6; 1, 0, 1, 1 gives Solution x = 1 - z, y = 1 + z, z is any number, Number of solutions Infinitely many solutions.
- Equations 0.5, 0.333333, 1; 0.25, -1, 2 gives Solution x = 20/7, y = -9/7.
- Equations 1, 1, 1, 1, 10; 1, -1, 0, 0, -1; 0, 1, -1, 0, -1; 0, 0, 1, -1, -1 gives Solution x = 1, y = 2, z = 3, w = 4.
How it works
The grid is the augmented matrix [A | b] of the system: each row is one equation, the columns before the last hold the coefficients of x, y, z, and w (in that order, 1 to 4 unknowns), and the last column holds the constant on the right of the equals sign. There can be 1 to 4 equations.
The calculator runs Gauss-Jordan elimination to reduced row echelon form, in exact fractions. Going through the columns from left to right:
- The pivot is the first row, from the top of the rows not used yet, with a non-zero entry in that column. A column with no such row is skipped.
- If the pivot row is not the top unused row, the two rows swap.
- The pivot row is divided by its pivot, so the pivot becomes 1 (left out when it is already 1).
- Every other row with a non-zero entry in that column has the right multiple of the pivot row subtracted, so its entry becomes 0.
Then:
- No solution when a pivot is in the constant column (a row reads 0 = 1).
- One solution when every unknown's column has a pivot: each unknown equals the constant in its pivot row.
- Infinitely many solutions otherwise. The unknowns without a pivot are free. Each pivot unknown equals the constant of its row minus each free unknown times that row's entry in the free unknown's column.
Exact fractions
Each cell is read as an exact fraction: the fraction nearest to its number with a bottom of at most 1,000,000, when that fraction rounds to the same 64-bit float (so a cell typed as 1/3 is exactly 1/3, as in Python's Fraction(x).limit_denominator(10**6)); otherwise its shortest decimal, exactly (0.1 is 1/10).
How the answer is written
- Solution, one solution:
x = 5, y = 3, z = -2: each unknown in order, a fraction in lowest terms (such as8/7,-9/7) or a whole number. - Solution, infinitely many: each pivot unknown in order as
x = <constant> <terms>, then the free unknowns:x = 1 - z, y = 1 + z, z is any number(with two or three free unknowns:z and w are any numbers,y, z and w are any numbers). The constant comes first and is left out when it is 0 and there are terms; each term is+or-and the coefficient's size in front of the unknown's name, with a coefficient of 1 left out, a whole coefficient written as2z, and a fraction in brackets as(1/2)z. A first term that is negative starts with-, such asx = -2z. With every term 0, it readsx = 0. - Solution, no solution:
No solution. - Solution in decimals (one solution only): the same, with each value rounded half up (away from zero) to 10 significant figures from its exact value, trailing zeros dropped, written like a JavaScript number (plain from 0.000001 up to below 10²¹, else e notation).
- Number of solutions:
One solution,Infinitely many solutions, orNo solution. - Your equations: each row as an equation, rows separated by
;, written like the terms above with the constant after=:x + y + z = 6; 2y + 5z = -4; 2x + 5y - z = 27. A row with every coefficient 0 reads0 = <constant>. - Row operations, separated by
;, rows counted from 1: a swap asR1 ↔ R2; dividing a row asR1 → 1/2 × R1(the factor that multiplies the row); and subtracting m times row j from row i asRi → Ri − m × Rj(+when adding), with m a fraction in lowest terms left out when it is 1. At most 30 are listed, thenand N more. With no operation needed, the steps readThe matrix is already reduced.
Worked examples by hand
x + y + z = 6, 2y + 5z = −4, 2x + 5y − z = 27. R3 − 2R1 gives 3y − 3z = 15, so y − z = 5. With 2y + 5z = −4: 2(z + 5) + 5z = −4, 7z = −14, z = −2, so y = 3 and x = 6 − 3 + 2 = 5. x = 5, y = 3, z = −2. Check: 2 × 5 + 5 × 3 − (−2) = 27.
2x + 3y = 7, x − y = 1. Divide row 1 by 2: x + (3/2)y = 7/2. Subtract it from row 2: −(5/2)y = −5/2. Divide by −5/2: y = 1. Subtract 3/2 × row 2 from row 1: x = 2. x = 2, y = 1. Steps: R1 → 1/2 × R1; R2 → R2 − R1; R2 → -2/5 × R2; R1 → R1 − 3/2 × R2.
x + 2y = 4, 3x − y = 2. By Cramer's rule, D = 1 × (−1) − 2 × 3 = −7, x = (4 × (−1) − 2 × 2) ÷ −7 = 8/7, y = (1 × 2 − 4 × 3) ÷ −7 = 10/7. In decimals, 1.142857143 and 1.428571429.
x + y = 2, 2x + 2y = 5. Row 2 − 2 × row 1 gives 0 = 1: No solution.
x + 2y − z = 3, 2x + 4y − 2z = 6, x + z = 1. Row 2 is twice row 1, so there are only two independent equations. From x + z = 1, x = 1 − z; then 2y = 3 − x + z = 2 + 2z, so y = 1 + z. x = 1 − z, y = 1 + z, z is any number.
x/2 + y/3 = 1, x/4 − y = 2 (typed as 0.5, 1/3, 1 and 0.25, −1, 2). From the second, x = 8 + 4y; then (8 + 4y)/2 + y/3 = 1, so 7y/3 = −3, y = −9/7, and x = 8 − 36/7 = 20/7.
Four unknowns: x + y + z + w = 10, x − y = −1, y − z = −1, z − w = −1. So y = x + 1, z = x + 2, w = x + 3, and 4x + 6 = 10: x = 1, y = 2, z = 3, w = 4.
Other questions people ask
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.