Tuesday, March 7, 2017

Coffee Cup Multiplication

Sometimes simple rules can lead to complex, beautiful patterns. An example of this is modulo multiplication on a circle. Each step is easy to describe, but the resulting image can be surprisingly intricate.

As you may recall, the modulo operation finds the remainder when one number is divided by another number. So \(a \equiv r \bmod n\) means that \(a\) divided by \(n\) leaves a remainder of \(r\).

Imagine that you have the numbers 0 through N-1 arranged on a clock, so that 0 was at the 12 o'clock position. For each position, multiply by some constant factor and find the remainder modulo N. Now draw a line between the position and the result of multiplying the position by the factor and finding the remainder modulo N.

As an example, if your constant factor is 3 and N is 10, then you would draw the following lines:

  • 0 to 0 (3*0 mod 10 = 0)
  • 1 to 3 (3*1 mod 10 = 3)
  • 2 to 6 (3*2 mod 10 = 6)
  • 3 to 9 (3*3 mod 10 = 9)
  • 4 to 2 (3*4 mod 10 = 2)
  • 5 to 5 (3*5 mod 10 = 5)
  • 6 to 8 (3*6 mod 10 = 8)
  • 7 to 1 (3*7 mod 10 = 1)
  • 8 to 4 (3*8 mod 10 = 4)
  • 9 to 7 (3*9 mod 10 = 7)

Burkard Polster does a much better job explaining the concept in one of his very fascinating Mathologer videos on YouTube.

I created this interactive visualization so that you can play around creating your own patterns. You can adjust the constant factor and the number of points along the circle. For the above example, the constant factor is 3 and the number of points is 10. This gives the equation \(y = (x * 3) \bmod 10\). Note that in the interactive visualization, 0 corresponds to the left most point, and points are numbered sequentially clockwise.

One of the interesting things about these patterns is that they can appear inside your coffee cup! (or any other cup for that matter).

If you have a light source on the edge of a cup, you get a cardioid shape, which is also the shape when the constant factor is 2 in the modulo multiplication.

If the light beams are parallel to the cup, you get a nephroid shape, which is the shape when the constant factor is 3.

The paper on this can be found here. What interesting patterns can you find?

Saturday, March 4, 2017

I am my baby, logically speaking

Yes
Everybody loves my baby
But my baby don't love nobody but me
Nobody but me
Oh
Everybody wants my baby
But my baby don't want nobody but me
That's plain to see!

The above lyrics are from the popular jazz song Everybody Loves My Baby composed by Spencer Williams in 1924. What may not be so plain to see is that it logically follows that

I am my baby!

Hmm, that seems like a very strange thing for Louis Armstrong to be singing about. Let's get to the heart of the logical argument:

Premises:
-- Everybody loves my baby.
-- My baby only loves me.
Conclusion:
-- I am my baby.

The argument goes as follows:

Everybody loves my baby. So, my baby must love my baby. But my baby only loves me. How can my baby love my baby and also only love me? It must be that my baby and me are the same person. Therefore, I am my baby.

We can even make the argument more formal by converting the English sentences into symbols and arrive at the same conclusion by following the rules of logic.

Let x be the universe of people, \(Luv\) means 'u loves v', b means my baby, and me means me (naturally).

For all x, x loves my baby.
[1] \(\forall x, Lxb\)

For all x, my baby loves x if and only if x is me.
[2] \(\forall x, Lbx \leftrightarrow \left(x=me\right)\)

Substituting b for x in [1] and [2], we get
My baby loves my baby.
[3] \(Lbb\)
And, my baby loves my baby if and only if my baby is me.
[4] \(Lbb \leftrightarrow \left(b=me\right)\)

This last statement implies that
If my baby loves my baby, then my baby is me.
[5] \(Lbb \rightarrow \left(b=me\right)\)

Together, [3] and [5] imply
My baby is me
[6] \(b = me\)

So what happened? Well, if we truly want to capture the meaning of the lyrics, then we need to take a look at our universe of discourse (or what we mean when we say 'For all x'). We claimed that x is the set of all people, which includes my baby. The intended meaning is probably that everybody other than my baby loves my baby.

For example, this is probably not the most helpful thing to say to a friend.

Friend: Nobody believes me!
You: That's not true - you believe you.

Your friend probably meant that no other person believes her.

This just goes to show that human language can be ambiguous and care must be taken when converting language into logical symbols so that the intended meaning is preserved as close as possible. Otherwise, you might get some surprising results, no matter how sound your reasoning.

Despite that, I think we should keep the song the way it is. Somehow, this doesn't quite have the same ring to it:

Yes
Everybody (that's not my baby) loves my baby
But my baby don't love nobody but me
Nobody but me
Oh
Everybody (other than my baby) wants my baby
But my baby don't want nobody but me
That's plain to see!