Part II · Algebra Chapter 7 of 60
Letters for numbers
A magician guesses the number you thought of and does mental arithmetic faster than a calculator. We'll expose his tricks one by one, and along the way learn to write down a rule that holds for all numbers at once.
Builds on: 6 · Root two and the real numbers
You will learn
- write in letters a rule that holds for all numbers, and evaluate an expression
- expand brackets and use the special products, including for mental arithmetic
- tell an identity from a coincidence, and factor expressions
The last chapter left a puzzle. The rule $\frac mn \to \frac{m + 2n}{m + n}$ produced fractions six times in a row for which $m^2 - 2n^2$ was $1$ or $-1$. Coincidence or law? You can't check every step: there are infinitely many. We need to reason about numbers we don't know as confidently as about familiar ones: about all $m$ and $n$ at once.
We'll come back to the puzzle once we've gathered some tools. Let's start with a trick. Think of a number. Multiply it by two. Add ten. Halve the result. Subtract the number you first thought of.
You got five.
The trick works with three, with a hundred, with minus seven and even with $\sqrt2$ from the last chapter. You can't check every number, but you can make sure the trick never fails, and the way to do it is the main tool of algebra. In this chapter we'll watch several tricks, and each time it's letters that expose the magician.
Trick one: always five
Put the number you thought of into an opaque bag: only you know how much is inside. Multiplying by two means taking two such bags. Adding ten means putting ten coins next to them. Halving means splitting everything into two equal heaps and keeping one: it holds one bag and five coins. Subtracting the original number means removing the bag. Five coins remain, whatever was inside.
Drawing bags takes a while, so instead of a bag we write a letter. The whole trick fits on one line:
$$x \;\to\; 2x \;\to\; 2x + 10 \;\to\; x + 5 \;\to\; 5.$$This line proves infinitely many statements at once: "with $x = 3$ you get five", "with $x = 100$ you get five", and so on for every number. There's no need to check them one by one any more.
A variable is a letter in place of which numbers can be substituted. An expression is a combination of numbers, variables, operation signs and brackets: $2x + 10$, $\frac{a + b}{2}$, $3a^2 - 2ab$. If you substitute numbers for the variables and carry out the operations, you get the value of the expression: for $x = 3$ the value of $2x + 10$ is $16$.
The magician is no wizard, of course. He chooses the steps so that the letter cancels out at the end. Try it yourself: build a trick from the buttons and watch what happens to the bag.
The second prepared trick works differently. Think of a number, multiply by 2, add 5, multiply by 5, subtract 25 and say the result. The magician drops the zero at the end and names your number. The exposure:
$$x \;\to\; 2x \;\to\; 2x + 5 \;\to\; 10x + 25 \;\to\; 10x.$$Here the letter doesn't vanish, but the answer is very simple: the number you thought of with a zero on the end. The magician solves the reverse problem: from the result he finds $x$. We'll return to this reverse problem at the very end of the chapter.
Which of these sequences of steps is a trick whose answer doesn't depend on the number thought of?
$x \to 3x \to 3x + 6 \to x + 2 \to 2$. The bag disappears, and every spectator gets $2$.
How letters got into arithmetic
For thousands of years problems with an unknown were written out in words. Babylonian scribes, Egyptian and Greek mathematicians, and in the ninth century the Baghdad scholar al-Khwarizmi set out solutions in phrases like "halve the number of roots, multiply the half by itself, add…". The first notable step towards symbols was taken by Diophantus of Alexandria: in his Arithmetica (dated by most scholars to the third century AD) the unknown had its own sign, and there were abbreviations for its powers. But a sign for the unknown is only half the job.
Operation signs appeared surprisingly late. "Plus" and "minus" were first printed in 1489, in a German textbook of commercial arithmetic by Johannes Widmann. The equals sign was invented by the Welshman Robert Recorde in 1557, who explained his choice this way: no two things can be more equal than a pair of parallel lines.
The decisive step was taken by the French lawyer François Viète, an adviser to two kings. In his Introduction to the Analytic Art (1591) he began using letters not only for unknown quantities but for known ones too: vowels for unknowns, consonants for givens. It seems a small thing, but it changes everything. As long as the known numbers are written as digits, a problem is solved for one set of numbers. When they are letters too, the solution works for every set at once, and the answer becomes a formula.
The now-familiar $x$, $y$, $z$ for unknowns and $a$, $b$, $c$ for knowns were established by René Descartes in his Geometry (1637). He wrote powers almost as we do, $x^3$, $x^4$, though out of old habit he often wrote $xx$ for $x^2$. There's a lovely story that $x$ is the Spanish rendering of the Arabic word "shay" ("thing"), used for the unknown. There's no documentary evidence for it; all that is certain is that letters from the end of the alphabet for unknowns caught on after Descartes.
We've already used a formula in chapter 0: the number of pieces of a circle, $1 + \binom{n}{2} + \binom{n}{4}$, is a rule for all $n$ at once. The area of a rectangle, $S = ab$, is a rule for all rectangles at once too. The letters in them are not a mystery but a place where numbers get substituted.
Find the value of $3a^2 - 2ab$ for $a = -2$ and $b = 5$.
$3 \cdot (-2)^2 - 2 \cdot (-2) \cdot 5 = 3 \cdot 4 + 20 = 32$. Note: $(-2)^2 = 4$, not $-4$, because the minus sits inside the bracket being squared. But $-2^2$ without brackets equals $-4$.
Trick two: multiplying by 11
Name a two-digit number and the magician multiplies it by 11 on the spot. $43 \cdot 11$? That's 473. $62 \cdot 11$? 682. The secret: between the two digits of the number he writes their sum. The digits of 43 add up to 7, hence 4-7-3. And $78 \cdot 11$? The digit sum is 15: the five goes in the middle, and the one is added to the seven, giving 858.
To expose this trick we'll have to multiply expressions with letters. All we'll use for that is a few laws of arithmetic that hold for any numbers. We wrote them out back in chapter 2, in the debate with the Sceptic; let's recall them, because every proof in this chapter rests on them and on them alone.
For any numbers $a$, $b$, $c$:
- the commutative laws: $a + b = b + a$ and $ab = ba$;
- the associative laws: $(a + b) + c = a + (b + c)$ and $(ab)c = a(bc)$;
- the distributive law: $a(b + c) = ab + ac$.
We don't prove these laws; we take them as the basic properties of numbers. For natural numbers you can see them on heaps of pebbles and rectangles of tiles, and in chapter 42 they become the axioms with which algebra begins. The distributive law has already helped us in chapter 2: it's what makes minus times minus plus. Its picture is a rectangle with sides $a$ and $b + c$, cut into two rectangles $a \times b$ and $a \times c$.
If a two-digit number has digits $a$ and $b$, then $\overline{ab} \cdot 11 = 100a + 10(a + b) + b$: $a$ hundreds, $a + b$ tens, $b$ units.
The idea: write the number in terms of its digits and multiply using the distributive law. The number with digits $a$ and $b$ consists of $a$ tens and $b$ units, so it equals $10a + b$; that's the positional notation of chapter 1. Split $11 = 10 + 1$ and apply the distributive law:
$$\begin{aligned}(10a + b) \cdot 11 &= (10a + b) \cdot 10 + (10a + b) \\ &= 100a + 10b + 10a + b \\ &= 100a + 10(a + b) + b.\end{aligned}$$In the second line we expanded the brackets once more, and in the third we gathered the tens together, $10b + 10a = 10(a + b)$, which is the distributive law read from right to left. If $a + b \ge 10$, the tens place holds more than nine, and ten tens, a hundred, is carried into the hundreds: hence the carry for 78.
In the exposure we expanded brackets twice, and each bracket had two terms. This kind of multiplication comes up all the time, and it's worth understanding once and for all what it gives.
For any numbers $a$, $b$, $c$, $d$ we have $(a + b)(c + d) = ac + ad + bc + bd$.
The idea: count the area of one rectangle in two ways, as a whole and piece by piece.
In the answer to the example, the terms $-5x$ and $3x$ differ only in the number in front of the letter. They can be added.
In the term $-5x$ the number $-5$ is called the coefficient, and $x$ the letter part. Terms with the same letter part are called like terms. They are combined by adding the coefficients: $-5x + 3x = -2x$. This is the same distributive law read from right to left: $-5x + 3x = (-5 + 3)x$.
Expand the brackets in $(2x - 1)(x - 1) - x(x - 1)$ and collect like terms. What is the coefficient of $x$?
$(2x - 1)(x - 1) = 2x^2 - 2x - x + 1 = 2x^2 - 3x + 1$, and $x(x - 1) = x^2 - x$. Subtract, changing the signs of the second expression: $2x^2 - 3x + 1 - x^2 + x = x^2 - 2x + 1$. The coefficient of $x$ is $-2$. Notice in passing that the result is a square: $x^2 - 2x + 1 = (x - 1)^2$. Why that happened will become clear in the next section.
Trick three: squares in your head
The magician names the square of a number ending in five instantly: $35^2 = 1225$, $65^2 = 4225$, $85^2 = 7225$. The recipe is short: multiply the number of tens by the next number up and append 25. For 35: $3 \cdot 4 = 12$, append 25, and you get 1225. For 85: $8 \cdot 9 = 72$, giving 7225.
To expose this trick we need the square of a sum: a product of sums in which both brackets are the same.
For any numbers $a$ and $b$ we have $(a + b)^2 = a^2 + 2ab + b^2$.
The idea: cut a square with side $a + b$ into pieces whose areas we know.
If a number has $n$ tens and 5 units, its square equals $100\,n(n + 1) + 25$: append 25 to the product $n(n + 1)$.
The idea: write the number as the sum $10n + 5$ and square it using the formula we've just proved, with $a = 10n$ and $b = 5$:
$$\begin{aligned}(10n + 5)^2 &= (10n)^2 + 2 \cdot 10n \cdot 5 + 5^2 \\ &= 100n^2 + 100n + 25 \\ &= 100\,n(n + 1) + 25.\end{aligned}$$In the last line the common factor $100n$ has been taken out of the first two terms, the distributive law from right to left. The number $100 \cdot n(n + 1)$ ends in two zeros, so the last two digits of the square are 25, and in front of them stands $n(n + 1)$. The argument doesn't depend on $n$, so the recipe works for all such numbers, 15 or 999,995 alike.
If the bracket holds a difference, only the sign of the doubled product changes. And if you multiply the sum and the difference of the same two numbers, the doubled product disappears altogether.
For any numbers $a$ and $b$ we have $(a - b)^2 = a^2 - 2ab + b^2$.
The idea: get the square with side $a - b$ by cutting two strips off the square with side $a$, and count what was cut carefully. Let $a > b > 0$.
For any numbers $a$ and $b$ we have $(a - b)(a + b) = a^2 - b^2$.
The idea: rearrange a shape of area $a^2 - b^2$ into a rectangle. Let $a > b > 0$.
The square of a sum and of a difference, the difference of squares, and the cube of a sum and sum of cubes from the next section are called the special products. They save work in both directions: from left to right they expand brackets, from right to left they assemble an expression into a product.
Work out without a calculator: $102 \cdot 98$.
Both factors are 2 away from 100: $102 \cdot 98 = (100 + 2)(100 - 2) = 10{,}000 - 4 = 9996$.
Trick four: a cube root in five seconds
Think of a two-digit number, cube it on a calculator and say the result. Say, 438,976. The magician replies almost at once: 76.
He looks at two things. The first is the last digit of the cube. Here are the cubes of the one-digit numbers:
| $n$ | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| $n^3$ | 0 | 1 | 8 | 27 | 64 |
| $n$ | 5 | 6 | 7 | 8 | 9 |
| $n^3$ | 125 | 216 | 343 | 512 | 729 |
The last digits of the cubes are all different: 0, 1, 8, 7, 4, 5, 6, 3, 2, 9. They're easy to remember: 2 and 8 swap, 3 and 7 swap, and the other digits stay themselves. The last digit of 438,976 is 6, so the number ends in 6. The second thing is the number of thousands, 438. It lies between $7^3 = 343$ and $8^3 = 512$, so the number has seven tens. Answer: 76.
The cube of a sum will expose this trick: the volume of a cube whose side is made of two segments.
For any numbers $a$ and $b$ we have $(a + b)^3 = a^3 + 3a^2b + 3ab^2 + b^3$.
Counting blocks works for lengths; for any numbers the same formula comes from multiplication: by the definition of a cube $(a + b)^3 = (a + b)^2(a + b)$, we already know the square of a sum, and by the product of sums
$$\begin{aligned}(a^2 + 2ab + b^2)(a + b) &= a^3 + a^2b + 2a^2b + 2ab^2 + ab^2 + b^3 \\ &= a^3 + 3a^2b + 3ab^2 + b^3.\end{aligned}$$Replacing $b$ with $-b$ gives the cube of a difference: $(a - b)^3 = a^3 - 3a^2b + 3ab^2 - b^3$; the signs alternate because odd powers of $-b$ are negative.
Let $N = (10a + b)^3$, where $a$ and $b$ are digits and $a \ne 0$. Then the last digit of $N$ is the last digit of $b^3$ and so determines $b$ uniquely, and $a$ is the largest digit whose cube $a^3$ doesn't exceed the number of thousands in $N$.
The idea: expand the cube by the formula and see which terms affect the units place and which the thousands. By the cube of a sum with $10a$ in place of $a$,
$$(10a + b)^3 = 1000a^3 + 300a^2b + 30ab^2 + b^3.$$The first three terms are divisible by 10, so the last digit of $N$ is the last digit of $b^3$. By the table the last digits of the cubes from $0^3$ to $9^3$ are all different, so $b$ is recovered uniquely from it.
Now the thousands. The number $10a + b$ is at least $10a$ and less than $10a + 10$. Cubing non-negative numbers preserves inequalities: if $0 \le u < v$, then in the product $u \cdot u \cdot u$ each factor is smaller than the corresponding factor in $v \cdot v \cdot v$, and $u^3 < v^3$. So $1000a^3 \le N < 1000(a + 1)^3$, and the number of whole thousands in $N$ is at least $a^3$ but less than $(a + 1)^3$. So $a$ is the largest digit whose cube doesn't exceed the number of thousands.
Now remove all six slabs and bars from the cut-up cube, leaving only $a^3$ and $b^3$. That gives one more formula.
For any numbers $a$ and $b$ we have $a^3 + b^3 = (a + b)(a^2 - ab + b^2)$.
For any numbers $a$ and $b$ we have $a^3 - b^3 = (a - b)(a^2 + ab + b^2)$.
The sum-of-cubes formula holds for any number in place of $b$, including $-b$. Substitute: $a^3 + (-b)^3 = \bigl(a + (-b)\bigr)\bigl(a^2 - a(-b) + (-b)^2\bigr)$. By the sign rule of chapter 2, $(-b)^2 = (-b)(-b) = b^2$, $(-b)^3 = (-b)^2 \cdot (-b) = -b^3$ and $-a(-b) = ab$. We get $a^3 - b^3 = (a - b)(a^2 + ab + b^2)$.
Which two-digit number has the cube 250,047?
The last digit of the cube is 7, and only $3^3 = 27$ ends in 7, so the number ends in 3. There are 250 thousands, and $6^3 = 216 \le 250 < 343 = 7^3$, so it has six tens. Answer: 63. Check: $63^2 = 3969$, $3969 \cdot 63 = 250{,}047$.
The trick that failed one day
Here's a trick that's easy to fall for. Substitute the numbers $n = 0, 1, 2, \dots$ into the expression $n^2 + n + 41$. You get 41, 43, 47, 53, 61, 71, 83, 97: all primes. Check another ten: primes again. This expression was described by Leonhard Euler, and it really does give primes forty times in a row, for $n$ from 0 to 39. But at $n = 40$ it gives $1600 + 40 + 41 = 1681 = 41^2$. You didn't even need to calculate: $40^2 + 40 + 41 = 40 \cdot 41 + 41 = 41 \cdot 41$.
Forty successful checks proved nothing, just like the five successful circles of chapter 0. Equations with letters come in two kinds. Some hold for all values of the letters, like $(a + b)^2 = a^2 + 2ab + b^2$. Others don't hold for all values, like $x^2 = x$, which is true only for $x = 0$ and $x = 1$.
An identity is an equation that holds for all values of its letters (at which both sides make sense). Expressions that can be joined by such an equation are called identically equal, and replacing one with the other is an identity transformation. Expanding brackets, collecting like terms, applying a special product: these are all identity transformations.
To prove an identity means to turn one side into the other by a chain of steps, each relying on the laws of arithmetic or on formulas already proved, just as we proved the special products. Disproving is even easier: one counterexample is enough. With $a = b = 1$ the expression $(a + b)^2$ equals 4, while $a^2 + b^2$ equals 2, and the "identity" $(a + b)^2 = a^2 + b^2$ falls apart.
To disprove an equation with letters, one counterexample is enough. To prove an identity, examples will never be enough, however many there are: you need an argument that works for all numbers at once. That is exactly what letters provide.
Now we can solve the puzzle from chapter 6.
If a fraction $\frac mn$ satisfies $m^2 - 2n^2 = \pm 1$, then for the next fraction $\frac{m + 2n}{m + n}$ the expression "numerator squared minus twice the denominator squared" equals the same number with the opposite sign. So from $\frac32$ on it equals $\pm 1$ at every step, without exception.
The idea: compute the expression for the new fraction in letters, expanding the brackets with the square of a sum. For the numerator $m + 2n$ and denominator $m + n$ we get
$$\begin{aligned}(m + 2n)^2 - 2(m + n)^2 &= m^2 + 4mn + 4n^2 - 2(m^2 + 2mn + n^2) \\ &= m^2 + 4mn + 4n^2 - 2m^2 - 4mn - 2n^2 \\ &= -m^2 + 2n^2 = -(m^2 - 2n^2).\end{aligned}$$In the first line the square of a sum is used twice, in the second the bracket with the factor $-2$ is expanded, and in the third like terms are collected: $4mn - 4mn = 0$, $m^2 - 2m^2 = -m^2$, $4n^2 - 2n^2 = 2n^2$. The equation holds for all $m$ and $n$, so at every step of the rule the expression only changes sign. For $\frac32$ it equals $9 - 8 = 1$, so for $\frac75$ it's $-1$, for $\frac{17}{12}$ it's $1$ again, and so on forever.
Six checks didn't prove the law, but one line with letters proved it for every step at once. The course's engine can check identities too; try it yourself.
Among the widget's examples is an identity that looks like a trick itself. Multiply four consecutive numbers and add one: $1 \cdot 2 \cdot 3 \cdot 4 + 1 = 25 = 5^2$, $2 \cdot 3 \cdot 4 \cdot 5 + 1 = 121 = 11^2$, $5 \cdot 6 \cdot 7 \cdot 8 + 1 = 1681 = 41^2$, 1681 again!
For any number $n$ we have $n(n + 1)(n + 2)(n + 3) + 1 = (n^2 + 3n + 1)^2$. In particular, the product of four consecutive integers plus one is always a perfect square.
The idea: pair the outer factors and the inner ones, and they give almost the same expression. By the commutative and associative laws the factors can be rearranged: $n(n + 1)(n + 2)(n + 3) = \bigl(n(n + 3)\bigr)\bigl((n + 1)(n + 2)\bigr)$. Expand: $n(n + 3) = n^2 + 3n$, and by the product of sums $(n + 1)(n + 2) = n^2 + 3n + 2$. Write $m = n^2 + 3n$. Then
$$\begin{aligned}n(n + 1)(n + 2)(n + 3) + 1 &= m(m + 2) + 1 \\ &= m^2 + 2m + 1 = (m + 1)^2 = (n^2 + 3n + 1)^2.\end{aligned}$$In the second line we expanded $m(m + 2)$ and recognised the square of the sum of $m$ and $1$. For an integer $n$ the number $n^2 + 3n + 1$ is an integer, so the result is the square of an integer.
A well-chosen letter $m$ is half the proof: with it, an expression of degree four turned into a familiar square of a sum.
Which of these equations is an identity?
$b - a = -(a - b)$, and opposite numbers have equal squares: $(-t)^2 = t^2$. So the equation holds for any $a$ and $b$.
The trick in reverse: factoring
Write any three-digit number twice in a row, say 372,372. Divide by 7: it divides exactly, 53,196. Divide the result by 11: exact again, 4836. Now by 13, and there's the original number, 372.
Writing a three-digit number $x$ next to itself means shifting it three places left and adding it again: you get $1000x + x$. By the distributive law that's $1001x$, and $1001 = 7 \cdot 11 \cdot 13$. Dividing by 7, 11 and 13, we divided by 1001 and got $x$ back. The whole trick rests on one move: we turned the sum $1000x + x$ into the product $1001 \cdot x$. That's a move in the other direction: not expanding brackets but assembling them.
To factor an expression is to write it as a product: $1000x + x = 1001x$, $x^2 - 9 = (x - 3)(x + 3)$.
School algebra has three main ways of factoring, and all of them are formulas from this chapter read from right to left.
- Take out a common factor: the distributive law in reverse, $6x^2 - 9x = 3x(2x - 3)$.
- Apply a special product: $x^2 - 49 = (x - 7)(x + 7)$, $x^2 - 10x + 25 = (x - 5)^2$, $x^3 + 8 = (x + 2)(x^2 - 2x + 4)$.
- Group the terms so that the groups share a common factor: $x^3 + 2x^2 + 3x + 6 = x^2(x + 2) + 3(x + 2)$, which is already $(x + 2)(x^2 + 3)$.
Factoring explains two more tricks. Take a two-digit number, reverse its digits and subtract the smaller from the larger: $72 - 27 = 45$, $91 - 19 = 72$, $53 - 35 = 18$. And the second: subtract an integer from its cube: $5^3 - 5 = 120$, $7^3 - 7 = 336$.
1. The difference between a two-digit number and the number written with the same digits in reverse order is divisible by 9, and the quotient is the difference of the digits.
2. For any integer $n$ the number $n^3 - n$ is divisible by 6.
First. The number with digits $a$ and $b$ equals $10a + b$, and the reversed one $10b + a$. Expand and collect like terms: $(10a + b) - (10b + a) = 9a - 9b$, and taking out the common factor gives $9(a - b)$. This is nine times the integer $a - b$, so it's divisible by 9, and the quotient is $a - b$.
Second. Take out the common factor $n$ and factor the remaining difference of squares by the formula: $n^3 - n = n(n^2 - 1) = (n - 1)\,n\,(n + 1)$. This is a product of three consecutive integers. Of two consecutive numbers one is even, and of three consecutive numbers one is divisible by 3: the remainders of three consecutive numbers on division by 3 are 0, 1 and 2 in some order, so one of them is zero. So the product is divisible by both 2 and 3. Divisibility by 6 follows: write the product as $2k$; the number 3 divides $2k$ and is coprime to 2, so by the generalized Euclid's lemma 3 divides $k$, that is, $k = 3m$ with integer $m$, and $n^3 - n = 2k = 6m$.
An expression of the form $x^2 + bx + c$ can be factored literally by hand. Take tiles: an $x \times x$ square, $b$ strips $x \times 1$ and $c$ unit squares. If they form a rectangle, its sides are the factors: the area of the rectangle is the product of its sides, and it's also the sum of the areas of the tiles.
The tiles suggest the rule. If $p$ strips lie on the right and $q$ at the bottom, then $p + q = b$, and the $p \times q$ corner holds $pq$ small squares. The rectangle with sides $x + p$ and $x + q$ has area $(x + p)(x + q) = x^2 + (p + q)x + pq$: the product of sums. So $x^2 + bx + c = (x + p)(x + q)$ if there are numbers $p$ and $q$ with sum $b$ and product $c$: $x^2 + 5x + 6 = (x + 2)(x + 3)$, because $2 + 3 = 5$ and $2 \cdot 3 = 6$. With $x^2 + 4x + 5$ nothing works: of the pairs of integers with sum 4, the largest product is $2 \cdot 2 = 4$, and 5 is needed. It will turn out later that this expression can't be factored at all, not even with fractions or irrational numbers, and in chapter 10 we'll learn to recognise such cases in advance.
The number 899 is one less than $900 = 30^2$. Factor it into two factors and give the larger one.
$899 = 30^2 - 1^2 = (30 - 1)(30 + 1) = 29 \cdot 31$. The larger factor is 31. Both factors are prime, and finding them by trial division would take much longer.
Where next
The tricks in this chapter went one way: a number thought of, some steps, a result. The letters explained why the result is what it is. But the magician in "I'll guess your number" was already doing the reverse, recovering the original number from the result. It was easy for him: he just dropped a zero. What if a spectator says, "I thought of a number, multiplied it by 3, added 7 and got 25"? The expression $3x + 7$ hides an unknown number, and the value of the expression is known. How do you find $x$, and is there a method that always works, not just when a guess happens to be lucky? That is chapter 8.