Sunday, December 11, 2011

Magic Square: Lo Shu Metric!

Let us indulge in the topic of Magic Squares today – simply put, it is a square grid into which whole numbers are placed. The whole numbers themselves need not follow any order but they must be distinct, and placed in such a way that each horizontal row, vertical column and diagonal add up to the same number. 

Let us illustrate by means of an example:

A 3 x 3 'Lo Shu' Square
Observe:

1st Row: 8 + 1 + 6 = 15
2nd Row: 3 + 5 + 7 = 15
3rd Row: 4 + 9 + 2 = 15
1st Column: 8 + 5 + 2 = 15
2nd Column: 1 + 5 + 9 = 15 
3rd Column: 6 + 7 + 2 = 15 
1st Diagonal: 8 + 5 + 2 = 15
2nd Diagonal: 6 + 7 + 2 = 15
This magic square is known as the 'Lo Shu' square and was known in China around 3000 BC. Legend says that it was first seen on the back of a turtle emerging from the Lo river - the natives then took it as a sign from the gods that they would not be freed of pestilence unless they increased their offerings.

But really, is there a systematic way of generating such magic squares? Indeed there is! There are several methods, of which the likes of trial and error I shall not mention, haha. Suppose we go by a logical algebraic method:

1) For a 3 x 3 square, there will be 9 numbers, whose sum is given by:

S = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45

Since each row must add up to the same number, dividing this by 3 means that each row/column/diagonal must add up to 15.

2) Let us now consider the central cell and label it x:

The Blank Square
We know that each row, column and diagonal must add up to 15, and so if we add up the middle row, middle column and both diagonals, we have them adding up to 60:

15 + 15 + 15 + 15 = 60

Now, pause for a moment - if you take the sum of the middle row, middle column and both the diagonals, that's equivalent to taking S + 3x = 60 because you're adding all the numbers from 1 through 9 once, and then adding them to 3x.

Since S = 45, then surely:

3x = 15 and therefore x = 5

And of course, we can carry on ad infinitum, ad nausea, via a system of simultaneous equations that can be solved for every single element in the grid we see above.

But surely, surely there must be an easier method!

Well, guess what? There is one! Simon de la Loubere, the French ambassador to the King of Siam in the late 17th century, wrote down an algorithm for constructing magic squares that have an odd number of rows and columns:

1) Place a '1' in the middle of the first row.

2) Go up one cell and then one cell to the right (order doesn't matter) to place successive numbers.

3) If the cell is blocked, the successive number should be placed beneath the current number.

Let's illustrate this awesome rule:

The 'Loubere' Algorithm
And there you have it:

A 3 x 3 'Lo Shu' Square
Using this algorithm, you can easily create any magic square that has an odd number of rows and columns. :)

Saturday, December 10, 2011

Pendulum Wave

It's been about 2 years since I last posted anything, so here goes:

Suppose for a minute there you believe me that the angular frequency of a pendulum is given by:


Where L is the length of the pendulum and g is the gravitational field strength. Well, none of that matters really, suffice to say that the longer the pendulum, the faster the oscillation for a given gravitational field.

In the video below, you’ll see that the pendulum bobs with a longer string length swing with a lower frequency than those with shorter string lengths, in accordance with the equation above.

What do you notice? Notice how the pendulum bobs start to swing in a synchronized fashion and then gradually start to lose their synchronization. This generates the nice pattern we see. Can we apply any quantitative explanation to this nice pattern of synchronization we see? Yes we can!

Now, suppose you now believe me (again) that the pendulum swings in such a way that when you follow the horizontal component of its displacement from equilibrium, it traces out a sinusoidal curve with respect to time as follows (I’ve left out all axes for simplicity):


Now imagine you have many different pendulums, all of different lengths – each pendulum bob differs from its preceding and successive pendulum bob by just a small change in its length. Then you you would expect the sinusoidal curves traced out by each bob to be slightly different due to different frequencies, as such:


The sinusoidal curves are all of different frequencies, though differing only slightly from one another – occasionally, one might expect the pendulum bobs to swing in phase and synchronize with one another, but most of the time, the pendulum bobs swing out of phase and are asynchronous due to their different frequencies.

So what does your eye see when you superpose all of the pendulum motions together? Well, essentially, there will be a period of time when the pendulum bobs all seem to be swinging in sync and then because of their different frequencies, they slowly start to swing out of sync, and then slowly again, they swing in sync. So if you add up all of the sinusoidal curves for a representative interpretation, you obtain this:


This is known as a wavepacket – the amplitude (how high the wave is) represents how coherent, or how in sync the individual pendulums are with one another. In the central portion, the amplitude is high, meaning the pendulums are almost swinging in sync. As time progresses, the pendulums swing out of sync, and you see the height of the wave packet decreases.

The motion is however, periodic, so you see the same patterns repeating over and over again, though with decreased amplitudes due to loss in kinetic energy.

That’s essentially it, but I haven’t made any additional effort to correctly quantify the patterns that we see. So sorry!