Basic Algebra

First we have these things called "expressions". I guess this is because we "express" some idea with them. The first type of expression that is interesting is "equality":

4 = 4

Here we are simply saying (obviously) that 4 is equal to 4. It might not seem very interesting, but it's important for a couple of reasons. First is that it's possible to construct an invalid expression, or an expression that is false:

4 = 5

The number 4 is not equal to 5, therefore this expression is false. The second important thing is that one side can be different from the other, and the expression can be true:

4 = 2 * 2

If we perform the calculation 2 * 2 it's value is always 4, so this expression is true. Now let's introduce something interesting:

4 = y

Here we have introduced a "variable" called y. It is like a box that can contain anything. If we open the box and put a 4 into it then the expression is true. If we put a 5 into it the expression is false. Let's take it a bit further and make it more complicated:

4 = y * 2

What value can we put into the y box that will make this expression true? Why 2 of course obviously! You can see it and it seems simple, but that is because you are so intelligent. How could we make a machine that would be able to tell us what the value of y should be? We feed the machine 4 = y * 2 and it tells us what the correct value of y:

input:  4 = y * 2
output: y = <answer>

I am now going to describe how this machine works:

  • Figure out which side of the = the y is on, the left of the right.
  • Figure out which part of that side has the y, and what the "rest" is.
  • Take that "rest" and reverse it: if it's a * multiplication, reverse that into a / divide.
  • Apply that reversal to both sides of the =.

What? That is 4 complicated steps just to figure out something you can see just by looking at it!! What is this insanity?? Let's "run" this machine and see what it does:

Figure out which side of the `=` the `y` is on, the left of the right.

The y is on the right hand side.

Figure out which part of that side has the `y`, and what the "rest".

The "rest" is * 2.

Take that "rest" and reverse it

Ok, reversed that is / 2 (divide something by 2).

Apply that reversal to *both* sides of the `=`.

Ok, I will divide 4 by 2, and divide y * 2 by 2. Now our expression looks like this:

4 / 2 = (y * 2) / 2

Now we have something very interesting on the right hand side: (y * 2) / 2. Because we are reversing this part, we can "simplify" this to just y:

4 / 2 = y

Now we are looking at the thing that we did in our head so easily before. The y is equal to 4 / 2, which of course means that y is equal to 2. Note: when we have an = it doesn't matter the order we write it. The expression 4 / 2 = y has the same meaning as y = 4 / 2.

This machine consisting of these 4 steps might seem really over complicated and silly, but it turns out that these rules are all we need to do some very complicated things. The complicated part of the machine is in step 3: figuring out how to reverse something.

Put this machine inside a loop

Let's make it a bit more complicated by introducing a slightly more complicated example:

4 = (y / 10) * 2

Can you figure out in your head what y might be just by thinking about it? We know in our heads that whatever y is, y / 10 must be equal to 2. If y / 10 must be 2, then y must be 20. But it's not so easy as before right? This number 20 kinda came out of nowhere. What if we do our little machine again. Let's do the steps as before:

Figure out which side of the `=` the `y` is on, the left of the right.

The y is on the right hand side.

Figure out which part of that side has the `y`, and what the "rest".

The "rest" is * 2. But this time, the part that has the y is no longer just y - it's y / 10.

Take that "rest" and reverse it

Ok, reversed that is / 2 (divide something by 2).

Apply that reversal to *both* sides of the `=`.

Ok, I will divide 4 by 2, and divide (y / 10) * 2 by 2. Now our expression looks like this:

4 / 2 = ((y / 10) * 2) / 2

Now we can "simplify" the right hand side as before, but instead of having just y left, we have this:

4 / 2 = y / 10

Oh, that's weird! That doesn't give us an answer at all! In fact it seems to have made everything more complicated! The "trick" is that we must run our machine again. In fact we must run our machine until the right hand side only has y - which in this case is just one more time. Ok, let's run the machine one more time. I won't go through all the steps again, but just say that the "reverse" of y / 10 is to multiply by 10:

(4 / 2) * 10 = y

Or this, because we can always flip the sides of an =:

y = (4 / 2) * 10

Now we can figure out what y is by doing the calculation (4 / 2) * 10 which is 20!

Reversing things

It turns out that reversing + and * are really simple. We simply make them the opposite: - and /. But in the last example we had y / 10 and we figured out that the reversal was * 10, which is true in that case but not always. Let's demonstrate why / is a bit tricky to reverse, by changing our example to this:

4 = (10 / y) * 2

Is it obvious what the value of y is? Does the answer just jump out at you? Remember that from before, whatever is in those brackets it must have a value of 2. So 10 / y must have a value of 2. Therefore y must have a value of 5 and not 20. But let's look at our machine. First do one step:

4 / 2 = 10 / y

So far so good, but let's run the machine one more time and assume that whenever we see a / we "reverse" it into a *:

(4 / 2) * 10 = y

Oh, whoops! We end up with y being equal to 20 again - what went wrong!!?

It turns out that reversing y / 10 and reversing 10 / y must be done differently. When we reverse y / 10 we get:

(y / 10) * 10

But we can't do the same with 10 / y. It turns out that we have to do this:

10 / (10 / y)

We have to keep it as a / when we reverse, and we must put it on the other side. Let's try running our machine again with this rule, from here:

4 / 2 = 10 / y

We get:

10 / (4 - 2) = 10 / (10 / y)

On the left side we put the 10 / to the left of (4 - 2), and we do the same on the right side.

Now take a look at the right hand side there: 10 / (10 / y). It's really not obvious at all that this simplifies to y. If fact it's extreemely confusing. We know from before that y must be 5. If y is 5 then 10 / y is 2. If we then do 10 / 2 we get 5 back again. I don't really know what to say here to help you understand this rule of reversing /. It might just be something you have to remember rather than deeply understanding. Anyway, assuming 10 / (10 / y) simplifies to y we can continue:

10 / (4 - 2) = y

And of course 10 / (4 - 2) is equal to 5, so y must be 5.

Subtraction has this strange thing just like divide:

4 = (10 - y) * 2

We can "see" just by looking that 10 - y must be equal to 2. So y must be 8. But if we run our machine first once:

4 / 2 = 10 - y

And again, and this time doing this same weird reversal trick:

10 - (4 / 2) = 10 - (10 - y)

Which simplifies to:

10 - (4 / 2) = y

Why the heck can we reverse + and * by always doing a - and /, but when we reverse - and / we have to do this complicated stuff? Sometimes the reversal of - is + and sometimes the reversal is still a - but with the weird order changes...

The reason why - and / are different is because of something called the "Commutative property". It's a fancy way of saying that 6 + 2 is always the same as 2 + 6. The + operator is "Commutative" meaning it always produces the same value regardless of the order of the numbers.

But - and / are not commutative:

2 - 6 = -4
6 - 2 =  4

The order of the numbers matters - a lot. Same with divide:

2 / 6 = 0.33333...
6 / 2 = 3

Because - and / are not commutative we must treat them differently when we reverse them, depending on which side the y is. It's weird and complicated but just deal.