An equation is a balance: do the same thing to both sides and it stays level. Solve 3x + 2 = 14 step by step, rearrange y = wx + b for x, and see why multiplying an inequality by a negative number flips it, using the decision rule 2x - 6 >= 0.
Solve a linear equation in one unknown by doing the same operation to both sides, and check the answer by substitution.
Rearrange a formula such as y = wx + b to make a different letter its subject.
Solve a linear inequality, flipping the sign when multiplying or dividing by a negative number, and explain the flip with a reflected number line.
Draw the solutions of an inequality on the number line and write them as an interval such as [a, b) or (a, b).
In review. The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
The question
A spam filter counts the exclamation marks \(x\) in a message and predicts spam when \({2x - 6 \geq 0}\). Which messages does it flag? A second filter predicts spam when \({-2x + 6 \geq 0}\). Does it flag the same ones? Answering takes one move that works for every equation, and one twist that only inequalities have.
From the last lesson
1. In what order is \({3 + 4 \times 2^2}\) worked out, and what is its value?
Show answer
The power first, \({2^2 = 4}\); then the multiplication, \({4 \times 4 = 16}\); then the addition, \({3 + 16 = 19}\).
2. Expand \({(a + b)^2}\).
Show answer
\({a^2 + 2ab + b^2}\): two squares and two rectangles \(ab\).
Intuition
An equation says that two expressions are equal. Picture it as a balance. Each box on a pan weighs the unknown number \(x\), and each small cube weighs 1. The equation \({3x + 2 = 14}\) says that three boxes and two cubes weigh the same as fourteen cubes, so the beam hangs level.
M01.1.3-F1
The equation \({3x + 2 = 14}\) as a balance. The beam is level, so the two sides weigh the same.
To find \(x\), take things off the balance until one box sits alone. There is one rule: whatever you do to one pan, do the same to the other. Then the beam stays level, and every new line of algebra is still true. Take something off one pan only, and the beam tips.
Build it up
Step 1. What a solution is. An equation is true for some values of \(x\) and false for others. A value that makes it true is a solution. Try \({x = 3}\): \({3 \times 3 + 2 = 11}\), not 14. Try \({x = 4}\): \({3 \times 4 + 2 = 14}\). So 4 is a solution. Guessing works here, but it does not scale.
Step 2. Moves that keep the balance level. You may:
add the same number to both sides, or subtract it from both;
multiply both sides by the same number, or divide both by it, as long as that number is not 0.
Why not 0? Multiplying both sides of any equation by 0 gives \({0 = 0}\), which is true for every \(x\): the information about \(x\) is thrown away. And dividing by 0 has no meaning at all.
Step 3. Undo in reverse order.\({3x + 2}\) was built by “times 3, then add 2”. Undo it the other way round: subtract 2, then divide by 3. That is how to choose the moves.
Step 4. Inequalities. An inequality compares two sides with \({<}\), \({\leq}\) (“less than or equal to”), \({>}\) or \({\geq}\). The same moves work, with one exception. Adding the same number to both sides slides both points along the line together, so their order stays. Multiplying by a positive number stretches or squeezes the line, and the order stays. Multiplying by a negative number turns the line round:
M01.1.3-F2
Multiplying by \(-1\) sends every point to its mirror image across 0. The arrows cross: left and right swap, so \({2 < 5}\) becomes \({-2 > -5}\).
So multiplying or dividing both sides of an inequality by a negative number flips its sign: \({<}\) becomes \({>}\), and \({\leq}\) becomes \({\geq}\).
Step 5. Solutions fill a stretch of the line. An inequality usually has infinitely many solutions. Together they form an interval:
M01.1.3-F3
Four intervals. A square bracket and a solid dot mean the end is included; a round bracket and a hollow dot mean it is left out.
The formal statement
NoteLinear equations
A linear equation in one unknown \(x\) is one that can be written \({ax + b = c}\), where \(a\), \(b\) and \(c\) are numbers and \(a\) is not 0. It has exactly one solution:
\[
\begin{aligned}
ax + b &= c \\
ax &= c - b \\
x &= \frac{c - b}{a} .
\end{aligned}
\]
The second line subtracts \(b\) from both sides. The third divides both sides by \(a\), which is allowed because \(a\) is not 0. Putting the answer back in checks it:
\[
a \times \frac{c - b}{a} + b = (c - b) + b = c .
\]
Rearranging a formula uses the same moves on letters. The model \({y = wx + b}\) gives the output \(y\) for an input \(x\). To ask which input gives a chosen output, make \(x\) the subject: subtract \(b\), then divide by \(w\) (which must not be 0):
\[
x = \frac{y - b}{w} .
\]
With \({w = 1.4}\) and \({b = 0.5}\), the output 4.7 comes from the input
For all numbers \(a\), \(b\) and \(c\), if \({a < b}\), then:
\({a + c < b + c}\) and \({a - c < b - c}\);
\({ca < cb}\) when \({c > 0}\);
\({ca > cb}\) when \({c < 0}\): the sign flips.
The same holds with \({\leq}\), which flips to \({\geq}\).
Why the sign flips. That \({a < b}\) means \({b - a}\) is positive: \(b\) lies to the right of \(a\). Now compare \(-a\) and \(-b\). Their difference is
\[
(-a) - (-b) = b - a ,
\]
which is positive, so \(-a\) lies to the right of \(-b\): \({-a > -b}\). A negative \(c\) is \(-d\) for a positive \(d\). Multiplying by \(d\) keeps the order, \({da < db}\), and multiplying by \(-1\) then flips it: \({-da > -db}\), which is \({ca > cb}\).
NoteIntervals
Inequality
Interval
Ends
\({a \leq x \leq b}\)
\([a, b]\)
both included
\({a \leq x < b}\)
\([a, b)\)
\(a\) in, \(b\) out
\({a < x < b}\)
\((a, b)\)
both left out
\({x \geq a}\)
\([a, \infty)\)
\(a\) in, no end
\({x \leq b}\)
\({(-\infty, b]}\)
no end, \(b\) in
The sign \(\infty\), “infinity”, is not a number: it says the interval goes on for ever, so it always takes a round bracket.
Worked example
Solve \({3x + 2 = 14}\).
M01.1.3-F4
Each move is made on both pans, so the beam stays level and each line is still true. The dashed outlines show what was just taken away.
Line 2 subtracts 2 from both sides. Line 3 divides both sides by 3. Check by putting 4 back into the original equation: \({3 \times 4 + 2}\) is \({12 + 2}\), which is 14, the right side. So \({x = 4}\).
The two spam filters. Solve each rule for \(x\), writing every move:
Add 6 to both sides, then divide both sides by 2. Since 2 is positive, the sign stays. The first filter flags every message with 3 or more exclamation marks: the interval \([3, \infty)\).
Subtract 6 from both sides, then divide both sides by \(-2\). Since \(-2\) is negative, the sign flips. The second filter flags messages with 3 or fewer marks: \({(-\infty, 3]}\), the mirror image.
M01.1.3-F5
The score of each rule at \({x = 0, 1, \dots, 6}\). A rule says yes where its score is at least 0. The sign in front of \(x\) decides which side of 3 says yes.
Check with points. At \({x = 4}\) the first score is \({2 \times 4 - 6 = 2}\), at least 0, so yes; the second is \({-8 + 6 = -2}\), so no. At \({x = 3}\) both scores are 0, so both say yes: the end 3 belongs to both intervals. A machine-learning classifier works just like this. It computes a score \({wx + b}\) and says yes when the score is at least 0. Its decision boundary is where the score is 0, here \({x = 3}\), and the sign of the weight \(w\) decides which side says yes.
Code
A function that solves \({ax + b = c}\) and prints each step, the way you would write it by hand:
def solve(a, b, c):"""Solve a*x + b = c step by step. a must not be 0."""print(a, "* x +", b, "=", c)# subtract b from both sides c = c - bprint(a, "* x =", c)# divide both sides by a x = c / aprint("x =", x)return xx = solve(3, 2, 14)# put the answer back into the left sideprint("check:", 3* x +2)
3 * x + 2 = 14
3 * x = 12
x = 4.0
check: 14.0
The same function on \({3x + 2 = 13}\) gives a decimal that cannot be stored exactly. Passing fractions instead keeps every step exact:
from fractions import Fraction# decimals: the answer is roundedx = solve(3, 2, 13)# fractions: the answer is exactx = solve(Fraction(3), Fraction(2), Fraction(13))print("check:", 3* x +2)
3 * x + 2 = 13
3 * x = 11
x = 3.6666666666666665
3 * x + 2 = 13
3 * x = 11
x = 11/3
check: 13
The rearranged formula \({x = (y - b)/w}\) is a function too. With decimals the answer misses 3 in the last place; with fractions made from the written decimals, it is exactly 3:
def input_for(y, w, b):"""The input x for which w*x + b equals y."""return (y - b) / wprint(input_for(4.7, 1.4, 0.5))print(input_for(Fraction("4.7"), Fraction("1.4"), Fraction("0.5")))
3.0000000000000004
3
Last, the two filters of the worked example, tested on 0 to 6 exclamation marks:
for marks inrange(0, 7):print(marks, 2* marks -6>=0, -2* marks +6>=0)
The first filter says True from 3 upwards, the second up to 3, and both say True at 3.
Explore
M01.1-X1
Equation balance
Each button does one operation to both pans and writes the new line of algebra underneath. Turn on Change the left pan only to break the rule and watch the beam tip.
Things to try:
Solve \({3x + 2 = 14}\) with the buttons in two moves. Then press Next step on a fresh start and compare.
Choose \({5x + 3 = 2x + 12}\), which has \(x\) on both sides. Which move gathers the boxes on one pan?
Turn on Change the left pan only, subtract 2, and read what the read-out says about the two sides. Then press Undo.
Try to multiply both sides by 0. Why does the balance refuse?
Pitfalls
M01.1.3-F6
Wrong beside right. Testing one point from the answer catches a missing flip at once.
“Dividing \({-2x \geq -6}\) by \(-2\) gives \({x \geq 3}\).”
Dividing by a negative number flips the sign, so the answer is \({x \leq 3}\). A quick test catches the slip: \({x = 5}\) lies in the wrong answer, but \({-2 \times 5 + 6 = -4}\) is not at least 0.
“I subtracted 2 from the left side; the right side can stay as it is.”
Then the two sides are no longer equal, and the new line has a different solution: \({3x = 14}\) is solved by \(14/3\), not by 4. Every move goes on both sides, every time.
“Multiplying both sides by the same number is always allowed, so 0 is fine.”
Multiplying by 0 turns any equation into \({0 = 0}\), which every \(x\) satisfies: the answer is lost. Dividing by 0 is not defined. Both moves need a number that is not 0.
“\({x \geq 3}\) is the interval \((3, \infty)\).”
The round bracket leaves 3 out, so \((3, \infty)\) is \({x > 3}\). For \({x \geq 3}\) write \([3, \infty)\). In a classifier the end matters: it decides whether a message with exactly 3 marks is flagged.
Check yourself
Recall
1. What one rule keeps an equation true while you solve it?
Show answer
Do the same thing to both sides: add or subtract the same number, or multiply or divide both sides by the same number that is not 0.
2. Solve \({5x - 4 = 11}\), and check your answer.
Show answer
Add 4 to both sides: \({5x = 15}\). Divide both sides by 5: \({x = 3}\). Check: \({5 \times 3 - 4 = 11}\).
3. When does the sign of an inequality flip?
Show answer
When both sides are multiplied or divided by a negative number, because that turns the number line round.
4. Write \({2 < x \leq 7}\) as an interval. Which end is included?
Show answer
\((2, 7]\). The end 7 is included and the end 2 is left out.
5. Rearrange \({y = wx + b}\) to make \(x\) the subject.
Show answer
\({x = (y - b)/w}\), which needs \(w\) to be not 0.
Exercises
1.★ Solve \({7 - 2x = 1}\) and \({4(x - 1) = 2x + 6}\). Check both answers.
Show solution
\({7 - 2x = 1}\). Subtract 7 from both sides: \({-2x = -6}\). Divide both sides by \(-2\): \({x = 3}\). Check: \({7 - 2 \times 3 = 1}\).
\({4(x - 1) = 2x + 6}\). Expand the bracket: \({4x - 4 = 2x + 6}\). Subtract \(2x\) from both sides: \({2x - 4 = 6}\). Add 4: \({2x = 10}\). Divide by 2: \({x = 5}\). Check: the left side is \({4 \times 4 = 16}\) and the right side is \({10 + 6 = 16}\).
2.★★ Solve \({-3 < 2x + 1 \leq 7}\). Write the answer as an interval and test both ends.
Show solution
Do each move to all three parts. Subtract 1: \({-4 < 2x \leq 6}\). Divide by 2, which is positive, so no sign flips: \({-2 < x \leq 3}\). The interval is \({(-2, 3]}\).
Test the ends. At \({x = 3}\): \({2 \times 3 + 1 = 7}\), and \({7 \leq 7}\) is true, so 3 is included. At \({x = -2}\): \({2 \times (-2) + 1 = -3}\), and \({-3 < -3}\) is false, so \(-2\) is left out.
3.★★★ Model A predicts \({1.4x + 0.5}\) and model B predicts \({-0.6x + 4.5}\). For which inputs \(x\) does A predict more than B? Write the answer as an interval, find the input where the two agree, and check one input on each side.
Show solution
We want the inputs for which
\[
1.4x + 0.5 > -0.6x + 4.5 .
\]
Add \(0.6x\) to both sides: \({2x + 0.5 > 4.5}\). Subtract 0.5: \({2x > 4}\). Divide by 2, which is positive: \({x > 2}\). The answer is the interval \((2, \infty)\).
They agree where the two sides are equal, and the same moves with \({=}\) in place of \({>}\) give \({x = 2}\). There A predicts \({2.8 + 0.5 = 3.3}\) and B predicts \({-1.2 + 4.5 = 3.3}\).
Checks. At \({x = 3}\): A gives 4.7 and B gives 2.7, so A is larger. At \({x = 0}\): A gives 0.5 and B gives 4.5, so B is larger.
Summary card
An equation is a balance: do the same thing to both sides and it stays level.
M01.1.3-F1
Same move, both pans.
\({ax + b = c}\) with \(a\) not 0 gives \({x = (c - b)/a}\). Check by putting it back.
\({y = wx + b}\) rearranged for \(x\) is \({x = (y - b)/w}\).
Multiplying or dividing an inequality by a negative number flips its sign.
\([a, b)\) includes \(a\) and leaves out \(b\); \((a, b)\) leaves out both.
Sources and next steps
Sources. Each was opened and checked against this lesson on 12 November 2026.
Jay Abramson and others, Algebra and Trigonometry 2e, OpenStax. Section 2.2, Linear Equations in One Variable, writes a linear equation as \({ax + b = 0}\) with \(a\) not 0, solves it by doing the same thing to both sides of the equals sign, and notes that we cannot divide by zero. Section 2.7 gives the properties of inequalities, with the exception that multiplying or dividing by a negative number reverses the inequality symbol, and interval notation with brackets and parentheses.
Richard Hammack, Book of Proof, third edition, Section 1.1. It lists the closed, open, half-open and infinite intervals in set notation and draws each as a darkened segment, with a solid circle for an end that is included and a hollow circle for one that is not.
Python Software Foundation, fractions: Rational numbers (Python 3.12). Fraction(numerator, denominator), the string form Fraction("4.7"), and exact arithmetic on the results.
Next.M01.1.4 Reading notation reads formulas with subscripts, hats, bars and Greek letters aloud, using the four data points of this course.