Sub topic 1
Linear Equations in Two Variables
Every method in this tutorial starts from one object: a linear equation with two unknowns. This chapter defines that object, explains what counts as a solution, and shows why its solutions form a straight line. The next chapters combine two such equations into a system.
Prerequisites
This chapter assumes you can do the following:
- Solve one-variable linear equations, such as 3x + 4 = 19.
- Evaluate an expression by substituting values for its variables.
- Plot points and lines on a coordinate plane.
- Do fraction and integer arithmetic, including negative numbers.
What makes an equation linear
A linear equation in two variables can be written in standard form:
Ax + By = C
Here A, B, and C are real numbers, and A and B are not both zero. The variables x and y appear only to the first power. They are never multiplied together, never in a denominator, and never inside a root or exponent.
| Equation | Linear? | Reason |
|---|---|---|
| 2x + y = 7 | Yes | Already in standard form |
| y = 3x - 5 | Yes | Rearranges to -3x + y = -5 |
| x = 4 | Yes | Here A = 1, B = 0, C = 4 |
| xy = 6 | No | x and y are multiplied |
| y = x² + 1 | No | x is squared |
| y = 1/x | No | x is in a denominator |
| 2(x + 1) = y - 3 | Yes | Expands to 2x + 2 = y - 3, then rearranges |
Some equations only look nonlinear until you simplify them. For example, x(x + 1) = x² + y - 2 contains x², but the x² terms cancel and leave a linear equation. Simplify first, then decide.
Solutions are ordered pairs
A solution of a linear equation in two variables is an ordered pair (x, y) that makes the equation true. Order matters. The pair (3, 1) means x = 3 and y = 1, which is a different pair from (1, 3).
To test a pair, substitute both values and compare the two sides. Take 2x + y = 7:
- (3, 1): 2(3) + 1 = 7. The pair is a solution.
- (1, 4): 2(1) + 4 = 6, and 6 ≠ 7. The pair is not a solution.
- (0, 7): 2(0) + 7 = 7. The pair is a solution.
- (-2, 11): 2(-2) + 11 = 7. The pair is a solution.
A single equation with two unknowns has infinitely many solutions. You can pick any x you like, and exactly one y completes the pair. This is the key difference from one-variable equations, which usually have one solution. One equation does not pin down two unknowns. That is why we will need two equations.
Generating solutions with a table
To find solutions, choose a value for one variable and solve for the other. Solve 2x + y = 7 for y first:
y = 7 - 2x
Now pick values of x:
| x | y = 7 - 2x | Pair |
|---|---|---|
| -2 | 11 | (-2, 11) |
| -1 | 9 | (-1, 9) |
| 0 | 7 | (0, 7) |
| 1 | 5 | (1, 5) |
| 2 | 3 | (2, 3) |
| 3 | 1 | (3, 1) |
| 4 | -1 | (4, -1) |
Plot these pairs and they line up. That is where the word "linear" comes from.
Each step of 1 in x changes y by -2. That constant rate of change is the line's slope. The x-coefficient 2 and the y-coefficient 1 control it: when x grows by 1, the term 2x grows by 2, so y must shrink by 2 to keep the sum at 7.
The solution set is a line
The graph of a linear equation is the set of all points (x, y) that are solutions. For any equation in standard form, that set is a straight line. Two consequences follow:
- A point on the line is a solution, and a point off the line is not.
- Two points are enough to draw the line, and a third point is a useful check.
The second consequence matters for the graphing method later. If your three points do not line up, you made an arithmetic error.
Intercepts: the two easiest points
The x-intercept is where the line crosses the x-axis. There y = 0. The y-intercept is where the line crosses the y-axis. There x = 0. Setting one variable to zero often removes a term and makes the arithmetic short.
Take 3x - 2y = 12.
- x-intercept: set y = 0. Then 3x = 12, so x = 4. The point is (4, 0).
- y-intercept: set x = 0. Then -2y = 12, so y = -6. The point is (0, -6).
Draw a line through (4, 0) and (0, -6). To check, test a third point such as (2, -3): 3(2) - 2(-3) = 6 + 6 = 12. It works.
Intercepts are a poor choice in one case. If the line passes through the origin, as in y = 2x, both intercepts are (0, 0) and you get only one point. Pick another x, such as x = 1, to get a second point.
Rewriting in slope-intercept form
Standard form is convenient for combining equations. Slope-intercept form is convenient for graphing:
y = mx + b
Here m is the slope (the change in y for each increase of 1 in x) and b is the y-intercept (the y-value where the line crosses the y-axis). The next chapters use this form for the graphing method, so practice the conversion now.
To convert, isolate y using the same operation on both sides. Start with 3x - 2y = 12:
- Subtract 3x from both sides: -2y = -3x + 12.
- Divide every term by -2: y = (3/2)x - 6.
The slope is 3/2 and the y-intercept is -6, which matches the intercept found above. To draw the line, start at (0, -6), move 2 units right and 3 units up, and mark the next point at (2, -3).
Special cases: horizontal and vertical lines
Setting A or B to zero gives two special forms:
- Horizontal line. If A = 0, the equation is By = C, which gives y = k for a constant k. Every point has the same y-value. The slope is 0. Example: y = 3 contains (-5, 3), (0, 3), and (8, 3).
- Vertical line. If B = 0, the equation is Ax = C, which gives x = k. Every point has the same x-value. The slope is undefined, so a vertical line has no slope-intercept form. Example: x = 4 contains (4, -2), (4, 0), and (4, 9).
In the equation x = 4, the variable y is still there as a coordinate. It is simply unrestricted, so any y works as long as x is 4. Do not read x = 4 as a single point.
Checking solutions with code
Substitution is mechanical, so a short program can do it. The functions below use exact fractions, so rational answers do not suffer rounding error.
from fractions import Fraction
def is_solution(a, b, c, x, y):
"""Return True if (x, y) satisfies a*x + b*y = c."""
return a * x + b * y == c
def y_for_x(a, b, c, x):
"""Solve a*x + b*y = c for y. Requires b != 0."""
if b == 0:
raise ValueError("vertical line: y is not determined by x")
return (Fraction(c) - a * x) / b
# Equation 2x + y = 7
print(is_solution(2, 1, 7, 3, 1)) # True
print(is_solution(2, 1, 7, 1, 4)) # False
for x in range(-2, 5):
print(x, y_for_x(2, 1, 7, x))
# Equation 3x - 2y = 12: slope-intercept form is y = (3/2)x - 6
print(y_for_x(3, -2, 12, 0)) # -6
print(y_for_x(3, -2, 12, 2)) # -3The ValueError case is the vertical line. When B = 0, a given x either allows every y or none, so there is no single y to return.
Common errors
- Reversing the pair. Writing (1, 3) for the solution x = 3, y = 1. Always read pairs as (x, y).
- Testing one equation only. Later, with systems, a pair must satisfy both equations. Build the habit of substituting into the original equation, not a rearranged copy that may contain a mistake.
- Moving a term without changing its sign. Going from 2x + y = 7 to y = 7 + 2x is wrong. The correct result is y = 7 - 2x.
- Dividing only some terms. To isolate y in 4y = 8x + 12, divide both terms: y = 2x + 3. Writing y = 2x + 12 is wrong.
- Calling x = 4 a point. It is a vertical line with infinitely many points.
- Trusting two points without a check. Two points always define some line, so a mistake in one point goes unnoticed. A third point catches it.
Deciding whether an equation is linear
The flowchart below summarizes how to decide whether an equation qualifies.
Summary of the working model
- A linear equation in two variables is Ax + By = C with A and B not both zero.
- Its solutions are ordered pairs, and there are infinitely many of them.
- Those pairs fill a straight line, so plotting two points (plus a check point) draws the whole solution set.
- Intercepts are quick points to find. Slope-intercept form, y = mx + b, makes the slope and y-intercept visible.
- A system of two equations asks for the pairs that lie on both lines at once. The next chapter builds on that idea.
Exercise
Is (4, -1) a solution of 3x + 5y = 7? Then find the x-intercept and y-intercept of 3x + 5y = 15.
Show answer
Substitute (4, -1) into 3x + 5y = 7: 3(4) + 5(-1) = 12 - 5 = 7, so yes, it is a solution. For 3x + 5y = 15, set y = 0 to get 3x = 15, so x = 5 and the x-intercept is (5, 0). Set x = 0 to get 5y = 15, so y = 3 and the y-intercept is (0, 3).
Exercise
Rewrite 4x + 2y = 10 in slope-intercept form, and state the slope and y-intercept. Then explain why x = -2 cannot be written in slope-intercept form.
Show answer
Subtract 4x from both sides: 2y = -4x + 10. Divide every term by 2: y = -2x + 5. The slope is -2 and the y-intercept is 5. The equation x = -2 is a vertical line. Every point on it has x = -2, so y is not a function of x, the slope is undefined, and no form y = mx + b can describe it.
Exercise
Which of these is not linear after simplifying: (a) 3(x - 1) = y + 2, (b) x(x + 2) = x² + y, (c) xy + y = 5? Explain.
Show answer
Only (c) is not linear. In (a), expanding gives 3x - 3 = y + 2, which rearranges to 3x - y = 5. In (b), the x² terms cancel and leave 2x = y, which is linear. In (c), the term xy multiplies the two variables, so the equation is not linear.