Sub topic 3
Two Linear Equations in Two Variables
Assume you can simplify algebraic expressions, expand brackets, work with fractions, and solve a linear equation in one variable. This chapter uses those skills to solve two equations together.
The working model
A linear equation in two variables has the form
\[ ax+by=c \]
where \(x\) and \(y\) are variables, and \(a\), \(b\), and \(c\) are constants. A system is a set of equations that must be true at the same time.
For example:
\[ x+y=10 \] \[ x-y=2 \]
The solution is the ordered pair \((x,y)\) that satisfies both equations. Here, \(x=6\) and \(y=4\), because \(6+4=10\) and \(6-4=2\).
A useful diagram is:
Substitution
Use substitution when one equation already has a variable alone, or can be rearranged easily.
Solve:
\[ y=2x+1 \] \[ 3x+y=11 \]
Replace \(y\) in the second equation with \(2x+1\):
\[ 3x+(2x+1)=11 \]
\[ 5x=10,\qquad x=2 \]
Now substitute \(x=2\) into \(y=2x+1\):
\[ y=2(2)+1=5 \]
Therefore, the solution is \((2,5)\).
Elimination
Use elimination when adding or subtracting the equations can remove one variable.
Solve:
\[ 2x+3y=13 \] \[ 2x-y=5 \]
Subtract the second equation from the first:
\[ (2x+3y)-(2x-y)=13-5 \]
\[ 4y=8,\qquad y=2 \]
Substitute \(y=2\) into \(2x-y=5\):
\[ 2x-2=5 \]
\[ x=\frac{7}{2} \]
The solution is \(\left(\frac{7}{2},2\right)\).
If the coefficients do not match, multiply one or both equations before adding or subtracting. Multiply the entire equation, including its right side. A common error is to multiply only one term.
Determinant shortcut
For
\[ a1x+b1y=c1 \] \[ a2x+b2y=c2 \]
define
\[ D=a1b2-a2b1 \]
When \(D\neq0\),
\[ x=\frac{c1b2-c2b1}{D}, \qquad y=\frac{a1c2-a2c1}{D} \]
This is useful when the coefficients are numerical and a quick calculation is needed.
def solve_2x2(a1, b1, c1, a2, b2, c2):
"""Solve a1*x + b1*y = c1 and a2*x + b2*y = c2."""
det = a1 * b2 - a2 * b1
if det == 0:
return None
x = (c1 * b2 - c2 * b1) / det
y = (a1 * c2 - a2 * c1) / det
return x, y
print(solve_2x2(1, 1, 10, 1, -1, 2))The program prints (6.0, 4.0). Always check a final pair in both original equations. This catches sign errors and incorrect multiplication.
Exercise
Solve 2x + y = 9 and x - y = 3 using elimination.
Show answer
Add the equations: 3x = 12, so x = 4. Then 4 - y = 3, so y = 1. The solution is (4, 1).