Chapter 5 - Apples and bananas

When is 5+5 not equal 10?

So 5+5 = 10 ... dah!
But it is also true that 5+5 = 2*5 ... OK, right?! In math there are usually many ways to write the same thing, so that it looks different but it means the same (syntax & semantics, like in chapter 1).
Sure sure, but when is 5+5 not the same as 10? How could I have five things and five things again, and when I put them all together they are NOT 10 things...? Too philosophical? Oops.
Let me find a concrete example. I can say "I have 5 fruits and other 5 fruits, so I have 10 fruits". Fine. But what if I have 5 apples and 5 bananas? What have I got? Ten... what? Ten fruits, OK, but that is neither apples nor bananas. I can I write this mathematically, to keep apples and bananas SEPARATED? I can try like: 5 * apple + 5 * banana and it could mean for example "5 times the weight of an apple and 5 times the weight of a banana". It is a linear combination (a mix of additions and multiplications, see chapter chapter 2) that uses the two variables apple and banana as a way to keep two other numbers separated, 5 and 5 in this example. You can also see the expression above as a weighted sum, where 5 and 5 are the weights of apple and banana, so the two fives control HOW MANY apples and bananas are in the mix.
The idea is similar to the notation for writing numbers based on the abacus (chapter 1). Only that here I'm not interested in actually finding a single number summing up two quantities, and because of that I don't really care what are the values of the two variables apple and banana. I could write something like: 5 * 1000 + 5 * 1 = 5005 where I picked 1000 as the value for apple and 1 for banana, but how good is to have found that the value of my expression is 5005? You might say that it represents 5 apples and 5 banana in a nice, REVERSIBLE way, and it does. However, sometimes it is more interesting NOT to calculate something, keep it a bit longer, and see where that gets me. In chapter 4 for example we wanted to avoid calculating too many divisions and we ended up inventing fractions. And here I want to think more in this way: say that you have 2 kinds of fruits, apples and bananas. I want to put all the apples in a box, and all the bananas in another, or make an abacus with two spikes, one for apples and the other for bananas. The difference with a USUAL abacus is that here I DON'T WANT to add them all up! Consider this: you go to buy one apple, but the shop only has bananas. How many bananas should they offer you to replace that single apple you cannot buy? If you really just need an apple, no amount of bananas would do. The word I'm looking for to describe this situation is incommensurable: there is no conversion rate between these two things. And that can happen, if you want to make an apple pie, good luck compensating for missing apples with any amount of bananas!
Finally, this idea works also to keep separated more than two numbers, like in a recipe: 1 * egg + 3 * milk + 4 * flour and again this makes sense because you cannot replace milk with eggs.

Moral of the story so far: not only 5+5 can be "not 10" sometimes, but I can write it as: 5 * a + 5 * b for some variables a and b (because writing apples and bananas EVERY TIME gets boring fast), and I don't have a particular value in mind for neither variables. And this is why math uses letters as well as numbers.

Calculate it all, some, or not at all

Here we have a new situation: we have two kinds of numbers in some calculation, and we need to keep them separated. Fine, but we probably also need to do something with the two numbers. For example: "I have 5 apples and 5 bananas, and I buy 3 more apples". One way to SEE this situation could be by using boxes (as we did in the previous chapter for fractions), and write 55 to represent that I have 5 apples (in the box on the left) and 5 bananas (box on the right). Written like that it is also more clear why they cannot be SIMPLY 10: because there are two boxes and... where should I even write the 10?
OK, now I want to buy 3 more apples, and I want to add them to my fruits. What I get should look like this: 5+35, which is clearly 85, or "8 apples and 5 bananas". Nice, right?!
But the notation 55 can be confused with two numbers on an abacus, like the whole number 55, and we don't want that. Also, what we are really doing here with a and b is give NAMES to the two boxes. So perhaps we should also label the two boxes in this way: a5b5.
Using labeled boxes, I can write the addition above as: a5b5 + a3b0 = a5+3b5 = a8b5 and I think it looks much more clear.
Now, the same thing can be written as the math expression: ( 5 * a + 5 * b ) + 3 * a and here I can REGROUP things, and put all apples in the same basket... 5 * a + 5 * b + 3 * a → (5 * a + 3 * a) + 5 * b I would expect that (5 * a + 3 * a) is simply (5+3)*a → 8*a because, after all, it means "I have 5 apples and also 3 apples".
But can I be sure that the math here says the same? Well... from the properties of multiplication (chapter 2) I know: (x*y + z*y) = (x+z)*y for any numbers x, y and z. And here I can use this property on MY numbers: (5 * a + 3 * a) + 5 * b → (5+3) * a + 5 * b

= 8 * a + 5 * b
So I was right: I just have to add together all apples and all bananas! But can I do more than this? Not in this case: this is the best I can do with this expression. So sometimes I can calculate all, until I get a number as a result, but in other cases the best I can do is put some stuff together, and clean up a bit the expression. And in some cases there is just nothing to do, for example with 8*a+5*b.
Wait... does this smell like a normal form or what? Here we have expressions with variables a and b, and we can write the same expression in multiple ways, for instance 5*a+5*b+3*a or 8*a+5*b. And we find ourselves asking: what is the simplest way to write an expression with a and b? So simple that I cannot simplify it further?
Yes, that sounds just like the normal forms discussed in chapter 1 (and all chapters since, really); the normal form here would be that I put together as much as possible the amounts of as and bs, and possibly get my expression to a form like: smtg * a + smtgElse * b where smtg is a number (whole or broken, positive or negative, or a fraction if you like) and smtgElse is a possibly different number. To bring the expression in this form, I might have to do some calculations, perhaps remove brackets, and put together all the multiples of a and all the multiples of b. When we discussed normal forms in chapter 1 we also talked about transformations, operations that change the look but not the meaning of the things we are working with. Here we are working with expressions containing as and bs, and we already know that a possible transformation is to put together all as. From all this we can define a rule: smtg * a + smtgElse * a → (smtg + smtgElse) * a which should not be surprising, because it is the same as the distributive property of multiplication, only with numbers AND variables this time.
Using labeled boxes, the general rule for adding linear combinations of apples and bananas becomes: asomeAbsomeB + amoreAbmoreB = asomeA+moreAbsomeB+moreB where someA, someB, and moreA, moreB are any four numbers.

Good, so we have discovered how to ADD apples and bananas to other apples and bananas: you just add apples to apples and bananas to bananas. Let's use this new addition rule on the expression (2*a+3*b) + (4*a+5*b). To calculate the result I should just drop the brackets, then regroup apples with apples and bananas with bananas: 2*a + 3*b + 4*a + 5*b →
2*a+4*a + 3*b+5*b →
(2+4)*a + (3+5)*b →
6*a + 8*b
or if you prefer our labeled boxes: a2b3 + a4b5 = a2+4b3+5 = a6b8 and that is the same result. Done.
As a final note: when the expression as only one apple (or banana) I can write a instead of 1*a, so for example: 1*a+3*b can be written simply as a+3*b.

Play with the playground below. Generate a random expression with as and bs, and see if you can figure out the result before clicking on the solve button.
Look at the fruits below: do they help visualizing the addition rule?
Try a few times, to get the feel of these additions...

Interestingly, having introduced a new notation (the labeled boxes for apples and bananas), we end up with multiple ways to write the same meaning. For example, I can write "I have 2 apples and 3 bananas" in more than one way with labeled boxes:
a2b3 = a2b0 + a0b3 = a1b0 + a1b3 = ... = a2 + b3

and all these different notations mean the same thing, 2*a+3*b, and that is because of our addition rule. So the addition rule for linear combinations of as and bs can be the base to define a meaning-preserving transformations on our labeled boxes.

Quadruple my fruits

At the end of chapter 1 we established that math is a language to talk about counting. Good. Here I want to talk counting pairs of boxes (one of apples and the other of bananas). For example I might want to say that "I have 2 apples and 3 bananas (in my two boxes)" and you might add that you want to buy "four times the amount of apples and bananas in the boxes". How do I translate that into a math expression? And how many apples and bananas is that?
Well I can translate that sentence into math one part at the time. First "I have 2 apples and 3 bananas" can be translated as 2*a + 3*b. And then you want four times that amount, so: ( 2*a + 3*b ) * 4 and after I have done the multiplication by four, I would like a result that looks something like: smtg * a + smtgElse * b or asmtgbsmtgElse.
In this situation you want to buy four boxes, and so you will find yourself buying two apples times four, and three bananas times four: that gives you eight apples and twelve bananas, still separated in their two boxes. Therefore, you should expect the solution of our calculation to be: 8*a + 12*b Right. But how can I be sure that intuition is correct? I have to proceed in a logical way, step by step. I could argue that because aNumber * 4 = aNumber + aNumber + aNumber + aNumber, then surely: ( 2*a + 3*b ) * 4 → (2*a+3*b) + (2*a+3*b) + (2*a+3*b) + (2*a+3*b) and at this point I know how to add everything: I just have to put apples with apples and bananas with bananas: (2+2+2+2)*a + (3+3+3+3)*b → 8*a + 12*b ... nice!
Another way to see this is to calculate ( 2*a + 3*b ) * 4 using the distributive property of multiplication, trusting that it works even with variables... That would give: ( 2*a + 3*b ) * 4 → (2*a*4) + (3*b*4) →
(2*4)*a + (3*4)*b →
8*a + 12*b
Wow, I get it: no matter what I do, I get the same result, so it must be correct, fine.
When I studied math, I was told many times that "math is precise"... I don't know about precise but surely it is consistent, even stubborn: (provided I do my calculations correctly) I find myself getting the same results, no matter what weird road I take to calculate. Another way to look at it could be: math has been created to represent numbers and similar things, and those are just what they are. And math does such a good job at it that I can never find a way to trick it into coming up with inconsistent results. And historically, when it really does happen that some things come out different than expected thanks to some tricks, it usually brings on a new and more powerful kind of math.
(For example Newton found math tricks to solve the paradox of Achilles and the tortoise, many contemporary mathematicians where not happy with his tricks; but those tricks led to the development of calculus)

Baskets of apples

I just convinced you (hopefully) that ( 2*a + 3*b ) * 4 = 2*4 * a + 3*4 * b. But what if you wanted to buy an unspecified number of pairs of boxes, say k pairs of boxes? You could expect this: ( 2*a + 3*b ) * k → 2*k * a + 3*k * b and in fact it makes sense.
But how can an expression like 2*k*a + 3*k*b be a result? Isn't a result supposed to be an answer to some question? Something that has been completely calculated? Simplified to the smallest, simplest form possible?
Well, in this case... that's it. I have made it as simple as I could, so later, when you will tell me what is the value of k, I will be able to quickly calculate the value of that expression. Again, the idea here is to calculate as much as I can, but stop if I cannot go any further, and more or less wait for the variables to be known.
An interesting thing happened in this expression: now I have k*a as a "new" variable. But is it really "new"? Can I mix (add for example) 10*a and k*a? Or do I have to keep them separated? Let's see: 10*a + k*a = (10+k) * a and this expression tells me that "I have 10 apples and I add a basket of k apples". How many apples is that? Your best reply could be "that makes ten-and-a-basket of apples"... so it is very possible that k cannot go away from my expression.
At this point it is worth looking again at our initial question: what is the result of (2*a+3*b)*k? This time I want to use the labeled boxes notation: a2b3 * ka2b3 * k1

(a2 * k1) + (b3 * k1) →

a*k2*1 + (b3 * k1) →

a*k2*1 + b*k3*1a*k2b*k3
OK, same result. But how to read this? It should mean something like "I have two boxes, one with two apples, the other with three bananas", and you want to buy a basket for each fruit in each box (and by a basket you mean a precise measure, like exactly k fruits). How many apples and bananas do I have to give you? The answer is "two k-apples and three k-bananas", or if you prefer "two baskets of apples and three baskets of bananas". And that is what a*k is, it is "one basket-load of apples".

So a and k*a are both variables that somehow are measured in apples, or count apples if you like; when I mix them in an expression, k will not go away in the result, which suggests that they are not the same KIND of numbers and I have to keep them SEPARATED as I try to calculate my expression. On the other hand I can add apples to apples (for example 2*a+3*a = 5*a) and also k-apples to other k-apples (AKA add baskets of apples to same-size baskets of apples). For example this new expression: 2*k*a + 3*k*a it becomes: 2 * k*a + 3 * k*a →
(2+3) * k*a →
5*k*a
and you could read this expression like: "I add two baskets of apples AND three baskets of apples. How many baskets of apples is that?", and the answer can only be "five baskets of apples", provided that all the baskets had the same amount of apples (k in this case).

I have been considering only addition and multiplication so far, but of course the same rules also work for subtraction and division. Look at these examples: 5*a + 5*b - 3*a → (5-3) * a + 5 * b → 2*a + 5*b

( 2*a + 3*b ) : 4 → (2:4) * a + (3:4) * b → 12*a + 34*b
So all operations can be extend to work for both numbers and variables.

Add a few cherries...

So far we have worked with two variables, apples and bananas. What happens if I add few cherries? Say that I have two apples and three bananas, and I add four cherries. What does that situation looks math terms? And what is the result? I could write this problem like this: 2*a + 3*b + 4*cherry = ?
Using our labeled boxes I need two, one for the apples and one for bananas, but here I also need to create a new box, specific for cherries. So here is how that looks with the labeled boxes: a2b3 + cherry4

a2b3cherry0 + a0b0cherry4

a2b3cherry4
Can we do better than that? Not really. But it is important to see that we can extend our world from two boxes (or types of fruit) to as many as we need. And if you look at the rules we have defined so far, they are still valid. Even better: they automatically SCALE to this new situation with three boxes!

For example, what do you think the results of these are?
2*a + 3*b + 4*c + 2*c + 10*b = ?
( 2*a + 3*b + 4*c ) * 5 = ??

The fact that a2b3 is also the same as a2b3c0 when the new variable c (not already present in the expression) is considered, suggest that there are EVEN MORE WAYS to write one of these labeled boxes values. For instance:
a2b3 = a2 + b3 = a2b3c0 = a2b3d0 = a2b3c0d0 = ... etc.

provided that c and d are NEW variables, AKA new boxes. So to specify the normal form for my labeled boxes, I will have to say explicitly that I should remove all the boxes with zero items in them. A situation where I might need to remember this rule, could be a calculation like: 2*a + 3*b -2*a   →   0*a + 3*b Clearly it would LOOK better to write it as 3*b instead, dropping the box with zero apples.

Fruit salads

Since I know that in some situations it makes sense to work with a variable like k*a, what about a*a or a*b?
Would that make sense? And when would I need to multiply a with a?
To see what a*a and a*b actually mean, I will have to go back and re-consider what multiplication actually is. Then I will be able to extend multiplication beyond numbers, to include variables and expression (AKA linear combination of variables and numbers).
Since this stuff is complicated, let's start as simple as possible. When we defined multiplication (in chapter 2) we used tally numbers (or Peano numbers) and we were interested in find out how many Is was II * III. Spoiler: it is six. Fine, but... why? Or better: HOW DO I KNOW it is six (or IIIIII to be precise)?
Well, because as we said in chapter 2, multiplication is just repeated addition, so here we have: II * III  →  III + III  →  IIIIII But how do we know that we need TWO copies of III? Oh, surely it is because II has two Is. So really what we are doing is COMBINE, mix the second number with the pieces of the first... Something like:

            (the first)  I -> III
            (the second) I -> III
or if it helps to SEE it better, I could write it like:
                   /-> I (the first digit of the second number)
  (the first)  I -+--> I (the second digit of the second number)
                   \-> I (...)
      +
                   /-> I 
  (the second) I -+--> I 
                   \-> I 
In both cases the total is six, so the multiplication still works as we expect. And remember that with tally numbers we are just counting and all the Is are the SAME, they each mean "one sheep" or something like that.
Let me try to see even better which digit is COMBINED with which, in the interpretation of the multiplication. To to that I can give a personality (a different look for example) to each I in both numbers, like this: II * III

I   with   I  and
I   with   I  and
I   with   I  and

I   with   I  and
I   with   I  and
I   with   I
and surely it makes six, but six WHAT? Six couples of Is. So... wait! What the multiplication ACTUALLY does is to create all possible couples of Is in the two numbers being multiplied, and then count how many couples there are?! Only that usually all the Is are exactly the same, so I never noticed, and simplify the story saying "II times III is IIIIII".
Personally I find this revelation a bit mind blowing. But... can I use it here, with apples and bananas? Let's see.
Say that I want to multiply two apples by three bananas... and since I don't want to BREAK math, I still want six to come out as part of the result. But I also want more information about my apples and bananas. *  →

( with , with , with ,
with , with , with  →

6 * ( with )
OK... perhaps... but what does it mean?
Let me try to read the steps of the calculation:
"take two apples and combine them (AKA multiply) with three bananas" →
"first apple combines with first banana",
"first apple combines with second banana",
"first apple combines with third banana",
"second apple combines with first banana",
"second apple combines with second banana",
"second apple combines with third banana"
And since I don't want to distinguish the first apple from the second, nor any of the bananas from any other banana, there are really just six couples (or pairs), each one a combination of an apple and a banana. So the result is "six couples, each couple has one apple and one banana".

Note: here I don't care if a couple is (apple,banana) or (banana,apple), and that means that "two apples multiplied by three bananas" gives the same result as "three bananas multiplied by two apples". Even "three apples by two bananas" gives the same result: "six (apple,banana) couples". So multiplication still works as expected, but gives me more details this time!

Now, I want to see how this looks in our labeled boxes notation: a2 * b3a*b2*3 where a*b stands for "a couple with an apple and a banana", or "apple-banana couple" for short (like above). So I can say that "2 apples multiplied by 2 bananas gives 6 apple-banana couples".
A final question: is an apple-banana couple the same KIND of thing as an apple or a banana? Or if you like: could I add an apple-banana to an apple or to a banana? And what would be the result?
These questions can be represented like this: VS   VS   ( with ) which is also this, with labeled boxes:
a1   VS   b2   VS   a*b3 and in both cases it looks like an apple-banana couple CANNOT BE an apple or a banana. Earlier we discovered that k*a is not the same kind of variable as a. For the same reason here a*b is not the same kind of thing as a, nor as b. After all a*b is a fruit salad, and a fruit salad is NOT an apple or a banana!
The great thing about this fruit salad approach to multiplication is that it mixes the fruits AND keeps them separated at the same time. In fact, the answer to what is "two apples times three bananas" is no longer simply "six" but it is "six apple-banana couples", which keeps the information about where the six came from... Clever or what?!
Another SPECTACULAR property of the fruit salad approach is that it works EXACLTY like the normal interpretation of multiplication, if we DROP the variables a and b. Take our example: (2*a)*(3*b) = 6*a*b. I can decide to get rid of a by replacing it with 1, and the same for b, and the equivalence should still be true: (2*1)*(3*1) → 6*1*1 or if you prefer: 2*3 → 6 ... yep, still true. So from now on we can simply consider the fruit salad interpretation of multiplication as our multiplication, with the added bonus that it will work both with expressions made of numbers, and with expressions containing numbers AND variables.

Apples time apples

We still haven't looked at a*a. What would that be? Well, according to our fruit salad view of multiplication it should just be: (1*a) * (1*a)  →  1*a*1*a  →  1*a2 where a*a (AKA a2) is an apple-apple couple of fruits. And a*a is different from a, b*b and even a*b, because in a fruit salad, the kinds of fruits that your add to the mix do count!

We got very far with this "fruit salad" interpretation of the multiplication. In light of what we know at this point, calculate: (4*a) * (5*a).

One last thing. What happens if we try a slightly more COMPLEX expression? For example: (2*a + 4*b) * (3*b) Well, this is just another case of the distributive property of the multiplication. Luckily we did not really alter the way multiplication works, even with our new "fruit salad" interepratation, so all the properties of the multiplication that we knew are still true, including this one!
I can distribute the multiplication across the addition, and get: (2*a + 4*b) * (3*b)  →  (2*a)*(3*b) + (4*b)*(3*b) and now each part can be calculated with our "fruit salad" rule for multiplication: (2*a)*(3*b) + (4*b)*(3*b)  →
2*3*a*b + 4*3*b*b  →
6 * a*b + 12 * b2
Done. Wow, so with all the stuff we did in this chapter, we can even solve these weird-looking type of expressions, that have variables everywhere.
The same calculation looks like this, when written with the labeled boxes: (a2b4) * b3  →

(a2 * b3) + (b4 * b3)  →

a*b2*3 + b*b4*3  →

a*b6 + b*b12
and both notations agree on the result: six apple-banana couples and twelve banana-banana couples.

Everything comes together

Finally, I can try to multiply two expressions both containing a and b, for example: (3*a+2*b) * (5*a+6*b) How to proceed here? I can start with the distributive property of the multiplication, and PRETEND that (5*a+6*b) is just some number, do the distribution of the multiplication, and then STOP PRETENDING, and put the bracket back in the expression! What is get in this way is: (3*a+2*b) * someNumber
(3*a) * someNumber + (2*b) * someNumber
(3*a) * (5*a+6*b) + (2*b) * (5*a+6*b)
This time however the two parts of my addition are not that simple (as in the previous examples)... but they are NOT totally new either. Both (3*a) * (5*a+6*b) and (2*b) * (5*a+6*b) are familiar multiplications by now, so I actually should know how to treat them. Let's see: (3*a) * (5*a+6*b) + (2*b) * (5*a+6*b)
(3*a)*(5*a)+(3*a)*(6*b) + (2*b) * (5*a+6*b)
(3*5*a*a)+(3*6*a*b) + (2*b) * (5*a+6*b)
3*5*a*a + 3*6*a*b + (2*b)*(5*a)+(2*b)*(6*b) →
3*5*a*a + 3*6*a*b + (2*5*b*a)+(2*6*b*b) →
3*5*a*a + 3*6*a*b + 2*5*b*a + 2*6*b*b →
15 * a*a + 18 * a*b + 10 * b*a + 12 * b*b
And now I can put together all the (a*a)s, the (b*b)s, and the (a*b)s, which by the way are the same as the (b*a)s. In this way I get: 15 * a*a + 18 * a*b + 10 * b*a + 12 * b*b →
15 * a*a + (18 + 10) * a*b + 12 * b*b →
15 * a*a + 28 * a*b + 12 * b*b
= (3*a+2*b) * (5*a+6*b)
and that is all I can do, because terms with a*a cannot be mixed with those with b*b, nor those with a*b. So... done!
Wow, that was along thing to figure out. But the important point is: it is entirely possible to multiply expressions together, and the result is another expression, with some new mix of variables.
The same calculation written using the labeled boxes, looks like this: (a3b2) * (a5b6) →

(a3b2) * a5 + (a3b2) * b6

a*a3*5b*a2*5 + (a3b2) * b6  →  a*a15b*a10 + a*b3*6b*b2*6

a*a15b*a10 + a*b18b*b12  →  a*a15a*b10+18b*b12  →  a*a15a*b28b*b12
And again, same result. Math really IS stubborn.

Moral of the story so far: linear combinations of variables can be treated as numerical expressions; we can add them, multiply by a number or even multiply an entire linear combination by another. Some of these operations give a result that has the same variables as the expressions that were involved in the calculation, but with different weights. In other cases we get new variables (AKA multiplications of variables).
To understand what happens with variables and multiplication we can take a slightly weir interpretation of multiplication that takes into account not only the numbers but also the kind of things we multiply together. We called this approach "fruit salad", and it has the interesting side effect: it helps see why different kinds of fruit salad cannot mix. For example a bowl with an apple and a banana is a kind of fruit salad, different from one with an orange and a pineapple. And even more interesting, a bowl with a banana is not the same kind as a bowl with an apple AND a banana. This new interpretation of multiplication allows to keep the variables separated and at the same time combine them.
Finally, a principle seems to emerge from our fooling around with expressions: you can PRETEND that variables are numbers and calculate all that you can, using the usual rules for operations on numbers. Of course sometimes you will have to stop the calculation because it will be impossible to reach a single-number result. So we have to accept that a result can be an expression sometimes, and not always a number. In chapter 4 we worked with lazy, un-calculated divisions and called them fractions; here you might say that a variable is a lazy number, a number that will remain un-calculated, separated from others, only to be revealed later (perhaps, or not if we just wanted to keep things separated).

In the playground below, try the following shop situations:
  2 apples, 3 bananas and 5 florins on the floor,
  3 bananas, 4 cherries,
  2 apples, 3 bananas and 5 florins on the floor,
  10 florins on the floor,
for each, test what happens in all four "And then" cases.
Note: a florin is an ancient coin from Florence.

Now, try with: 3 apples and 2 bananas. What happens in the last of the "And then" cases?

Thanks to algebra.js by nicolewhite

Simpler and stranger cases

Now that we have a way to calculate a multiplication between two math expressions, both containing a and b, I would like to consider the special case: (a+b)*(a+b) where a+b is math shorthand for 1*a+1*b. This case is interesting because it the square of an expression, in the same way that 5*5, or 52, is 25. I'm curious to see what happens when the thing being SQUARED is an entire expression with variables, instead of just a simple number.
We can calculate this simply by using the rule we figured out in the previous section: (a+b)*(a+b) →
(a+b)*a + (a+b)*b
a*a + b*a + a*b + b*b
a2 + 2*a*b + b2
Wait a second... This looks familiar. It is in fact the well known rule to calculate (a+b)2 that you might remember from your school math. Here we discovered it again using our rules for math expressions with variables... not bad.
Let me just write the rule using the labeled boxes, in case it becomes more easy to understand: (a1b1) 2  →  a1b1 * a1b1  →

(a1b1 * a1) + (a1b1 * b1)  →  (a*a1*1b*a1*1) + (a*b1*1b*b1*1)  →

a*a1a*b1+1b*b1  →  a*a1a*b2b*b1
Note: this expression will come up again in a completely different situation in chapter 7.

A more general case is the following expression where we want to multiply two additions; it is more general than the square we just calculated, because this expression contains four different variables: (a+b)*(c+d) = ? So what we want to find out here is what is the result of: a1b1 * c1d1 or if you prefer to go all the way back to our initial idea of boxes of fruits, you could read the expression as "I have one apple in the apple-box and one banana in the banana-box, I want to combine them (multiply) with other two boxes, one with a cherry and the other with a date".
We could use the rule defined in the previous section, or... you might remember this rule from your school math. Whichever the case, we need to multiply each term in the first bracket with both terms in the second, and add the results; or something like this: (a+b)*(c+d) →
(a+b)*c + (a+b)*d
a*c + b*c + a*d + b*d
So I started with an apple, a banana, a cherry, and a date, and by composing them two-by-two in all possible ways (using our "fruit salad" multiplication) I got four couples of fruits: one apple-cherry couple, one banana-cherry, one apple-date, and one banana-date couple. They are all different KINDS of fruits salads, so I cannot put them together, so I have to stop my calculation here.
An interesting fact is that all of these calculations are valid in general; that means that for ANY four numbers that you might pick, it will be true that: (a+b)*(c+d) = a*c + b*c + a*d + b*d Let's try, just to get an idea how solid this equivalence is. If we pick a=1, b=2, c=3 and d=4 we should have: (1+2)*(3+4) → 1*3 + 2*3 + 1*4 + 2*4 → 3+6+4+8 → 21 without even THINKING about the fact that for instance (1+2) can be simplified to 3, I get this result automatically. But if did the calculation step-by-step, manually, I would get: (1+2)*(3+4) → 3 * 7 → 21 ... the same result. Right... because math is stubborn! And here you clearly see that we are being lazy: we try to do the multiplication between the two brackets without even bothering to simplify the contents of the brackets first! And if you remember the calculation diagrams from chapter 4 you see just what I mean by lazy here. On the left you see the step-by-step calculation, and on the right you see the approach "without thinking", AKA doing the fruit salad multiplication with all possible couples:

(1+2) * (3+4)
⇓ + ⇓ +
3 + 7
⇓ *
21
(1+2) * (3+4)
⇓ *
1*3 + 2*3 + 1*4 + 2*4 = 3+6+4+8
⇓ +
21

To conclude, we have still to consider situations in which ordinary numbers are present in the expression, as in this example: (a+b)*(c+5) where I substitute d with 5. Since I just found that (a+b)*(c+d) = a*c + b*c + a*d + b*d , and here d=1, the calculation should be direct: (a+b)*(c+5) = a*c + b*c + a*5 + b*5 And that's as far as I can go. I could group things in a few different ways, but those would only be syntactic changes... For example I could group all the as and bs together, using the distributive property of multiplication backwards: a*c + b*c + a*5 + b*5  →  (c+5) * a + (c+5) * b but on the other hand I could group terms by c and those that have 5, and get this: a*c + b*c + a*5 + b*5  →  (a+b) * c + (a+b) * 5 In both cases I better stop, because if I were to continue I would get back to: (a+b)*(c+5).
To close this example, I want to notice that result looks a bit odd, it is not in the usual normal form for these kinds of expressions. For example, we should write a*5 as 5*a because five is a constant number, it cannot change, while a is the variable, and in math it is convention to keep the format as: number*variable + otherNumber*otherVariable + etc.. Sometimes the "*" sign is dropped, and you could find the expression written like: number variable + otherNumber otherVariable + etc.. Or in our case: 5a + 5b + ac + bc. Also, terms with two variables should be placed after those with only one variable, and then those with three and so no. And in each term the variables should be ordered alphabetically: so it is better to write b*c than c*b, and a should come before b and also before a*c. That leads to a more correct way to write our result a*c + b*c + a*5 + b*5: 5*a + 5*b + a*c + b*c

A final note on terminology: linear combination of variables and numbers (AKA expressions with variables) are usually called polynomals in math (see wikipedia for an intro and more terminology). Polynomials as linear combinations of variables and numbers

Puzzles

(1) Fruit salad multiplication.

Using the rules we defined in this chapter, calculate the following expressions.

(2) Multiply, and again, and again...

We know what is (a+b)*(a+b), it is a*a + 2*a*b + b*b, but what are these:

Hint: don't do these exercises each by itself. Be smart, and LOOK at them first! Each one is the result of the previous, multiplied by (a+b)... that should make it easier to calculate them...
Hint two: if you look at the last one, for example it is really (a+b)*(a+b) MULTIPLIED by the first in the list, AKA (a+b)*(a+b)*(a+b), so again, you can save some calculation steps, by REUSING some results...
When you are done with your calculations, stand back, and look at your results. Could you find a rule, a pattern that these powers follow? Try looking at all of them, from (a+b)0 to (a+b)5... What could the rule be?


TOP