Volume 1: Foundations to Precalculus · Part II: Algebra
Chapter 4. The Language of Algebra: Variables, Expressions, and Equations
Algebra is arithmetic with the numbers left blank. This chapter rebuilds the vocabulary of that idea (variable, term, coefficient, expression, equation, identity, formula) and the handful of moves you make with it: substituting, expanding, collecting, factoring, and rearranging. Nothing here is hard in isolation. What makes algebra feel slippery after a long break is that the words have faded and the moves have become habits without reasons. We restore both, so that every later chapter can speak this language without stopping to translate.
Why it matters: every formula you will ever use (a loan repayment, a drug dose per kilogram, a spreadsheet column, a physics equation, a line of code) is an algebraic expression. Being fluent with expressions is what lets you use a formula you have never seen before, turn it round to answer the question you actually have, and spot when someone else’s formula is wrong.
4.1. Why letters? Generalising arithmetic
4.1.1. The problem
Here is an old party trick. Think of a number. Double it. Add ten. Halve the result. Subtract the number you first thought of. Whatever number you chose, you are now holding 5.
Try it with 7: \(7 \to 14 \to 24 \to 12 \to 5\). With 100: \(100 \to 200 \to 210 \to 105 \to 5\). With \(-3\): \(-3 \to -6 \to 4 \to 2 \to 5\).
Three examples are not an explanation. How do we know it works for every number, including ones nobody will ever try? Arithmetic can only check one number at a time. We need a way to compute with "whatever number you thought of" as a single object.
4.1.2. Intuition
Give the unknown number a name. Call it \(n\). Then do exactly the same operations, writing down what you have at each stage instead of a specific value:
| Instruction | What you are holding |
|---|---|
Think of a number |
\(n\) |
Double it |
\(2n\) |
Add ten |
\(2n + 10\) |
Halve the result |
\(n + 5\) |
Subtract the original number |
\(5\) |
The letter has done something no list of examples could do: it has carried out the arithmetic for all numbers at once. The halving step is where the magic happens: half of \(2n + 10\) is \(n + 5\), because halving each part of a sum halves the whole. Subtracting \(n\) then removes all trace of the original choice.
That is the entire spirit of algebra. A letter is a placeholder that lets you write down a calculation without committing to the input, so you can reason about the calculation itself.
4.1.3. Why it works
Arithmetic facts like \(3 \times (4 + 5) = 3 \times 4 + 3 \times 5\) are true for specific numbers. But you will notice that the shape of such facts never depends on the particular numbers. Algebra promotes those shapes to first-class statements: \(a(b + c) = ab + ac\) for all numbers \(a, b, c\). Once a shape is established, you can use it anywhere, on numbers or on other expressions, without checking it again. The handful of rules that make this work (commutativity, associativity, distributivity, and the behaviour of 0 and 1) were reviewed in Chapter 1. Algebra is just those rules applied to symbols.
|
Variable
A variable is a symbol, usually a letter, that stands for a number we either do not know yet or want to leave unspecified. In \(2n + 10\), \(n\) is the variable. The word comes from Latin variabilis, "changeable". |
|
Constant
A constant is a quantity with a fixed value throughout a discussion. Literal numbers such as \(10\) or \(-\tfrac{3}{4}\) are constants, and so are named numbers such as \(\pi \approx 3.14159\) and \(e \approx 2.71828\). |
|
Why "algebra"?
The word comes from the title of a book written in Baghdad around 820 CE by Muhammad ibn Musa al-Khwarizmi: al-Kitab al-mukhtasar fi hisab al-jabr wa’l-muqabala, "The Compendious Book on Calculation by Restoring and Balancing". Al-jabr ("restoring") meant moving a subtracted quantity to the other side of an equation, where it becomes added. His name, Latinised as Algoritmi, gave us the word algorithm. Remarkably, al-Khwarizmi wrote everything in words: no letters, no symbols. Using letters for unknowns took another 750 years. François Viète (1590s) used vowels for unknowns and consonants for knowns, and René Descartes (1637) settled the convention we still use: \(x, y, z\) for unknowns, \(a, b, c\) for knowns. |
4.2. The cast of characters: variables, constants, parameters, unknowns
4.2.1. The problem
Look at the equation of a straight line, which you will meet properly in Chapter 5:
Four letters. Are they all "variables"? If you ask a mathematician, she will say \(x\) and \(y\) are variables, while \(m\) and \(b\) are… something else. Yet all four are letters standing for numbers. What is the difference, and why does it matter?
4.2.2. Intuition
The difference is not in the letters but in the role each letter plays in a particular discussion. A useful mental model: think of a family of programs.
-
\(m\) and \(b\) are like configuration settings. Once chosen (say \(m = 2\), \(b = 1\)), they stay fixed while you work with that particular line.
-
\(x\) is the input that you vary freely.
-
\(y\) is the output that depends on \(x\).
Change \(m\) or \(b\) and you get a different line. Change \(x\) and you move along the same line.
|
Parameter
A parameter is a letter that is held fixed within one problem but could be changed to give a related problem. In \(y = mx + b\), \(m\) and \(b\) are parameters: each choice of them gives one line from a whole family of lines. In \(ax^2 + bx + c = 0\), the coefficients \(a, b, c\) are parameters. |
|
Unknown
An unknown is a variable whose value we are trying to find from an equation. In \(3x + 4 = 19\), \(x\) is the unknown, and the equation pins it down to \(x = 5\). "Unknown" describes a variable’s job in a problem rather than a different kind of object. |
|
Independent and dependent variables
When one quantity is computed from another, the input is the independent variable and the output is the dependent variable. In \(y = mx + b\), \(x\) is independent, \(y\) is dependent. In a formula such as \(A = \pi r^2\), \(r\) is independent and \(A\) is dependent. |
Roles can change. In the quadratic formula you will treat \(a, b, c\) as fixed and solve for \(x\). But if you later ask "for which values of \(c\) does this equation have a solution?", \(c\) has become the variable of interest. Mathematicians switch roles constantly and rarely announce it. The context, and phrases like "for fixed \(a\)" or "solve for \(t\)", tell you who is playing which part.
|
Same letter, different jobs
Conventions are only conventions. Physics writes \(a\) for acceleration (a variable), statistics writes \(a\) for an intercept (a parameter), and \(e\) might be Euler’s number or an error term. When you meet an unfamiliar formula, ask of each letter: Is this fixed for the discussion, or does it vary? Am I solving for it? Never assume from the letter alone. |
4.3. Anatomy of an expression: terms, factors, coefficients, like terms
4.3.1. The problem
To manipulate something you need names for its parts. A programmer who cannot say "argument", "return value", or "loop body" cannot discuss code. Algebra has the same need, and the vocabulary is small. Here is a typical expression, labelled:
|
Expression
An expression is a meaningful combination of numbers, variables, and operations, with no equals sign: \(7x^2 - 3x + 4\), \(\frac{a+b}{2}\), \(2\pi r\). An expression has a value once its variables are given values; it does not assert anything. |
|
Term
The terms of an expression are the pieces that are added together. In \(7x^2 - 3x + 4\) the terms are \(7x^2\), \(-3x\), and \(4\). Subtraction is read as adding a negative, so the minus sign travels with the term that follows it. Inside brackets things are grouped: \(3(x + 2) - 4y\) has two terms at the top level, \(3(x + 2)\) and \(-4y\). |
|
Factor
The factors of a term (or of a number) are the pieces that are multiplied together to make it. The term \(6x^2y\) has factors \(6\), \(x\), \(x\), \(y\) (and combinations of them such as \(2x\) or \(3xy\)). Terms are added; factors are multiplied. Keeping these two words apart avoids many errors. |
|
Coefficient
A coefficient is the numerical factor multiplying the variable part of a term. In \(7x^2 - 3x + 4\), \(7\) is the coefficient of \(x^2\), and \(-3\) is the coefficient of \(x\) (the sign is part of it). In \(x\) or \(-y\) the coefficients are \(1\) and \(-1\), usually not written. In \(ax^2\), with \(a\) a parameter, we also call \(a\) the coefficient. |
|
Constant term
The constant term is a term with no variable in it: the \(4\) in \(7x^2 - 3x + 4\). If there is no such term, the constant term is \(0\). |
|
Like terms
Like terms have exactly the same variable part, with each variable raised to the same power. \(5x^2y\) and \(-2yx^2\) are like terms (order of multiplication does not matter). \(3x\) and \(3x^2\) are not like terms; neither are \(xy\) and \(x\). Only like terms can be combined into a single term. |
4.3.2. Notation conventions worth restating
Algebra has a few writing conventions that are so ingrained nobody mentions them. After a gap they can trip you up.
-
Juxtaposition means multiplication. \(3x\) means \(3 \times x\); \(ab\) means \(a \times b\); \(2(x+1)\) means \(2 \times (x + 1)\). This only works for letters: \(23\) is twenty-three, not \(2 \times 3\), which is why you will see \(2 \cdot 3\) with a raised dot when two numbers are multiplied.
-
Numbers come first, then letters, usually alphabetically. Write \(3xy\), not \(x3y\) or \(y3x\). They are equal, but the standard order makes like terms easy to spot.
-
Exponents bind tighter than everything else. \(3x^2\) means \(3 \times (x^2)\), not \((3x)^2\). And \(-x^2\) means \(-(x^2)\), which is negative whenever \(x \neq 0\). (See Chapter 3.)
-
A fraction bar groups. \(\frac{a + b}{2}\) means \((a + b) \div 2\), even though no brackets are written. Typing it into code you must add them:
(a + b) / 2. -
Order of operations (brackets, exponents, multiplication and division, addition and subtraction) is exactly as in Chapter 1.
|
Degree of a term and of an expression
The degree of a term is the total number of variable factors in it: \(7x^2\) has degree 2, \(-3x\) has degree 1, \(4\) has degree 0, and \(5x^2y\) has degree 3. The degree of a polynomial (a sum of such terms with whole-number powers) is the largest degree among its terms. Degree 1 means linear, degree 2 quadratic, degree 3 cubic. You will use these words constantly from Chapter 5 on. |
|
The minus sign belongs to the term after it
In \(5 - 2x\), the terms are \(5\) and \(-2x\), so the coefficient of \(x\) is \(-2\), not \(2\). This matters the moment you rearrange: \(5 - 2x\) equals \(-2x + 5\), and it does not equal \(2x - 5\). If you reorder terms, each one carries its own sign with it. |
4.4. Expressions, equations, identities, and formulas
4.4.1. The problem
Compare these four lines:
They look similar, but they are four different kinds of statement. Line (a) asserts nothing. Line (b) is true for exactly one value of \(x\). Line (c) is true for every value of \(x\). Line (d) describes a relationship between three quantities. Confusing these kinds is the root of a surprising number of algebraic blunders, so it pays to have precise names.
|
Equation
An equation is a statement that two expressions are equal: left-hand side (LHS) \(=\) right-hand side (RHS). An equation may be true or false depending on the values of its variables. Example: \(2(x + 3) = 14\) is true when \(x = 4\) and false otherwise. |
|
Solution, root, solution set
A solution of an equation is a value of the unknown that makes it true. For an equation of the form "expression \(= 0\)", a solution is also called a root. The solution set is the collection of all solutions, written with braces: the solution set of \(x^2 = 9\) is \(\{-3, 3\}\). An equation may have one solution, several, infinitely many, or none (solution set \(\varnothing\), the empty set). |
|
Identity
An identity is an equation that is true for every value of its variables, such as \(2(x + 3) = 2x + 6\) or \((a + b)^2 = a^2 + 2ab + b^2\). Some books emphasise this with a triple bar, \(2(x + 3) \equiv 2x + 6\), read "is identically equal to". Identities are the tools of algebra: each one licenses you to replace one expression by another. |
|
Formula
A formula is an equation that expresses a rule or relationship between quantities, usually with one quantity isolated on the left, its subject: \(A = \ell w\), \(F = \tfrac{9}{5}C + 32\), \(v = u + at\). A formula is a recipe: give values to the quantities on the right and it tells you the subject. |
The same idea in table form:
| Kind | Example | Has an equals sign? | True when? |
|---|---|---|---|
Expression |
\(2(x+3)\) |
No |
Not a statement; it has a value |
Conditional equation |
\(2(x+3) = 14\) |
Yes |
For some values (here only \(x = 4\)) |
Identity |
\(2(x+3) = 2x + 6\) |
Yes |
For all values |
Contradiction |
\(2(x+3) = 2x + 7\) |
Yes |
For no values |
Formula |
\(A = \ell w\) |
Yes |
Defines one quantity in terms of others |
4.4.2. How to tell which kind you have
The reliable test is to simplify both sides and compare.
-
\(2(x + 3) = 2x + 6\): the left expands to \(2x + 6\), identical to the right. Identity.
-
\(2(x + 3) = 2x + 7\): the left expands to \(2x + 6\). Subtracting \(2x\) from both sides leaves \(6 = 7\), which is never true. Contradiction: no solutions.
-
\(2(x + 3) = 14\): the left is \(2x + 6\). Subtracting 6 gives \(2x = 8\), so \(x = 4\). Conditional: exactly one solution.
You will see these three outcomes again, under the names "one solution", "no solution", and "infinitely many solutions", for linear equations in Chapter 5 and for systems of equations in Chapter 6.
|
One example can refute an identity, but never prove one
Is \((x + 1)^2 = x^2 + 1\) an identity? Try \(x = 0\): both sides are \(1\). Looks good. Try \(x = 1\): the left is \(4\), the right is \(2\). It is not an identity. One counterexample is enough to destroy a claimed identity. But no number of agreeing examples is enough to prove one, because there are infinitely many values you have not tried. To prove an identity, transform one side into the other using rules you already trust, as we do in Section 4.7. |
4.5. Evaluating and substituting
4.5.1. The problem
A formula is only useful if you can feed values into it reliably. The rules are simple, yet substitution is where most sign errors in all of mathematics are born. Consider evaluating \(3x^2 - 2xy + y^2\) when \(x = -2\) and \(y = 3\). A hurried calculation gives \(-12 - 12 + 9 = -15\). The correct answer is \(33\). Where did the hurried version go wrong?
4.5.2. Intuition
Substitution means "replace each occurrence of the letter by the value". The danger is that a value is a whole object, while the expression around the letter may bind more tightly than you expect. \(x^2\) with \(x = -2\) means \((-2)^2 = 4\), not \(-2^2 = -4\). The cure is mechanical: always substitute inside brackets. Brackets cost nothing and they protect the value.
|
Evaluate, substitute
To evaluate an expression is to compute its numerical value for given values of its variables. To substitute is to replace a variable by something else, a number or another expression. Evaluation is substitution followed by arithmetic. |
Input: an expression and a value for each variable in it.
Steps:
-
Rewrite the expression, replacing every occurrence of each variable by its value in brackets.
-
Evaluate powers (exponents) first.
-
Then multiplications and divisions, left to right.
-
Then additions and subtractions, left to right.
-
Check the sign of the result against a rough estimate.
Output: the numerical value of the expression.
4.5.3. Worked example
Evaluate \(3x^2 - 2xy + y^2\) at \(x = -2\), \(y = 3\).
The hurried version made two errors: it squared \(-2\) to get \(-4\) (no brackets), and it lost the double negative in \(-2xy\). Writing every bracket prevents both.
4.5.4. Where you’d use this
-
Health. Body-mass index is \(\text{BMI} = m / h^2\) (mass in kg, height in m). For 70 kg and 1.75 m: \(70 / (1.75)^2 = 70 / 3.0625 \approx 22.9\). The brackets matter: \(70 / 1.75^2\) in a calculator is fine, but
=70/1.75*1.75in a spreadsheet gives 70. -
Physics. A stone dropped from rest falls \(s = \tfrac{1}{2}gt^2\) metres in \(t\) seconds. With \(g = 9.8\) and \(t = 3\): \(\tfrac{1}{2}(9.8)(3)^2 = 4.9 \times 9 = 44.1\) m. Timing the fall of a stone down a well estimates its depth.
-
Computing. Substitution at scale is what computers do. A spreadsheet fills a column by substituting each row’s values into one formula; a database evaluates
price * qty * (1 + tax_rate)for millions of rows; a GPU shader evaluates the same lighting expression for every pixel of every frame. Each is the procedure above, run very fast.
4.5.5. Substituting an expression
You can substitute an expression, not just a number. This is how one formula is fed into another. If \(y = x^2 + 2x\) and \(x = t - 1\), then
The brackets around \(t - 1\) are not optional: without them, \(x^2\) would become \(t - 1^2\), which is a different expression entirely. Substitution of expressions is the algebraic face of function composition, which you will meet in Chapter 11.
|
The square of a negative
With \(x = -3\):
So \(-x^2\) and \((-x)^2\) are different expressions, and \(-x^2 + (-x)^2 = 0\) for every \(x\). Spreadsheets get this "wrong": in Excel, |
Try it: −x² in Excel and Python.
4.5.6. Expression trees: what the order of operations really is
The order of operations can feel like an arbitrary rule to memorise. It is better understood as a description of a tree. Every expression has a hidden structure in which each operation combines exactly two sub-expressions. Here is \(3(x + 2) - 4y\):
To evaluate, start at the leaves (numbers and variables), replace each variable by its value, and work upward: each internal node applies its operation to the values of its children. The root’s value is the value of the expression. "Brackets first, then exponents, then multiplication, then addition" is simply the convention for how a flat line of symbols encodes such a tree. Brackets exist to override the default tree shape. Try it: Draw the tree of 3(x+2)−4y.
Substitution is now easy to picture: replace a leaf labelled \(x\) by the value, or by an entire subtree.
|
Build-a-tree
Type an expression and see its tree drawn live. Drag values onto the variable leaves and watch each internal node light up with its value as evaluation flows from leaves to root. Then remove a pair of brackets and see how the tree, and the answer, changes. |
4.6. Exercises: vocabulary, kinds of statement, substitution
-
In \(5a^2 - a + 7 - 2ab\), list the terms, and give the coefficient of \(a\), the coefficient of \(ab\), and the constant term.
-
Classify each as an expression, conditional equation, identity, contradiction, or formula: (a) \(3(x - 1) = 3x - 3\); (b) \(3(x - 1) = 3x + 3\); (c) \(3(x - 1) = 12\); (d) \(A = \pi r^2\); (e) \(4x - 7\).
-
Evaluate \(2a^2 - 3ab + b^3\) when \(a = -1\), \(b = 2\).
-
Evaluate \(-x^2 + (-x)^2\) when \(x = 4\). What happens for other values of \(x\), and why?
-
Substitute \(x = t - 1\) into \(x^2 + 2x + 1\) and simplify. Explain the result in one sentence.
-
Find one value of \(x\) that shows \((x + 1)^2 = x^2 + 1\) is not an identity. Are there any values for which it is true?
-
Draw the expression tree for \(\frac{a + b}{2} - c^2\). Which operation is at the root?
Answers
-
Terms: \(5a^2\), \(-a\), \(7\), \(-2ab\). Coefficient of \(a\) is \(-1\) (the sign belongs to the term, and the 1 is invisible). Coefficient of \(ab\) is \(-2\). Constant term \(7\).
-
(a) Identity: the left expands to \(3x - 3\). (b) Contradiction: the left is \(3x - 3\), and \(3x - 3 = 3x + 3\) reduces to \(-3 = 3\). (c) Conditional equation: \(3x - 3 = 12\) gives \(3x = 15\), \(x = 5\). (d) Formula (subject \(A\)). (e) Expression.
-
\(2(-1)^2 - 3(-1)(2) + (2)^3 = 2(1) - (-6) + 8 = 2 + 6 + 8 = 16\).
-
\(-(4^2) + (-4)^2 = -16 + 16 = 0\). It is \(0\) for every \(x\), because \((-x)^2 = x^2\) (a negative times a negative is positive), so the expression is \(-x^2 + x^2\).
-
\((t-1)^2 + 2(t-1) + 1 = (t^2 - 2t + 1) + (2t - 2) + 1 = t^2\). The original expression is \((x+1)^2\), and \(x + 1 = t\), so of course it becomes \(t^2\).
-
\(x = 1\): the left is \(4\), the right is \(2\). Expanding, \((x+1)^2 = x^2 + 2x + 1\), so the equation is \(x^2 + 2x + 1 = x^2 + 1\), i.e. \(2x = 0\): it is true only for \(x = 0\).
-
The root is the subtraction. Its left child is a division node (children: an addition node with leaves \(a\), \(b\); and the leaf \(2\)). Its right child is a power node with leaves \(c\) and \(2\). The fraction bar acts as brackets around \(a + b\).
4.7. Expanding brackets: the distributive law
4.7.1. The problem
Quick: what is \(7 \times 38\)? Most people who can do this in their heads do it as \(7 \times 40 - 7 \times 2 = 280 - 14 = 266\). They have used, perhaps without naming it, the single most important law in algebra. Every time you "multiply out brackets", you are using it. Every time you factorise, you are using it backwards. Let us make it explicit and see why it is true.
4.7.2. Intuition: the area model
Think of multiplication as the area of a rectangle. A rectangle of height 3 and width \(x + 2\) can be cut into two rectangles: one \(3\) by \(x\), one \(3\) by \(2\). The total area is unchanged by cutting, so \(3(x + 2) = 3x + 6\).
The same picture handles two brackets. A rectangle of width \(x + 2\) and height \(x + 3\) cuts into four pieces, one for each pairing of a width-part with a height-part:
Adding the four areas gives \(x^2 + 2x + 3x + 6 = x^2 + 5x + 6\). The picture explains the rule you may remember as "multiply everything in the first bracket by everything in the second".
4.7.3. Why it works
The distributive law is one of the basic properties of numbers:
It holds for every number, positive or negative, whole or fractional; the area picture is a convincing illustration for positive lengths, and the rules of signed arithmetic in Chapter 1 extend it to all numbers. Because \(b - c = b + (-c)\), it also covers subtraction: \(a(b - c) = ab - ac\). And because it holds for any \(a\), we may let \(a\) itself be a bracketed expression. That gives two-bracket expansion with no new rule at all:
|
Distributive law, expand
The distributive law says multiplication "distributes over" addition: \(a(b + c) = ab + ac\). To expand (or "multiply out") an expression is to use this law to remove brackets, producing a sum of terms. The opposite move, rewriting a sum as a product, is factoring (Section 4.9). |
|
Binomial, product
A binomial is an expression with two terms, such as \(x + 3\) or \(2a - 5b\) (bi = two, nomen = name). A monomial has one term, a trinomial three. A product is the result of a multiplication; "the product of \(x + 3\) and \(x + 2\)" means \((x + 3)(x + 2)\). |
Input: a product of two (or more) bracketed sums.
Steps:
-
Multiply each term of the first bracket by each term of the second, carrying signs with the terms. If the brackets have \(m\) and \(n\) terms, you will get \(m \times n\) products. Count them.
-
Simplify each product using the exponent law \(x^a x^b = x^{a+b}\) and sign rules.
-
Collect like terms (Section 4.8).
-
For three or more brackets: expand two of them first, then multiply the result by the next bracket.
Output: an equivalent expression with no brackets, a sum of terms.
4.7.4. Worked examples
Example 1. A negative multiplier. Expand \(-3(2x - 5)\).
Example 2. Two binomials with signs. Expand \((2x - 1)(x + 4)\). There are \(2 \times 2 = 4\) products:
Check by substitution. With \(x = 1\): the original is \((1)(5) = 5\); the expansion is \(2 + 7 - 4 = 5\). Agreement at one point does not prove the expansion right (see the Watch out in Section 4.4), but disagreement would prove it wrong, so this is a quick, worthwhile sanity check.
Example 3. A binomial times a trinomial. Expand \((x + 1)(x^2 - x + 1)\). There are \(2 \times 3 = 6\) products:
That cancellation is not luck: it is the "sum of cubes" factorisation \(x^3 + 1 = (x + 1)(x^2 - x + 1)\), which you will meet again in Chapter 7.
4.7.5. Special products worth knowing by sight
Three expansions appear so often that it is worth recognising them instantly, in both directions.
Each one is just the four-product rule. For the first: \((a + b)(a + b) = a^2 + ab + ba + b^2 = a^2 + 2ab + b^2\). For the third, the cross terms \(-ab\) and \(+ab\) cancel. In the area model, \((a + b)^2\) is a square of side \(a + b\) cut into an \(a^2\) square, a \(b^2\) square, and two \(ab\) rectangles.
|
The freshman’s dream
\((a + b)^2 \neq a^2 + b^2\). Squaring does not distribute over addition. With \(a = 3\), \(b = 4\): \((3 + 4)^2 = 49\) but \(3^2 + 4^2 = 25\). The missing \(2ab = 24\) is the two rectangles in the area picture. The same error in other clothing: \(\sqrt{a + b} \neq \sqrt{a} + \sqrt{b}\) and \(\frac{1}{a + b} \neq \frac{1}{a} + \frac{1}{b}\). Only multiplication distributes over addition. |
|
Mental arithmetic with special products
The difference of two squares turns certain multiplications into subtractions: \(49 \times 51 = (50 - 1)(50 + 1) = 2500 - 1 = 2499\), and \(97 \times 103 = 10000 - 9 = 9991\). The square of a sum does squares: \(103^2 = 10000 + 600 + 9 = 10609\). Before electronic calculators, tables of squares were used to multiply via the identity \(ab = \frac{(a + b)^2 - (a - b)^2}{4}\) ("quarter-squares multiplication"), and the same trick appears in some hardware multipliers. |
4.7.6. Alternative approaches and choosing a method
-
FOIL (First, Outer, Inner, Last) is a mnemonic for multiplying two binomials: \((a + b)(c + d) = ac + ad + bc + bd\). It is fine for exactly that case, but it is just "each term by each term" with an order attached, and it gives no help with a trinomial. Many teachers now discourage it for that reason.
-
The grid (box) method is the area model written as a table: write one bracket’s terms across the top, the other’s down the side, fill each cell with a product, then add all the cells. It scales to any number of terms and makes it hard to miss a product. It is the best choice when brackets have three or more terms.
-
Recognising a special product is fastest when it applies. Look for squares and for pairs like \((a + b)(a - b)\) before reaching for the general method.
Rule of thumb: spot a special product if you can; use "each by each" (or FOIL) for two binomials; use a grid for anything larger.
|
Resize the rectangle
Drag sliders for \(a\) and \(b\) and watch a square of side \(a + b\) split into \(a^2\), \(b^2\), and two \(ab\) rectangles. Toggle "freshman’s dream" to overlay \(a^2 + b^2\) alone and see exactly what area is missing. |
4.7.7. Where you’d use this
-
Interest on interest. £1000 at 5% for two years becomes \(1000(1 + r)^2 = 1000(1 + 2r + r^2)\) with \(r = 0.05\): \(1000(1 + 0.10 + 0.0025) = £1102.50\). The expansion shows where the money comes from: \(2r\) is two years of simple interest (£100), and \(r^2\) is the interest earned on the first year’s interest (£2.50).
-
Home and garden. A square lawn of side \(x\) metres gets a path 2 m wide all round. The outer square has side \(x + 4\), so the path’s area is \((x + 4)^2 - x^2 = x^2 + 8x + 16 - x^2 = 8x + 16\) square metres. For a 10 m lawn that is 96 m², which tells you how many paving slabs to buy.
-
Mental arithmetic. \(23 \times 17 = (20 + 3)(20 - 3) = 400 - 9 = 391\), the difference of two squares in action.
4.8. Collecting like terms and simplifying
4.8.1. The problem
Expanding usually leaves a mess: \(4(2x - y) - 3(x - 2y) + 5\) becomes a string of six terms. We want the simplest equivalent form. What does "simplest" mean, and which combinations are legal?
4.8.2. Intuition and why it works
\(3x + 5x = 8x\) because three apples plus five apples is eight apples. But the real justification is the distributive law read backwards:
That explains why only like terms combine. \(3x + 5x^2\) has no common variable part to pull out, so there is nothing to add: it is already as simple as it gets. Apples and apple-squares do not merge.
|
Simplify
To simplify an expression is to rewrite it in an equivalent form that is shorter or more useful, typically with brackets removed, like terms collected, and terms written in a standard order (usually decreasing powers: \(2x^2 + 7x - 4\)). "Simplest" depends on purpose: sometimes the factored form is the more useful one. |
Input: an expression.
Steps:
-
Expand any brackets. When a bracket is preceded by a minus sign, negate every term inside it.
-
Group like terms together (underline them, or reorder them, each term keeping its sign).
-
Add the coefficients within each group; keep the variable part unchanged.
-
Write the result in standard order and drop any terms with coefficient 0.
Output: an equivalent expression with no two like terms.
4.8.3. Worked example
Simplify \(4(2x - y) - 3(x - 2y) + 5\).
Check at \(x = 1, y = 1\): original \(4(1) - 3(-1) + 5 = 4 + 3 + 5 = 12\); result \(5 + 2 + 5 = 12\). Consistent.
|
Subtracting a bracket negates everything inside
\(10 - (x - 3)\) is \(10 - x + 3 = 13 - x\), not \(10 - x - 3\). A minus sign in front of a bracket is a hidden coefficient of \(-1\), and it must be distributed to every term inside. This single error accounts for a large fraction of all wrong answers in school algebra, and in hand-derived formulas in engineering too. |
|
Is it simpler or just different?
"Simplify" is not a precise instruction. \(x^2 - 1\) and \((x - 1)(x + 1)\) are equally simple. If you want to solve \(x^2 - 1 = 0\), the factored form is better; if you want to add it to \(3x^2 + 2\), the expanded form is better. Choose the form that serves your next step. |
4.9. Factoring out a common factor
4.9.1. The problem
Expanding turns products into sums. Often we need to go the other way. Suppose a shop sells items at \(12\) dollars, \(18\) dollars, and \(30\) dollars, and you buy \(n\) of each: the total \(12n + 18n + 30n\) is obviously \(60n\). Less obviously, \(6x^2 + 9x\) can be rewritten as \(3x(2x + 3)\). Why would you want to? Because a product tells you things a sum hides. A product is zero exactly when one of its factors is zero, so \(3x(2x + 3) = 0\) immediately gives \(x = 0\) or \(x = -\tfrac{3}{2}\); the sum \(6x^2 + 9x = 0\) tells you nothing at a glance. Products also cancel in fractions, and sums do not.
4.9.2. Intuition
Factoring is the distributive law run backwards: \(ab + ac = a(b + c)\). Look for something every term shares, pull it out to the front, and write what is left of each term inside a bracket. In the area picture, you are taking several rectangles of the same height and pushing them together into one long rectangle.
|
Factor, factorise, greatest common factor
To factor (US) or factorise (UK) an expression is to rewrite it as a product. The greatest common factor (GCF), also called the highest common factor (HCF), of several terms is the largest expression that divides all of them: the greatest common divisor of the coefficients times each shared variable raised to its lowest power. The GCF of \(12x^3y\), \(-18x^2y^2\), and \(6x^2y\) is \(6x^2y\). |
Input: a sum of terms.
Steps:
-
Find the GCD of the numerical coefficients (see Chapter 1 and Chapter 23).
-
For each variable that appears in every term, take the lowest power that occurs.
-
The GCF is the product of steps 1 and 2. (If the leading term is negative, you may choose to include a factor of \(-1\).)
-
Divide each term by the GCF; the quotients form the bracket.
-
Write GCF \(\times\) (bracket). Check by expanding. The bracket should have the same number of terms as the original, and its terms should have no common factor left.
Output: an equivalent product, GCF \(\times\) (sum).
4.9.3. Worked example
Factor \(12x^3y - 18x^2y^2 + 6x^2y\).
-
Coefficients \(12, -18, 6\): GCD is \(6\).
-
\(x\) appears as \(x^3, x^2, x^2\): lowest power \(x^2\).
-
\(y\) appears as \(y, y^2, y\): lowest power \(y\).
-
GCF \(= 6x^2y\).
Check: \(6x^2y \cdot 2x = 12x^3y\), \(6x^2y \cdot (-3y) = -18x^2y^2\), \(6x^2y \cdot 1 = 6x^2y\). Correct, and three terms in, three terms out.
|
The vanishing 1
When the whole of a term is the GCF, it leaves \(1\) behind, not nothing. \(6x^2y\) divided by \(6x^2y\) is \(1\), so the bracket is \((2x - 3y + 1)\). Writing \(6x^2y(2x - 3y)\) loses a term, and expanding to check catches the mistake instantly. |
Factoring out a negative. \(-4x + 8\) can be written \(4(-x + 2)\) or \(-4(x - 2)\). Both are correct. The second is usually preferred because it makes the bracket’s leading coefficient positive, which makes common brackets easier to spot, for instance in \(x(x - 2) - 4(x - 2) = (x - 4)(x - 2)\). That last move, pulling out a common bracket, is the seed of factoring by grouping in Chapter 7.
4.9.4. Where you’d use this
-
Shopping. Prices of £12, £18, and £30 plus 20% VAT on each: \(1.2 \times 12 + 1.2 \times 18 + 1.2 \times 30 = 1.2(12 + 18 + 30) = 1.2 \times 60 = £72\). Factoring is why a till can add up the items first and apply tax once.
-
Physics. A ball thrown upward at 20 m/s is at height \(h = 20t - 4.9t^2\) metres after \(t\) seconds. Factoring gives \(h = t(20 - 4.9t)\): a product is zero exactly when one of its factors is, so the ball is at ground level at \(t = 0\) and at \(t = 20 / 4.9 \approx 4.1\) s. That "factor, then set each factor to zero" move is the main method of Chapter 8.
-
Computing. Factored forms do fewer multiplications (Horner’s method, below), and factoring a common term out of a loop (
total = rate * sum(xs)instead ofsum(rate * x for x in xs)) is a standard optimisation.
4.9.5. Where factoring goes next
Taking out a common factor is the first and simplest kind of factoring. Recognising \(x^2 - 9\) as \((x - 3)(x + 3)\) (difference of two squares) and \(x^2 + 5x + 6\) as \((x + 2)(x + 3)\) are harder skills developed in Chapter 7 and Chapter 8. The habit to form now: when faced with a sum, always ask first, "is there a common factor?"
4.10. Exercises: expanding, collecting, factoring
-
Expand \(-4(3 - 2x)\).
-
Expand and simplify \((x - 5)(x + 3)\).
-
Expand \((3a - 2b)^2\) using a special product.
-
Simplify \(5(2x - 3) - 2(4x - 7)\).
-
Factor \(15x^2 - 10x\).
-
Factor \(8a^2b - 12ab^2 + 4ab\) completely.
-
Use special products to compute \(103^2\) and \(97 \times 103\) without a calculator.
-
Prove that the sum of any three consecutive integers is divisible by 3. (Let the smallest be \(n\).)
-
Expand \((x - 2)(x^2 + 2x + 4)\). What pattern from the chapter does the answer match?
Answers
-
\((-4)(3) + (-4)(-2x) = -12 + 8x\), usually written \(8x - 12\).
-
\(x \cdot x + 3x - 5x - 15 = x^2 - 2x - 15\).
-
\((a - b)^2 = a^2 - 2ab + b^2\) with \(a \to 3a\), \(b \to 2b\): \((3a)^2 - 2(3a)(2b) + (2b)^2 = 9a^2 - 12ab + 4b^2\).
-
\(10x - 15 - 8x + 14 = 2x - 1\). Note \((-2)(-7) = +14\).
-
GCF \(5x\): \(5x(3x - 2)\). Check: \(15x^2 - 10x\).
-
GCF of coefficients \(4\); lowest powers \(a^1\), \(b^1\). GCF \(4ab\): \(4ab(2a - 3b + 1)\). Don’t lose the \(1\).
-
\(103^2 = (100 + 3)^2 = 10000 + 600 + 9 = 10609\). \(97 \times 103 = (100 - 3)(100 + 3) = 10000 - 9 = 9991\).
-
\(n + (n + 1) + (n + 2) = 3n + 3 = 3(n + 1)\). Since \(n + 1\) is an integer, the sum is 3 times an integer. (This is a genuine proof: one algebraic computation covers every case, as in the "think of a number" trick.)
-
\(x^3 + 2x^2 + 4x - 2x^2 - 4x - 8 = x^3 - 8\). It is the difference-of-cubes cousin of Example 3: \(a^3 - b^3 = (a - b)(a^2 + ab + b^2)\) with \(a = x\), \(b = 2\).
4.11. Equations and the balance model
4.11.1. The problem
So far we have transformed expressions into equivalent expressions. With equations we want something different: to find the values that make the equation true. The strategy is to transform the equation step by step into something so simple that the answer can be read off, such as \(x = 4\). But which transformations are allowed? If you change an equation, how do you know the new one has the same solutions?
4.11.2. Intuition: the balance
Picture an old-fashioned pan balance. An equation says the two pans weigh the same. Whatever you do to one pan, you must do to the other, and the balance stays level. Below, each blue box is an unknown weight \(x\) and each orange disc weighs 1 unit.
Remove three discs from each side: the pans still balance, so \(2x = 8\). Halve the contents of each pan: still level, so \(x = 4\). Check: \(2(4) + 3 = 11\). Correct.
This is al-Khwarizmi’s "balancing", and it is the whole idea of equation solving. Chapter 5 develops it into a complete algorithm.
4.11.3. Why it works: equivalent equations
|
Equivalent equations
Two equations are equivalent if they have exactly the same solution set. \(2x + 3 = 11\), \(2x = 8\), and \(x = 4\) are equivalent: each is true for \(x = 4\) and for nothing else. Solving an equation means replacing it by a chain of equivalent equations, ending with one whose solution is obvious. |
Which operations produce an equivalent equation? The key requirement is that the step can be undone. If \(A = B\) then certainly \(A + 5 = B + 5\); and conversely, if \(A + 5 = B + 5\) we can subtract \(5\) to recover \(A = B\). Because we can go both ways, no solutions are gained or lost. The safe operations are:
-
add or subtract the same quantity on both sides (always reversible);
-
multiply or divide both sides by the same non-zero quantity (reversible: undo by dividing or multiplying);
-
replace either side by an equivalent expression (expanding, collecting, factoring);
-
swap the two sides.
|
Operations that are not reversible
Multiplying by zero destroys information: \(x = 3\) times 0 gives \(0 = 0\), which every \(x\) satisfies. Dividing by an expression that might be zero can lose solutions: dividing \(x^2 = 5x\) by \(x\) gives \(x = 5\), silently losing the solution \(x = 0\). Factor instead: \(x^2 - 5x = x(x - 5) = 0\), so \(x = 0\) or \(x = 5\). Squaring both sides can create solutions: \(x = 3\) squared gives \(x^2 = 9\), which also has \(x = -3\). Squaring is sometimes necessary (equations with square roots), but then every candidate solution must be checked in the original equation. Such impostors are called extraneous solutions. |
|
Equals means "is the same as", not "the answer is"
Many people learned to treat \(=\) as a button meaning "now write the answer", and so write chains such as \(3 + 4 = 7 \times 2 = 14\). Each \(=\) in a chain must be a true statement on its own, and \(3 + 4 = 7 \times 2\) is false. In algebra, \(=\) is a symmetric relation: \(A = B\) and \(B = A\) say the same thing, and both sides are on equal footing. Keep chains of equalities honest and your derivations will be checkable line by line. |
|
Balance builder
Load an equation onto a virtual balance as boxes (unknowns) and discs (units), including "negative" balloons that pull upward. Apply operations to both pans and watch the beam. Try an illegal move, such as removing a disc from one pan only, and watch it tip. Try "multiply both pans by 0" and watch every possible \(x\) become a solution. |
4.11.4. Where you’d use this
-
Small business. A cake stall costs £40 to set up; each cake costs £0.50 to make and sells for £2. Breaking even after \(n\) cakes means \(40 + 0.5n = 2n\). Subtract \(0.5n\) from both pans: \(40 = 1.5n\), so \(n = 40 / 1.5 \approx 26.7\). You need to sell 27 cakes before you make any profit.
-
Everywhere else. Every "how many/how long/how much" question with a known formula is an equation to solve: how many months to save for a £600 phone at £45 a month (\(45m = 600\), \(m \approx 13.3\), so 14 months); what dose gives a target blood concentration; how many servers handle a forecast load. Chapter 5 turns this into a systematic method.
4.12. Rearranging formulas: changing the subject
4.12.1. The problem
The formula \(F = \tfrac{9}{5}C + 32\) converts a Celsius temperature to Fahrenheit. A thermostat in a US house reads \(68^\circ\text{F}\); what is that in Celsius? You could substitute \(F = 68\) and solve the resulting equation. But if you need to convert a thousand readings, or write a function f_to_c, you want a formula with \(C\) as its subject. Rearranging is equation solving where the "answer" is an expression rather than a number.
4.12.2. Intuition: do and undo
Read the formula as a recipe that builds \(F\) from \(C\): start with \(C\), multiply by \(\tfrac{9}{5}\), then add \(32\). To get back from \(F\) to \(C\), undo the steps in reverse order, each with its inverse operation: subtract \(32\), then divide by \(\tfrac{9}{5}\) (that is, multiply by \(\tfrac{5}{9}\)).
It is the same logic as getting undressed: you put on socks and then shoes, so you take off shoes and then socks. Inverses in reverse order.
|
Subject of a formula, inverse operation
The subject of a formula is the variable standing alone on one side, usually the left: \(F\) is the subject of \(F = \tfrac{9}{5}C + 32\). Changing the subject (also rearranging, transposing, or solving for a variable) means producing an equivalent formula with a different subject. An inverse operation undoes another: addition and subtraction are inverses, as are multiplication and division (by a non-zero number), and squaring and taking the square root (with care about signs). |
Input: a formula and the variable \(v\) that should become the subject.
Steps:
-
Clear fractions by multiplying both sides by any denominators (noting which quantities must be non-zero).
-
Expand brackets that contain \(v\).
-
Gather all terms containing \(v\) on one side and all other terms on the other side (add or subtract terms on both sides).
-
If \(v\) appears in more than one term, factor it out: \(v(\ldots)\).
-
Divide both sides by the coefficient of \(v\) (state that it must be non-zero).
-
If \(v\) appears inside a power or root, apply the inverse (root or power) last, considering \(\pm\).
-
Check: substitute a convenient set of numbers into both the original and the new formula.
Output: a formula \(v = \ldots\) with \(v\) absent from the right-hand side, plus any conditions for validity.
4.12.3. Worked examples
Example 1. Celsius from Fahrenheit. Make \(C\) the subject of \(F = \tfrac{9}{5}C + 32\).
So \(68^\circ\text{F}\) is \(\tfrac{5}{9}(36) = 20^\circ\text{C}\). Check: \(\tfrac{9}{5}(20) + 32 = 36 + 32 = 68\). Correct.
Example 2. A physics formula. The velocity after constant acceleration is \(v = u + at\) (initial velocity \(u\), acceleration \(a\), time \(t\)). Make \(a\) the subject.
That is the familiar "change in velocity over time". The condition \(t \neq 0\) is not pedantry: at \(t = 0\) no time has passed and the acceleration cannot be deduced.
Example 3. A trapezoid. The area of a trapezoid with parallel sides \(a, b\) and height \(h\) is \(A = \tfrac{1}{2}h(a + b)\). Make \(b\) the subject.
Here we did not expand \(h(a + b)\): dividing by \(h\) was cleaner. Expanding first (\(2A = ha + hb\), then \(hb = 2A - ha\), then \(b = \tfrac{2A - ha}{h}\)) gives the same answer in a different form. Both are correct; choose whichever path keeps the algebra short.
Example 4. The subject appears twice. Make \(x\) the subject of \(y = \dfrac{x + 1}{x - 2}\).
This is the important case. The variable appears in two places, so no single "undo" chain will isolate it. The procedure handles it: clear the fraction, gather the \(x\) terms, factor.
Check with \(x = 5\): \(y = \tfrac{6}{3} = 2\), and the new formula gives \(x = \tfrac{1 + 4}{1} = 5\). Correct. The condition \(y \neq 1\) has meaning: no \(x\) makes \(\tfrac{x + 1}{x - 2}\) equal to 1 (that would require \(x + 1 = x - 2\), i.e. \(1 = -2\)). In the language of Chapter 11, you have just computed an inverse function and found a value outside its domain.
Example 5. A root. A pendulum’s period is \(T = 2\pi\sqrt{L/g}\). Make \(L\) the subject.
With \(g \approx 9.81\ \text{m/s}^2\) and a desired period of \(2\) seconds, \(L \approx 9.81 \times 4 / 39.48 \approx 0.994\) m: a "seconds pendulum" is almost exactly a metre long. (That near-coincidence is not an accident; it was once proposed as the definition of the metre.)
|
Rearranging can silently divide by zero
Every time you divide by a letter or an expression, you are assuming it is not zero. Write the condition down (\(t \neq 0\), \(y \neq 1\)). And when you take a square root to undo a square, remember \(\pm\): from \(A = \pi r^2\) you get \(r = \sqrt{A/\pi}\) only because a radius cannot be negative; from \(x^2 = k\) in general you get \(x = \pm\sqrt{k}\). |
4.12.4. Alternative approaches and choosing a method
-
The do/undo chain is quickest when the variable appears once. Read off the order of operations applied to it, then reverse.
-
The general procedure (clear fractions, gather, factor, divide) is needed when the variable appears more than once. It always works for formulas that are linear in the target variable.
-
Substitute numbers first, then solve is fine when you only need one answer, not a reusable formula.
-
Not every formula can be rearranged. \(y = x + \sin x\) or \(y = xe^x\) cannot be solved for \(x\) with elementary operations. Then numerical methods such as Newton’s method take over (Chapter 18, Chapter 32).
4.12.5. Where you’d use this
-
Electronics. Ohm’s law \(V = IR\) has three useful subjects: \(I = V/R\) (12 V across a 4 Ω heater draws 3 A), \(R = V/I\) (which resistor limits an LED’s current), and \(V\) itself.
-
Travel. \(d = vt\) rearranges to \(t = d/v\): 150 miles at an average 60 mph takes 2.5 hours; and to \(v = d/t\) for the average speed you need to arrive on time.
-
Spreadsheets and code. Spreadsheets compute forwards only: you put \(C\) in a cell and \(F\) comes out. To go the other way you either rearrange the formula yourself or use a numerical "goal seek". Rearranging once, by hand, is faster, exact, and testable.
|
Rearrange and verify
Pick a formula from physics or finance and a target variable. Apply operations step by step from a palette ("subtract \(u\) from both sides", "factor out \(x\)"); the lab refuses illegal moves and flags any division by an expression that could be zero. When you finish, it round-trips random values through your rearranged formula to confirm it is correct. |
4.13. Translating words into algebra
4.13.1. The problem
Real problems arrive in words, not symbols. "A taxi charges a fixed fee of $3 plus $1.80 per mile. How far can you go for $30?" The mathematics here is trivial once written down; the hard part is the writing down. Translation is a skill in its own right, and it has a few traps that catch even fluent readers.
4.13.2. A phrase book
| Words | Algebra |
|---|---|
the sum of \(a\) and \(b\); \(a\) increased by \(b\) |
\(a + b\) |
the difference of \(a\) and \(b\); \(a\) minus \(b\) |
\(a - b\) |
\(b\) less than \(a\); \(a\) decreased by \(b\) |
\(a - b\) (note the order) |
the product of \(a\) and \(b\); \(a\) times \(b\) |
\(ab\) |
the quotient of \(a\) and \(b\); \(a\) per \(b\) |
\(\frac{a}{b}\) |
twice \(n\); double \(n\) |
\(2n\) |
the square of the sum of \(a\) and \(b\) |
\((a + b)^2\) |
the sum of the squares of \(a\) and \(b\) |
\(a^2 + b^2\) |
\(a\) is 20% more than \(b\) |
\(a = 1.2b\) |
\(a\) exceeds \(b\) by 5 |
\(a - b = 5\) |
three consecutive integers |
\(n,\ n + 1,\ n + 2\) |
an even number; an odd number |
\(2k\); \(2k + 1\) (\(k\) an integer) |
Input: a problem stated in words.
Steps:
-
Identify the quantity asked for. Give it a letter and write down what the letter means, with units ("let \(m\) = distance in miles").
-
Express every other quantity in the problem in terms of that letter (and any given numbers).
-
Find the sentence that says two things are equal (or that one exceeds another) and write it as an equation.
-
Solve the equation (Chapter 5).
-
Answer the original question in words, with units, and check the answer against the original wording, not against your equation.
Output: an equation modelling the problem, and its interpreted solution.
4.13.3. Worked examples
Example 1. The taxi. Let \(m\) be the distance in miles. The cost in dollars is \(3 + 1.80m\). A budget of $30 means
You can travel 15 miles. Check in words: $3 plus 15 miles at $1.80 is \(3 + 27 = 30\) dollars. Correct. The expression \(3 + 1.80m\) is a linear cost model, a fixed cost plus a rate; Chapter 5 builds a whole toolkit around models of this shape.
Example 2. Consecutive integers. Three consecutive integers add to 87. Find them.
Let the smallest be \(n\); the others are \(n + 1\) and \(n + 2\).
The integers are \(28, 29, 30\). Check: \(28 + 29 + 30 = 87\).
Example 3. "Less than" reverses. "Five less than twice a number is 17." The phrase "five less than \(X\)" means \(X - 5\), so the equation is \(2n - 5 = 17\), giving \(2n = 22\), \(n = 11\). Writing \(5 - 2n = 17\) is the classic mistake: English puts the 5 first, algebra puts it last.
|
The students-and-professors problem
"At a university there are six times as many students as professors. Write an equation using \(S\) for the number of students and \(P\) for professors." A famous 1980s study found that a large fraction of engineering students wrote \(6S = P\). The words "six times… students" sit next to each other, so the 6 gets attached to \(S\). But there are more students, so the professors' number must be multiplied: \(S = 6P\). The defence: test the equation with numbers. If there are 10 professors there are 60 students, and \(S = 6P\) gives \(60 = 60\); \(6S = P\) gives \(360 = 10\). Also make sure letters stand for numbers of things ("\(S\) = number of students"), not for the things themselves ("\(S\) = students"). |
|
Applications: where expressions and formulas live
Spreadsheets are the most widely used algebra system in the world: a cell formula such as |
4.14. Variables in mathematics and in programming
4.14.1. The problem
A programmer reading algebra brings strong habits from code, and some of them mislead. The line
x = x + 1
is perfectly ordinary in Python, C, or Java. As a mathematical equation it is a contradiction: subtract \(x\) from both sides and you get \(0 = 1\). Same symbols, entirely different meanings. Where exactly do the two notions of "variable" and "equals" part company?
4.14.2. Two meanings of "="
| Mathematics | Most programming languages | |
|---|---|---|
\(=\) means |
a claim that two things are equal (a relation, symmetric) |
an instruction: evaluate the right, store it in the left (assignment) |
|
a false statement for every \(x\) (\(0 = 1\)) |
"increment x" |
Equality test |
\(=\) |
|
Assignment |
\(:=\) or "let \(x\) = …" (definitions) |
|
A variable is |
a name for a value that is fixed within the argument, even if unknown |
a name for a storage location whose contents change over time |
Order of lines |
irrelevant to truth (all statements hold simultaneously) |
crucial (each line changes state) |
x = 5 # assignment: bind the name x to the value 5
x = x + 1 # read x (5), add 1, rebind x to 6
print(x) # 6
print(x == x + 1) # equality test: is 6 equal to 7? False
6 False
Within a single mathematical argument, a variable never changes value. When we wrote \(2x + 3 = 11\), then \(2x = 8\), then \(x = 4\), we did not change \(x\): we produced a sequence of equivalent statements about the same unknown. In code, by contrast, the same name can hold different values at different moments, which is why reasoning about imperative programs requires talking about time ("after line 3, x is 6").
|
Bound and free variables
A variable is free in an expression if the expression’s value depends on it, and bound if it is only a placeholder inside some construction. In \(\sum_{i=1}^{n} i^2\) (the sum of \(i^2\) as \(i\) runs from 1 to \(n\), see Chapter 14), \(n\) is free and \(i\) is bound: renaming \(i\) to \(k\) changes nothing. Programmers know this as scope: a loop counter is local to the loop, exactly like a bound variable. |
4.15. Exercises: equations, rearranging, translating
-
Which of these operations, applied to both sides of an equation, always gives an equivalent equation? (a) add \(7\); (b) multiply by \(x\); (c) divide by \(3\); (d) square; (e) subtract \(2x\).
-
Make \(r\) the subject of \(C = 2\pi r\).
-
Make \(s\) the subject of \(v^2 = u^2 + 2as\).
-
Make \(w\) the subject of \(P = 2(\ell + w)\).
-
The lens formula is \(\dfrac{1}{f} = \dfrac{1}{u} + \dfrac{1}{v}\). Make \(v\) the subject.
-
Make \(x\) the subject of \(y = \dfrac{2x + 3}{x - 1}\). For which value of \(y\) does your formula fail, and why?
-
Translate and solve: "Five less than twice a number is 17."
-
A taxi charges $3 plus $1.80 per mile. Write an expression for the cost of an \(m\)-mile trip and find the cost of a 12-mile trip.
-
A rectangle’s length is 3 cm more than twice its width, and its perimeter is 54 cm. Find its dimensions.
-
A programmer claims that
total = total + price"proves" \(\text{price} = 0\). Explain the confusion in one or two sentences.
Answers
-
(a), (c), (e) always give equivalent equations. (b) fails if \(x = 0\) (it can introduce the solution \(x = 0\)). (d) can introduce extraneous solutions (\(x = 3\) becomes \(x^2 = 9\), which also allows \(-3\)).
-
\(r = \dfrac{C}{2\pi}\).
-
\(v^2 - u^2 = 2as\), so \(s = \dfrac{v^2 - u^2}{2a}\), with \(a \neq 0\).
-
\(\tfrac{P}{2} = \ell + w\), so \(w = \tfrac{P}{2} - \ell\) (equivalently \(\tfrac{P - 2\ell}{2}\)).
-
\(\tfrac{1}{v} = \tfrac{1}{f} - \tfrac{1}{u} = \tfrac{u - f}{fu}\), so \(v = \dfrac{fu}{u - f}\), with \(u \neq f\). (Check: \(f = 10\), \(u = 30\) gives \(v = 300/20 = 15\), and \(\tfrac{1}{30} + \tfrac{1}{15} = \tfrac{3}{30} = \tfrac{1}{10}\). Correct.)
-
\(y(x - 1) = 2x + 3 \Rightarrow yx - y = 2x + 3 \Rightarrow yx - 2x = y + 3 \Rightarrow x(y - 2) = y + 3 \Rightarrow x = \dfrac{y + 3}{y - 2}\). It fails at \(y = 2\): no \(x\) gives \(y = 2\), since \(2x + 3 = 2(x - 1)\) would mean \(3 = -2\).
-
\(2n - 5 = 17 \Rightarrow 2n = 22 \Rightarrow n = 11\). Check: \(2(11) - 5 = 17\).
-
\(C = 3 + 1.80m\). For \(m = 12\): \(3 + 21.60 = 24.60\) dollars.
-
Let width \(w\) cm, length \(2w + 3\) cm. \(2\big(w + (2w + 3)\big) = 54 \Rightarrow 6w + 6 = 54 \Rightarrow w = 8\). Length \(2(8) + 3 = 19\) cm. Check: \(2(8 + 19) = 54\).
-
In code,
=is assignment: it stores the old total plus the price as the new total. Two different moments in time are involved, so there is no equation to subtract from. Read mathematically as \(t = t + p\), it would indeed force \(p = 0\), but that is not what the code says.
4.16. Interactive tools
Browser tools on the companion website that go with this chapter. Each example link in the chapter opens one of them with that example already set up.
4.17. Mastery check
-
Which of these are like terms: \(3x^2y\), \(-2xy^2\), \(5yx^2\), \(7xy\)?
-
Evaluate \((a - b)^2 - (a^2 - b^2)\) when \(a = 3\), \(b = -1\).
-
Expand and simplify \(2(x + 3)(x - 1) - (x - 2)^2\).
-
Factor completely: \(18p^3q - 27p^2q^2\).
-
The surface area of a closed cylinder is \(S = 2\pi r^2 + 2\pi rh\). Make \(h\) the subject.
-
Make \(x\) the subject of \(a(x - b) = c(x + d)\), and state any condition.
-
Is \(4(x - 2) - 2(2x - 4) = 0\) a conditional equation, an identity, or a contradiction?
-
Translate into an equation: "A number’s square exceeds the number itself by 12." Verify that \(4\) and \(-3\) both satisfy it.
Decision rule: All correct without hesitation → move on to Chapter 5. Stuck on 1–2 → reread Section 4.3, Section 4.7, or Section 4.12 as appropriate. Stuck on more → work the three exercise sets in this chapter first, then retry.
Mastery check answers
-
\(3x^2y\) and \(5yx^2\) (same variable part, \(x^2y\)). \(-2xy^2\) has \(y\) squared instead, and \(7xy\) has lower powers.
-
\((3 - (-1))^2 - (3^2 - (-1)^2) = 4^2 - (9 - 1) = 16 - 8 = 8\).
-
\((x + 3)(x - 1) = x^2 + 2x - 3\), so the first part is \(2x^2 + 4x - 6\). \((x - 2)^2 = x^2 - 4x + 4\). Subtracting (negate every term): \(2x^2 + 4x - 6 - x^2 + 4x - 4 = x^2 + 8x - 10\).
-
GCD of 18 and 27 is 9; lowest powers \(p^2\), \(q\). \(9p^2q(2p - 3q)\).
-
\(S - 2\pi r^2 = 2\pi rh\), so \(h = \dfrac{S - 2\pi r^2}{2\pi r} = \dfrac{S}{2\pi r} - r\) (with \(r > 0\)).
-
\(ax - ab = cx + cd \Rightarrow ax - cx = ab + cd \Rightarrow x(a - c) = ab + cd \Rightarrow x = \dfrac{ab + cd}{a - c}\), provided \(a \neq c\).
-
Identity: \(4x - 8 - 4x + 8 = 0\), i.e. \(0 = 0\), true for every \(x\).
-
\(n^2 = n + 12\) (or \(n^2 - n = 12\)). \(n = 4\): \(16 = 16\). \(n = -3\): \(9 = -3 + 12 = 9\). Solving such equations systematically is the subject of Chapter 8.