Linear equations are the workhorses of everyday algebra. A supplier charges a fixed fee plus a price per unit; two products have different prices and you know the totals for two orders; three ingredients must be mixed to hit three targets. Each of these translates into one or more equations where the unknowns appear only to the first power, with no squares, roots or products of unknowns.
This guide shows how to solve a single linear equation cleanly, then how to solve systems of two and three equations using substitution, elimination and Cramer's rule. It also explains how to tell, before doing all the work, whether a system has one solution, none or infinitely many.
Solving one equation in one unknown
The goal is to get x alone on one side. Whatever you do to one side, you must do to the other.
Example: 3x + 5 = x + 17
- Collect the x terms on the left: subtract x from both sides. 2x + 5 = 17.
- Move the constant to the right: subtract 5. 2x = 12.
- Divide by the coefficient: x = 6.
- Check: 3 × 6 + 5 = 23 and 6 + 17 = 23. Both sides match.
Example with a fractional answer: 4x − 7 = 10x + 2
Subtract 10x: −6x − 7 = 2. Add 7: −6x = 9. Divide by −6: x = −3/2. Leaving the answer as a fraction keeps it exact; −1.5 is fine too, but answers such as 1/3 lose accuracy as decimals.
When there is no single answer
If the x terms cancel out, you are left with a statement about numbers:
- 2x + 3 = 2x + 3 simplifies to 0 = 0, which is always true: every x is a solution (the equation is an identity).
- 2x + 3 = 2x + 5 simplifies to 0 = 2, which is never true: there is no solution.
Systems of two equations
A system asks for values that satisfy every equation at once. Graphically, each linear equation in two unknowns is a straight line, and the solution is where the lines cross.
Example. An office orders stationery. Three notebooks and two pens cost 13. One notebook and four pens cost 11. Let n be the notebook price and p the pen price:
3n + 2p = 13
n + 4p = 11
Method 1: substitution
Rearrange one equation for one unknown, then substitute it into the other.
- From the second equation: n = 11 − 4p.
- Substitute into the first: 3(11 − 4p) + 2p = 13, so 33 − 12p + 2p = 13.
- Simplify: −10p = −20, so p = 2.
- Back-substitute: n = 11 − 4 × 2 = 3.
Substitution is ideal when one unknown already has a coefficient of 1.
Method 2: elimination
Scale the equations so that one unknown has the same coefficient in both, then subtract.
- Multiply the second equation by 3: 3n + 12p = 33.
- Subtract the first equation: (3n + 12p) − (3n + 2p) = 33 − 13, so 10p = 20 and p = 2.
- Substitute back to get n = 3.
Elimination scales better to three or more equations and is the basis of the row-reduction method used by computers.
Method 3: Cramer's rule
Cramer's rule uses determinants. For
a₁x + b₁y = c₁
a₂x + b₂y = c₂
compute the main determinant D and two more, where the constants replace one column each:
D = a₁b₂ − b₁a₂
Dx = c₁b₂ − b₁c₂
Dy = a₁c₂ − c₁a₂
x = Dx ÷ D, y = Dy ÷ D
For the stationery system: D = 3 × 4 − 2 × 1 = 10, Dn = 13 × 4 − 2 × 11 = 30 and Dp = 3 × 11 − 13 × 1 = 20. So n = 30 ÷ 10 = 3 and p = 20 ÷ 10 = 2.
Cramer's rule is neat for 2×2 and 3×3 systems and gives each unknown directly, but it becomes inefficient for large systems. The determinants are explained in more depth in How to Find the Determinant and Inverse of a Matrix.
Systems of three equations
The same ideas extend to three unknowns. Take:
x + y + z = 6
2x − y + z = 3
x + 2y − z = 2
With elimination, add the first and third equations to remove z: 2x + 3y = 8. Subtract the second from the first to remove z again: −x + 2y = 3. Solving those two gives x = 1 and y = 2, and then z = 6 − 1 − 2 = 3.
With Cramer's rule, the main determinant is D = 7, and replacing each column with the constants gives Dx = 7, Dy = 14 and Dz = 21. So x = 1, y = 2, z = 3, the same answer.
Always substitute the solution back into all three original equations. It takes a moment and catches almost every arithmetic slip.
One solution, none, or infinitely many
The determinant of the coefficients tells you which case you are in:
- D ≠ 0: exactly one solution. The lines (or planes) meet at a single point.
- D = 0: either no solution or infinitely many. The equations are not independent.
To tell the two D = 0 cases apart, compare the equations:
| System | What happens | Result |
|---|---|---|
| x + y = 3 and 2x + 2y = 8 | Same left side (doubled), different right side | No solution (parallel lines) |
| x + y = 3 and 2x + 2y = 6 | Second equation is just the first doubled | Infinitely many (same line) |
In matrix language, a system has no solution when the augmented matrix (coefficients plus constants) has a higher rank than the coefficient matrix alone, and infinitely many when the ranks are equal but smaller than the number of unknowns. The number of "free variables" is the difference.
Using the linear equation solver
The Linear Equation Solver works with exact fractions throughout.
- Choose a mode: ax + b = cx + d, 2 equations, 2 unknowns or 3 equations, 3 unknowns.
- For a single equation, type the four values a, b, c and d. For 3x + 5 = x + 17, enter 3, 5, 1 and 17.
- For a system, fill in the grid: one row per equation, with the coefficient of each unknown followed by the constant on the right-hand side. Integers, decimals and fractions are accepted.
- Read the answer, then open the steps. Single equations show the move-and-divide working with a check line. Systems show Cramer's rule with each determinant, then a substitution check.
When the determinant is 0, the solver compares ranks and tells you whether the system is inconsistent (no solution) or has infinitely many solutions, and lists the free variables with the reduced equations.
Other ways to solve linear systems
- Graphing: plotting two lines shows the solution visually and makes parallel or identical lines obvious, but reading an exact intersection off a graph is rarely precise.
- Matrices: writing the system as AX = B and computing X = A⁻¹B works well when you need to solve many systems with the same coefficients. The Matrix Calculator handles inverses and row reduction.
- Spreadsheets:
=MMULT(MINVERSE(A1:C3), D1:D3)solves a 3×3 system, in floating point. Excel's Solver add-in also works but is more than you need. - Programming:
numpy.linalg.solvein Python is the standard for large systems.
If the equation contains x², it is no longer linear; use the Quadratic Equation Solver instead. For fraction arithmetic in hand working, the Fraction Calculator is useful.
Common mistakes
- Doing something to one side only. Every operation must apply to the whole of both sides.
- Sign errors when moving terms. Moving +5 across the equals sign makes it −5.
- Distributing a negative incompletely. −(2x − 3) is −2x + 3, not −2x − 3.
- Multiplying only one term when scaling an equation for elimination. Every term, including the constant, must be multiplied.
- Skipping the check. Substitution into the original equations is the only proof your answer is right.
Frequently asked questions
What makes an equation linear?
Each unknown appears only to the first power and is not multiplied by another unknown. 3x + 2y = 7 is linear; x² + y = 7 and xy = 4 are not.
Which method is best for solving a system of equations?
Substitution is quickest when a variable already has a coefficient of 1. Elimination is the most reliable general method, and Cramer's rule is convenient for small systems when you want each unknown directly.
How do I know if a system has no solution?
When eliminating, you end up with a false statement such as 0 = 2. Graphically, the lines are parallel; algebraically, the determinant is 0 and the equations contradict each other.
Can a system of linear equations have exactly two solutions?
No. A linear system has either no solution, exactly one or infinitely many. Two straight lines cannot cross at exactly two points.
Why does Cramer's rule fail when the determinant is zero?
Because every unknown is found by dividing by the determinant, and division by zero is undefined. A zero determinant means the equations are not independent.