Solving Simultaneous Linear Equations

Solves a₁x + b₁y = c₁ and a₂x + b₂y = c₂ for x and y. When a₁b₂ − a₂b₁ is zero there is no unique solution.

Two linear equations in two unknowns are solved together for the pair (x,y)(x, y) that satisfies both at once.

a1x+b1y=c1,a2x+b2y=c2a_1 x + b_1 y = c_1, \quad a_2 x + b_2 y = c_2

Substitution and elimination both work, but Cramer's rule writes the answer straight from the coefficients.

x=c1b2c2b1a1b2a2b1,y=a1c2a2c1a1b2a2b1x = \dfrac{c_1 b_2 - c_2 b_1}{a_1 b_2 - a_2 b_1}, \quad y = \dfrac{a_1 c_2 - a_2 c_1}{a_1 b_2 - a_2 b_1}

Example

Solve 2x+3y=122x + 3y = 12 together with xy=1x - y = 1, so a1=2a_1 = 2, b1=3b_1 = 3, c1=12c_1 = 12, a2=1a_2 = 1, b2=1b_2 = -1, c2=1c_2 = 1. The denominator first:

a1b2a2b1=2×(1)1×3=5a_1 b_2 - a_2 b_1 = 2 \times (-1) - 1 \times 3 = -5
x=12×(1)1×35=155=3,y=2×11×125=105=2x = \dfrac{12 \times (-1) - 1 \times 3}{-5} = \dfrac{-15}{-5} = 3, \quad y = \dfrac{2 \times 1 - 1 \times 12}{-5} = \dfrac{-10}{-5} = 2

So x=3x = 3 and y=2y = 2. Substituting back, 2×3+3×2=122 \times 3 + 3 \times 2 = 12 and 32=13 - 2 = 1: both equations hold.

Notes