How to Solve a System of Equations: Substitution, Elimination and Cramer's Rule

Four ways to solve two or three linear equations at once, how to choose between them, and how to spot systems with no solution or infinitely many.

A system of equations is two or more equations that share the same unknowns, and solving it means finding values that make every equation true at once. For two linear equations in x and y, the four standard methods are graphing, substitution, elimination and Cramer’s rule. Substitution and elimination are the workhorses: for example, 2x + 3y = 13 and x − y = −1 are both satisfied only by x = 2, y = 3.

Geometrically, each linear equation in two variables is a line, and the solution is the point where the lines cross. That picture explains the three possible outcomes: lines that cross once (one solution), parallel lines (no solution), or the same line twice (infinitely many solutions).

Method 1: Graphing

Rewrite each equation in slope-intercept form, y = mx + b, graph both lines and read the intersection.

  • 2x + 3y = 13 → y = −(2/3)x + 13/3
  • x − y = −1 → y = x + 1

The lines cross at (2, 3). Graphing is good for building intuition and for checking an answer, but it is imprecise when the solution is not a pair of whole numbers. Comparing slopes is also the fastest way to predict the outcome: different slopes always means exactly one solution. The slope calculator and how to find the slope of a line cover slope-intercept form.

Method 2: Substitution

  1. Solve one equation for one variable.
  2. Substitute that expression into the other equation.
  3. Solve the resulting one-variable equation.
  4. Substitute back to find the other variable.

2x + 3y = 13 and x − y = −1

From the second: x = y − 1

Substitute: 2(y − 1) + 3y = 13 → 5y − 2 = 13 → y = 3

Back-substitute: x = 3 − 1 = 2 → (2, 3)

Substitution shines when a variable already has a coefficient of 1 or −1, as x does here. When every coefficient is larger, it produces fractions, and elimination is cleaner.

Method 3: Elimination

Add or subtract the equations so that one variable cancels. Multiply one or both equations by constants first if needed.

3x + 4y = 10 and 5x − 2y = 34

Multiply the second by 2: 10x − 4y = 68

Add to the first: 13x = 78 → x = 6

Substitute: 3(6) + 4y = 10 → 4y = −8 → y = −2 → (6, −2)

Pick the variable that needs the least scaling. Here the y coefficients, 4 and −2, already have opposite signs, so multiplying one equation by 2 was enough. When the signs match, subtract instead of adding.

Check: 5(6) − 2(−2) = 30 + 4 = 34 ✓. Always check in the equation you did not use for back-substitution.

Method 4: Cramer’s rule (determinants)

For the system ax + by = e and cx + dy = f, compute three 2×2 determinants:

D = ad − bc,   Dx = ed − bf,   Dy = af − ec
x = Dx ÷ D,   y = Dy ÷ D

Using the same system, 3x + 4y = 10 and 5x − 2y = 34:

D = 3(−2) − 4(5) = −26

Dₓ = 10(−2) − 4(34) = −156 → x = −156 ÷ −26 = 6

Dᵧ = 3(34) − 10(5) = 52 → y = 52 ÷ −26 = −2

Cramer’s rule is formulaic and easy to program, and it extends to 3×3 systems with 3×3 determinants. If D = 0, the rule fails because the system has either no solution or infinitely many. The matrix determinant calculator evaluates the determinants, and the matrix inverse calculator offers the related method x = A⁻¹b.

Choosing a method

Situation Best method
A variable has coefficient 1 or −1 Substitution
Coefficients line up or are easy to match Elimination
You want a visual or a rough check Graphing
Formula-driven work, spreadsheets, code Cramer’s rule or matrices
Three or more unknowns Elimination or matrices

No solution and infinitely many solutions

Elimination reveals these cases automatically.

No solution: 2x + 4y = 8 and x + 2y = 5. Doubling the second gives 2x + 4y = 10. Subtracting leaves 0 = −2, which is false. The lines have the same slope but different intercepts, so they are parallel and never meet.

Infinitely many: x + 2y = 4 and 2x + 4y = 8. Doubling the first reproduces the second, and subtracting leaves 0 = 0. Every point on the line x + 2y = 4 is a solution.

Result after elimination Lines Number of solutions Determinant D
A single value for x and y Intersecting One Not zero
False statement (0 = −2) Parallel None Zero
True statement (0 = 0) Identical Infinitely many Zero

Solving a 3×3 system

With three unknowns, use elimination twice to reduce the system to two equations in two unknowns, then solve as before.

(1) x + y + z = 6   (2) 2x − y + z = 3   (3) x + 2y − z = 2

(1) + (3) eliminates z: 2x + 3y = 8

(2) + (3) eliminates z: 3x + y = 5 → y = 5 − 3x

Substitute: 2x + 3(5 − 3x) = 8 → −7x = −7 → x = 1, y = 2

From (1): z = 6 − 1 − 2 = 3 → (1, 2, 3)

Larger systems are usually solved with matrices and row reduction (Gaussian elimination), which is the same process organized in a grid. The system of linear equations calculator handles 2×2 and 3×3 systems with steps, and the matrix calculator covers general matrix work.

Word problems

The hard part is usually setting up the equations. Define one variable per unknown, then write one equation per fact.

Ticket sales. A theater sold 150 tickets for $1,520. Adult tickets cost $12 and child tickets $8. Let a and c be the numbers sold.

Count: a + c = 150   ·   Money: 12a + 8c = 1,520

Substitute c = 150 − a: 12a + 8(150 − a) = 1,520 → 4a = 320

a = 80 adult tickets, c = 70 child tickets

Mixture. How many liters of a 20% solution and a 50% solution make 30 liters of a 30% solution? With x and y liters: x + y = 30 and 0.20x + 0.50y = 0.30 × 30 = 9. Solving gives 20 L of the 20% solution and 10 L of the 50% solution.

The same two-equation pattern, one equation for the count and one for the value, solves coin, investment and speed problems. More practice is on the coin word problems page. When one of the equations is quadratic instead of linear, substitution still works; see how to solve quadratic equations for the second step.

Frequently asked questions

What is the easiest way to solve a system of equations?

Use substitution when one equation already has a variable with a coefficient of 1 or −1, because you can isolate it without fractions. Otherwise elimination is usually quickest: scale the equations so one variable cancels when you add them.

How do I know if a system has no solution?

If eliminating a variable leaves a false statement such as 0 = 2, the system has no solution; the lines are parallel. If it leaves a true statement such as 0 = 0, the equations describe the same line and there are infinitely many solutions.

How many equations do I need to solve for three unknowns?

You need three independent equations. Fewer equations leave infinitely many solutions, and equations that are multiples or combinations of each other do not count as independent.

What is Cramer's rule?

Cramer's rule solves a square linear system with determinants. Each variable equals a determinant in which that variable's column is replaced by the constants, divided by the determinant of the coefficient matrix. It only works when that determinant is not zero.