System of Linear Equations Solver
Exact answers to 2 × 2 and 3 × 3 systems, with every row operation and a check.
Results
Solution
x = 3, y = 4, z = 5
The three planes meet at one point, (3, 4, 5).
- Determinant D
- −1Not 0, so exactly one solution
- Rank of A and of [A | b]
- 3 and 3Both equal the 3 unknowns
- Equations satisfied
- 3 of 3Checked exactly by substitution
| Equation | Left side with the values | Left side | Right side | Holds |
|---|---|---|---|---|
| Equation 1 | 1 × 3 + 2 × 4 + 1 × 5 | 16 | 16 | Yes |
| Equation 2 | 1 × 3 + 1 × 4 + 2 × 5 | 17 | 17 | Yes |
| Equation 3 | 2 × 3 + 3 × 4 + 4 × 5 | 38 | 38 | Yes |
How this was solved
- Write the system as the augmented matrix [A | b]: one row per equation, one column per unknown (x, y and z), and the right sides after the bar.
- Row-reduce it with 7 row operations (listed below) to reduced row-echelon form: each pivot is 1 and is the only nonzero entry in its column.
- rank(A) = 3 and rank([A | b]) = 3, the number of unknowns, so there is exactly one solution.
- Read it from the last column: x = 3, y = 4, z = 5.
- Determinant: D = 1 × (1 × 4 − 2 × 3) − 2 × (1 × 4 − 2 × 2) + 1 × (1 × 3 − 1 × 2) = 1 × (−2) − 2 × 0 + 1 × 1 = −1. It isn't 0, which also means exactly one solution; Cramer's rule gives the same values.
- Check: substituting the values into every equation gives its right side (table above).
Every step: row operations and Cramer's rule
Each step names the row operation; the row it changes is highlighted. The last matrix is the reduced row-echelon form (RREF).
Start: [A | b] x y z Right side R1 1 2 1 16 R2 1 1 2 17 R3 2 3 4 38 Step 1: R2 ← R2 − R1 x y z Right side R1 1 2 1 16 R2 (changed) 0 −1 1 1 R3 2 3 4 38 Subtract R1 from R2 to make its x entry 0.
Step 2: R3 ← R3 − 2R1 x y z Right side R1 1 2 1 16 R2 0 −1 1 1 R3 (changed) 0 −1 2 6 Subtract 2 × R1 from R3 to make its x entry 0.
Step 3: R2 ← −R2 x y z Right side R1 1 2 1 16 R2 (changed) 0 1 −1 −1 R3 0 −1 2 6 Multiply R2 by −1 so its y entry becomes 1.
Step 4: R1 ← R1 − 2R2 x y z Right side R1 (changed) 1 0 3 18 R2 0 1 −1 −1 R3 0 −1 2 6 Subtract 2 × R2 from R1 to make its y entry 0.
Step 5: R3 ← R3 + R2 x y z Right side R1 1 0 3 18 R2 0 1 −1 −1 R3 (changed) 0 0 1 5 Add R2 to R3 to make its y entry 0.
Step 6: R1 ← R1 − 3R3 x y z Right side R1 (changed) 1 0 0 3 R2 0 1 −1 −1 R3 0 0 1 5 Subtract 3 × R3 from R1 to make its z entry 0.
Step 7: R2 ← R2 + R3 x y z Right side R1 1 0 0 3 R2 (changed) 0 1 0 4 R3 0 0 1 5 Add R3 to R2 to make its z entry 0.
Replace one column of A at a time by the right sides and divide each determinant by D (OpenStax College Algebra 2e, §7.8).
D: the coefficients A x y z R1 1 2 1 R2 1 1 2 R3 2 3 4 D = 1 × (1 × 4 − 2 × 3) − 2 × (1 × 4 − 2 × 2) + 1 × (1 × 3 − 1 × 2) = 1 × (−2) − 2 × 0 + 1 × 1 = −1
Dx: the x column replaced by the right sides x y z R1 16 2 1 R2 17 1 2 R3 38 3 4 Dx = 16 × (1 × 4 − 2 × 3) − 2 × (17 × 4 − 2 × 38) + 1 × (17 × 3 − 1 × 38) = 16 × (−2) − 2 × (−8) + 1 × 13 = −3
x = Dx ÷ D = −3 ÷ (−1) = 3
Dy: the y column replaced by the right sides x y z R1 1 16 1 R2 1 17 2 R3 2 38 4 Dy = 1 × (17 × 4 − 2 × 38) − 16 × (1 × 4 − 2 × 2) + 1 × (1 × 38 − 17 × 2) = 1 × (−8) − 16 × 0 + 1 × 4 = −4
y = Dy ÷ D = −4 ÷ (−1) = 4
Dz: the z column replaced by the right sides x y z R1 1 2 16 R2 1 1 17 R3 2 3 38 Dz = 1 × (1 × 38 − 17 × 3) − 2 × (1 × 38 − 17 × 2) + 16 × (1 × 3 − 1 × 2) = 1 × (−13) − 2 × 4 + 16 × 1 = −5
z = Dz ÷ D = −5 ÷ (−1) = 5
Assumptions
- Every number is kept as an exact fraction. Decimals you type are read exactly (0.1 is 1/10), so nothing is rounded along the way.
- Decimal values are rounded for display only (about 7 significant digits, marked ≈).
- A blank cell is never treated as 0. An unknown missing from an equation needs a 0 in its cell.
- Row reduction uses the first row from the top with a nonzero entry as each pivot, as you would by hand. Any other order of valid operations reaches the same reduced matrix and the same answer.
- Linear equations only: each unknown to the first power, with no products of unknowns.
Calculated in your browser. This site doesn't send or store the numbers you enter.
What this solver answers
It finds the values of the unknowns that make every equation of a system true at once: x and y for two linear equations, or x, y and z for three. The answer is exact, as fractions, with decimals beside them. When there isn’t exactly one answer, it names the case and shows why: no solution, with the combination of equations that contradicts itself, or infinitely many, with a formula that gives all of them.
How to enter your system
Choose the System size, then how to enter it:
- Grid: one box per number, laid out like the equation, [2] x + [3] y = [7]. Each box takes a whole number, a decimal such as 0.25 or a fraction such as -3/4 or 2 1/3. Move the unknowns to the left side and the plain number to the right before you type. The line under each equation reads it back, so a slip shows right away.
- Equations: type each equation as written, such as
2x + 3 = y - 4. Terms may come in any order, on either side; the solver collects them into standard form (here 2x − y = −7) and shows that under the box. Any letters work as unknowns, taken in alphabetical order, and3/4xmeans (3/4)x.
Switching between the two carries your system across. The Try buttons load the examples worked through on this page.
Missing terms and blank cells
If an equation doesn’t contain an unknown, its coefficient is 0: x + z = 4 is x + 0y + z = 4. In the grid, type that 0. A blank box is never read as 0, because it may be a number you haven’t typed yet. Blank boxes are dashed, and the result lists them with a Fill blank cells with 0 button for when every blank really is a missing term. Typed equations don’t need this: leaving y out of x + z = 4 already says its coefficient is 0.
Fractions and decimals stay exact
Every number is kept as a fraction, so 0.1 is exactly 1/10 and 1/3 is never cut to 0.333 partway through. Type 1/3 rather than 0.333: a rounded decimal is used exactly as typed, which gives the exact answer to a slightly different system, and a note under the box says so. The Fractions example solves (1/2)x + (1/3)y = 4 and 0.25x − y = −1; the answer is x = 44/7 and y = 18/7, shown beside their decimals, about 6.285714 and 2.571429.
Worked example: solving a 3 × 3 system step by step
A baker has 16 cups of sugar, 17 cups of butter and 38 cups of flour. A batch of cookies (x) takes 1 cup of sugar, 1 of butter and 2 of flour; a batch of muffins (y) takes 2, 1 and 3; a batch of scones (z) takes 1, 2 and 4. How many batches of each use everything up? One equation per ingredient:
-
Write the augmented matrix, one row per equation. Putting the sugar equation first gives a 1 in the top-left corner, which keeps the first steps free of fractions.
-
Clear the x column below the pivot: R2 ← R2 − R1 gives 0, −1, 1 | 1, and R3 ← R3 − 2R1 gives 0, −1, 2 | 6.
-
Make the y pivot 1: R2 ← −R2 gives 0, 1, −1 | −1.
-
Clear the rest of the y column: R1 ← R1 − 2R2 gives 1, 0, 3 | 18, and R3 ← R3 + R2 gives 0, 0, 1 | 5.
-
The z pivot is already 1. Clear its column: R1 ← R1 − 3R3 gives 1, 0, 0 | 3, and R2 ← R2 + R3 gives 0, 1, 0 | 4.
-
Each row now reads unknown = number: x = 3, y = 4, z = 5, so 3 batches of cookies, 4 of muffins and 5 of scones.
-
Check in every original equation: sugar 3 + 2 × 4 + 5 = 16, butter 3 + 4 + 2 × 5 = 17 and flour 2 × 3 + 3 × 4 + 4 × 5 = 38.
The calculator shows these seven row operations with the matrix after each one, and the same answer by Cramer’s rule: D = −1, Dx = −3, Dy = −4 and Dz = −5, so x = −3 ÷ (−1) = 3, y = 4 and z = 5.
How to solve a system of linear equations by elimination (row reduction)
Elimination adds multiples of one equation to another until each equation is left with one unknown. Row reduction does the same on the augmented matrix [A | b]: one row per equation, one column per unknown and the right sides after the bar. Three operations never change the solutions:
- swap two rows (R1 ↔ R2);
- multiply a row by a number other than 0 (R2 ← −R2);
- add a multiple of one row to another (R3 ← R3 − 2R1).
Work one column at a time. Take as the pivot the first row, from the top, with a nonzero entry in that column; make the pivot 1; then clear every other entry in its column. At the end, in reduced row-echelon form, each pivot is 1 and the only nonzero entry in its column, so the rows read x = …, y = …, z = ….
If the pivot position holds a 0, swap in a row below it first. The Row swap example starts with 2y + z = 7, which has no x term, so its first step is R1 ↔ R2; it ends at x = 1, y = 2, z = 3.
Turning a word problem into a system
Give each quantity the question asks for its own letter, then write one equation for each fact that links them, keeping the units the same on both sides. In the Coffee blend example, a roaster mixes beans costing $9 and $14 a pound into 20 pounds that should be worth $12 a pound. With x pounds of the $9 beans and y pounds of the $14 beans:
- weight: x + y = 20 (pounds);
- value: 9x + 14y = 12 × 20 = 240 (dollars).
The solution, x = 8 and y = 12, means 8 pounds of the cheaper beans and 12 of the pricier ones.
When a system has no solution
Row reduction then ends with a row that reads 0 = c, where c isn’t 0, and no values can make that true. Such a system is called inconsistent. With two unknowns the equations are parallel lines: the same slope and different intercepts. The No solution example, 2x − 3y = 6 and −4x + 6y = 5, has two lines of slope 2/3, and 2 × equation 1 + equation 2 gives 0x + 0y = 17.
With three unknowns the contradiction can take all three equations. In x + y + z = 2, x − y + 2z = 1 and 2x + 3z = 5, no two equations clash, but adding the first two gives 2x + 3z = 3 while the third says 2x + 3z = 5. The solver finds that combination and shows it: equation 1 + equation 2 − equation 3 gives 0x + 0y + 0z = −2. In the language of rank, the coefficients A have rank 2 but [A | b] has rank 3.
When a system has infinitely many solutions
Row reduction then leaves at least one unknown with no pivot and no contradiction. That unknown is free: give it any value t, and the other rows give the rest. In the Infinitely many example,
equation 3 is equation 1 + equation 2, so it adds nothing new: A and [A | b] both have rank 2, one less than the 3 unknowns. The reduced matrix leaves z free, and every solution, for any number t, is
t = 0 gives (−11, 6, 0) and t = 1 gives (−4, 3, 1), and both satisfy all three equations. With two unknowns this case means both equations describe the same line. If your textbook lets a different unknown be free, its formulas look different but describe the same points.
The determinant and Cramer’s rule
For a square system, the determinant D of the coefficients decides whether there is exactly one solution: D ≠ 0 means exactly one. Cramer’s rule then gives each unknown as a ratio of determinants,
- is the determinant of the coefficients; for two equations and it is .
- is the same determinant with the x column replaced by the right sides ; likewise and .
For the coffee blend, D = 1 × 14 − 1 × 9 = 5, Dx = 20 × 14 − 1 × 240 = 40 and Dy = 1 × 240 − 20 × 9 = 60, so x = 40 ÷ 5 = 8 and y = 60 ÷ 5 = 12. For a 3 × 3 system the steps expand each determinant along its first row, where is the coefficient in row i and column j:
When D = 0, Cramer’s rule would divide by zero, and D = 0 alone doesn’t tell you which of the other two cases you have: the no-solution and the infinitely-many examples above both have D = 0. The ranks decide, which is why the solver always row-reduces as well.
Checking the answer by substitution
Put the values back into every original equation; each left side must come out exactly equal to its right side. The results do this for every equation, with the products written out, such as 1 × 3 + 2 × 4 + 1 × 5 = 16 for the sugar equation above. Because the arithmetic is exact, a check that holds really holds. Rounded decimals such as 6.285714 miss by a little, so substitute the fractions when you check by hand.
Reading the result
- The headline gives the solution, or “Infinitely many” with the general solution, or “None” with the contradiction that rules it out.
- The tiles give the determinant, the ranks of A and [A | b] that decide the case, and a check count, the free unknowns or the contradiction.
- The tables hold the solution as fractions and decimals, the check by substitution, the general solution at t = 0 and t = 1, or the combination of equations that reads 0 = c. Each downloads as CSV; fractions are written with a fraction slash (44⁄7) so that a spreadsheet keeps them as text instead of reading them as dates.
- The graph (2 × 2 only) draws both equations as lines, with the crossing point, or shows them parallel or on top of each other, plus each line’s slope-intercept form.
- How this was solved lists the reasoning, and the tabs underneath show every row operation with its matrix, and Cramer’s rule. Save for comparison keeps up to three systems side by side.
Assumptions and limitations
- Linear equations only: every unknown to the first power, with no products such as xy and no unknown in a denominator.
- Square systems of 2 or 3 equations in as many unknowns.
- Each number may have up to 15 digits above and below the fraction bar. Within that, everything is exact; decimals are rounded for display only, to about 7 significant digits, and marked ≈.
- Row reduction uses the hand method, pivoting on the first nonzero entry from the top. With exact fractions the order of the row operations can’t add rounding error, and every valid order leads to the same answer.
Common mistakes
- Leaving a missing term blank instead of typing 0, or typing a coefficient in the wrong column when the terms are in another order: for 3y + 2x = 7, the x box gets 2 and the y box 3.
- Using the grid before rearranging. 2x = 7 − 3y must become 2x + 3y = 7; a term changes sign when it moves across the = sign.
- Reading D = 0 as “no solution”. It means “not exactly one solution”; the system may have infinitely many.
- Rounding partway through. Writing 1/3 as 0.33 in a middle step can turn an exact answer into a nearly right one, or hide a contradiction.
- Checking only one equation. A solution has to satisfy every equation; a value that fits one line may miss the other.
Questions
Are simultaneous equations the same as a system of equations?
Yes. Simultaneous equations are equations that must all be true at the same time, which is exactly what a system of equations is. Their solution is the set of values that satisfies every equation at once, and that is what this solver finds.
Which method should I use: substitution, elimination or matrices?
They all give the same answer, so use the one your course asks for. Substitution is quickest when an equation already reads x = … or has a coefficient of 1. Elimination suits two equations whose coefficients line up. Row reduction is elimination written as a grid of numbers, and it works the same way for three or more unknowns, which is why the steps here use it. Cramer’s rule is neat for a 2 × 2 with whole numbers but fails whenever the determinant is 0.
Can I solve two equations in three unknowns, or three equations in two?
Not here; this solver takes square systems, 2 × 2 and 3 × 3. Two equations in three unknowns can’t pin down a single point, so they have no solution or infinitely many. Three equations in two unknowns have a solution only when the third agrees with the other two; solve any two of them here, then substitute the answer into the third to see whether it holds.
What if my equation has unknowns on both sides?
Choose Equations under Enter as and type it as written. The solver moves every unknown to the left and every number to the right, so 2x + 3 = y − 4 is read as 2x − y = −7. To use the grid instead, rearrange it that way yourself first.
Sources
- College Algebra 2e, 7.1 Systems of Linear Equations: Two Variables OpenStax (Rice University) A solution is an ordered pair that satisfies every equation, checked by substituting it back; independent systems cross at one point, dependent systems are the same line (infinitely many solutions), and inconsistent systems are parallel lines with no solution.
- College Algebra 2e, 7.2 Systems of Linear Equations: Three Variables OpenStax (Rice University) A solution of a 3 × 3 system is an ordered triple where three planes meet; three-variable systems can also be inconsistent or dependent.
- College Algebra 2e, 7.6 Solving Systems with Gaussian Elimination OpenStax (Rice University) The augmented matrix, the three row operations (interchange rows, multiply a row by a constant, add a multiple of one row to another), and reading a final row 0 = 4 as inconsistent and 0 = 0 as dependent.
- College Algebra 2e, 7.8 Solving Systems with Cramer’s Rule OpenStax (Rice University) Cramer’s rule x = Dx ÷ D, with Dx the determinant after replacing the x column by the constants; a determinant of zero doesn’t say whether there is no solution or infinitely many, so elimination is needed.
- Solving Ax = b: Row Reduced Form R (18.06SC lecture summary) MIT OpenCourseWare (Gilbert Strang) Rank as the number of pivots, the complete solution as a particular solution (free variables set to 0) plus the nullspace, and the solvability rule that a combination of rows giving the zero row must give 0 on the right side too.
- Determinant Formulas and Cofactors (18.06SC lecture summary) MIT OpenCourseWare (Gilbert Strang) The 2 × 2 determinant ad − bc and the 3 × 3 cofactor expansion along the first row used in the Cramer’s rule steps.
Smart Financial Calc: https://smartfinancialcalc.com/math/linear-system-solver/