Saturday, September 18, 2010

Childhood magic

The science fiction writer Arthur C. Clarke (who incidentally predicted the geostationary communication satellite in 1945) once famously said, "Any sufficiently advanced technology is indistinguishable from magic." One example I like to use in this regard is the music or video player. It would have seem incredulous to someone from the early 19th century that a spinning disk or cylinder can record music and speeches. Similarly if you tell someone from the early 20th century than you can record hours of moving pictures on a tiny disk, they would find that magical. Even today, it seems incredible to me that you can records hours of movies or 1000's of songs on a device no bigger than a postage stamp. One fascinating aspect of the multimedia player and recorder is the amount of technology involved, spanning mathematics (some of them discovered thousands of years ago), physics and engineering, but that's a discussion for another time.

I had similar experiences as a child when I learned of various puzzling phenomena in science and mathematics. The amazement only deepens when I became older and understood the reasons behind the magic. Let me delineate some examples here.

1. My first computer was a Commodore VIC-20. This is a wonderful machine with features that were quite advanced at the time for a home computer. It outputs in color and has polyphonic sound capabilities. During one of our experiments with sound, my brother and I made two of the sound generators generate tones at frequencies that are almost the same. The result was surprising and quite remarkable to us! We heard a sound whose intensity undulates, like a siren. It is magical how the superposition of two pure tones can create such a strange sound effect. Only year later did I discover that this is a phenomena known as beat frequencies. Mathematically, we can expressed the pure tones generated by the sound generator as a sinusoidal wave of the form sin(2π x frequency x t). The summation of two sinusoidal waves is an exercise in high school trigonometry:

sin(a) + sin(b) = 2sin(0.5(a+b))cos(0.5(a-b))

Given two tones of different frequencies, their superposition results in:

sin(2π f1 t) + sin(2π f2 t) = 2sin(2π 0.5(f1+f2)t)cos(2π 0.5(f1-f2)t)

Thus the result is a sinusoidal wave whose frequency is the average of f1 and f2 with the magnitude modulated by a sinusoidal wave of frequency 0.5(f1-f2). If f1 and f2 is close enough and the difference |f1-f2| is small enough that the magnitude modulation is at a frequency that we can distinguish aurally, then this is what the siren-like undulation of the amplitude is about. This is shown in the following figure where the second waveform has a frequency that is 10% higher than the first waveform and the sum of these two sinusoidal waves of slightly different frequencies is shown at the bottom of the figure:2. In a series of books to introduce young children to science and mathematics, I found an article that was truly amazing to me. It describes a simple device for measuring distances between you and a far away object. Most of the time we measured distances using a ruler or a tape measure, but that is not feasible for far away objects. There are sonar measurement devices that bounces ultrasound off an object and measure the time it took for the sound to come back, but that is too high tech. No, this device was simply a piece of paper with markings on it!

To measure the distance from you to, say a tree, you hold the paper with your outstretched arms and close your right eye. You line up the tree with the reference mark "0". Then you close your left eye and open your right eye. The position of the tree on the paper will be the distance. It is as simple as that! Pure magic! The underlying principle behind this cute little device is the parallax principle and can be described in the following bird's eye view (pardon my crude drawing skills):

In essence, your right eye and your left eye will line up the tree with the paper at different spots. How far the markings on the papers need to be is simply a matter of trigonometry.  The parameters you need will be the length of your arms L (or more accurately the distance from your eyes to the paper) and the distance between your eyes s.  In particular, the congruent triangles show that the distance to the object D is related to the distance p on the paper between the left and right eye view via the following equation p = s(D-L)/D.
Such an elegant solution to the problem of measuring distances.  One drawback of this approach is that the resolving power decreases as the distance increases.  As D → ∞, we see that p → s, i.e. all the lines on the paper are bunched up towards the end.

3. Once upon a time, I spend my summers working for a family friend's grocery store and restaurant and there was an avuncular gentleman there who proposed the following enticing offer. He said: "I'll give you Nafl. 100 (Nafl or Florin is the official currency of the Netherlands Antilles) if you can solve the following problem. There are 3 houses and 3 utilities (electricity, water and gas). Each house needs a connection to all 3 utilities. Draw me a set of lines connecting each of the 3 houses to each of the 3 utilities without any of the lines crossing each other."
This seems simple enough. So I spent the next couple of weeks trying to solve this problem, drawing maps on reams of scratch paper. Trying hard as I might, I cannot come up with a solution. It was very frustrating because many times I thought I had the solution, and only not being able to place one final connection. Now I know that the problem is impossible. In mathematical terms, the graph I am trying to draw is the complete bipartite graph K3,3 and this is impossible to draw on a piece of paper without some lines crossing each other since the graph K3,3 is not planar.  In fact the graph K3,3 is an important part of the necessary and sufficient conditions for a graph to be planar.

4. One interesting math trick I learned was how to take fifth root of large integers.  The trick goes as follows.  Ask your friend to pick a 2 digit number and input that into a calculator.  Then raise that number to the fifth power and show you the answer.  Within seconds, you can tell your friend which 2 digit number he or she picked.  The main ingredient of the trick is the fact that any integer raised to the fifth power has the same last digit as itself.   This interesting number theoretical fact is actually easily shown using basic number theory.  In mathematical terms, the result we are trying to show is
x5 ≡ x  mod 10
It is clear that the fifth power of an even number is even and the fifth power of an odd number is odd, i.e.
x5 ≡ x  mod 2
According to Fermat's (little) Theorem (not to be confused with the celebrated Fermat's Last Theorem that took more than 350 years to solve):
x5 ≡ x mod 5
Since 2 and 5 are relatively prime, this implies that x5 ≡ x  mod 10
To complete executing the trick, one needs to memorize the fifth powers of 10, 20, ..., 90.   Because raising a number to the fifth power is a monotonically increasing operation, this allows one to determine between which of the 2 decades the 2 digit number lies and thus determine the first digit of the number.  The last digit one would read off from the last digit of the fifth power. 

Monday, March 29, 2010


My son recently installed a screensaver on his computer and this leads me to reminisce about the screensavers I have seen over the years. In the distant past, computer screens were all built using cathode ray tube (CRT) technology, where a beam of electrons is accelerated to hit a screen of phosphor causing a release of photons lighting up the screen. One drawback of such screens is that in heavily used areas of the screen the phosphor will lose its ability to release photons after a while. If one continues to display the exact same image on the screen for an extended period of time, this would cause the image to be burned-in at the display. Common places where you see this phenomenon is in ATMs and Airport terminals.

To prevent burn-in of personal computer displays, screensavers were created, which are programs that are activated after several minutes of inactivity to constantly change the images displayed on the screen, in order to wear down the phosphor more evenly. One of the earliest screensavers for PCs is the flying toaster screensaver, where toasters are flying across the screen. Since then the screensaver has become much more sophisticated (e.g. displaying fractals and other beautiful patterns based on mathematical equations) and has been used for a myriad of tasks, including advertising, display of news (e.g. PointCast), photo slideshows (e.g. Picasa) and collaborative computing (e.g. World Community Grid) to help solve various important problems in the world today. Since most computer screens today are based on LCD technology, the problem of screen burn-in is less of a problem (but could still exist). However screensavers are still popular since they create a useful diversion to mundane computing tasks.

Back to the screensaver that was installed on my son's computer. This screensaver is associated with a popular video game, and when the screensaver starts, the logo of the game is displayed at a fixed location at the center of the screen with a scrolling star field in the background. This is exactly the kind of burn-in prone images the screensaver is trying to prevent. So it seems we have reached full circle!