Wednesday, December 26, 2012

Logarithms and the end of the world

Hardly a day goes by when I am not asked "Hey Math Guy!  What do logarithms have to do with the end of the world?"  Now that the end of the world has come and gone, I will share an interesting coincidence from the annals of math history.

When the natives are restless, they use log rhythms to communicate over long distances


I am not talking about prosthetic devices, like artificial limbs and fake noses. At least not yet. I predict that I will, however, be talking about fake noses soon. And I am definitely not talking about electrophoresis or paresthesia[1]. Prosthapheresi Prosthespaeoius Prosthaphaeresis is a technique used to simplify multiplication.

Here is the simple approach. When you have two numbers to multiply together, you first compute arccos and arcsin of both. Then you add and subtract to get some other numbers. Then you compute the sine or maybe cosine of these and add them together. Or maybe subtract. Then divide by two.

Easy enough, right? Except for the silly fact that all these trig functions will probably involve multiplying, this simple method turns multiplying into the easy process of addition and subtraction. The trig functions may be seen as an impediment, but if you happen to have a trig table handy (or a scientific calculator app for your smart phone) then you can just look them up. And lemme tell ya, 16th century astronomers always had their trig tables handy.

Required reading for all 16th century astronomers

So, when some unknown person came up with the idea that a trig identity could be used to make the multiplication process faster, it got a lot of airplay. The phrase "(sin x + sin y)/2 = sin ((x+y)/2) cos ((x-y)/2)" was on everyone's lips.

I have a similar formula that turns multiplication into addition, subtraction and a quick look up in a table of squares: ((x+y)/2)2 - ((x-y)/2)2 = x y. Let's say we wish to multiply 9 X 17. The sum and difference are 26 and 8, which become 13 and 4 when you divide by 2. I happen to know that 13 squared is 169, and also that 4 squared is 16. The difference (169 - 16) is 153. I'm so confident in this method, that I am not even gonna check that with my calculator.

This formula has become known as John the Math Guy's Prosthaphaerisoid. I have not found any evidence that this formula was known back in the 16th century. I have looked in the index of all my math history books (there are 127 of them on my shelf), and have not found a single mention of the formula under that name. It's too bad. If they had known the formula earlier, Pluto would have been discovered so much earlier and the whole "is Pluto a planet" thing would have been settled already.

Invention of logarithms

Enter John Napier (1550 - 1617), who is remembered today as the inventor of logarithms. In 1614, he published a book of logarithms called Mirifici Logarithmorum Canonis Descriptio. I am sure most of my readers have a well worn copy of this book sitting on their night stand.

The father of modern-day ciphering

Napier took inspiration from several sources for this boon to cipherophiles [2]. Primarily, he drew from the idea of Prosthaphaeresis which was indirectly introduced to him by Tycho Brahe, an eminent astronomer of his time [3]. Probably at a dinner party of 16th century math geeks. Napier also drew on the work of Michael Stifel (1487 - 1567). While Stifel most certainly did not invent the formula that makes logarithms possible, he was likely the first one to state that logarithms turn multiplication into addition, and division into subtraction.

am an = a(m+n)

The formula that made it all possible

Doomsday prophecies 

It would perhaps be to Napier's dismay that he has not been remembered for his book A Plain Discovery of the Whole Revelation of Saint John (1593). This book was a bestseller during his day, and even after his death, was printed in twenty-one editions, and was translated into Dutch, French and German. Both the words and the numbers were translated, by the way [4].

Napier was a vehement Protestant. In his book he viciously attacked the Catholic Church, claiming that the pope was the Antichrist. Napier also offered his prediction that the Day of Judgment would come between 1688 and 1700.

Michael Stifel entered an Augustinian monastery and was ordained in 1511. After much dissatisfaction with the Catholic Church, he sought the help of no less a personage than Martin Luther in setting him up in Protestant pulpits. Unfortunately, Stifel's career as a minister was tumultuous, having to move from several parishes due to anti-Lutheran sentiment, and leaving another due to war. Stifel predicted that the world would end on October 3, 1533, and many believed him. As a result he was arrested and forced to leave yet another post. There is not much profit in being a prophet.

Actual unretouched photo from Oct 3, 1533

It would be to Stifle's dismay that he has not become known for his own bestseller, A Book of Arithmetic about the AntiChrist. A Revelation in the Revelation. [5] 
Not only do Stifel and Napier share the discovery of logarithms and prediction of the end of the world, but both men also accused the pope of being the Antichrist.

Much as he would have liked, Isaac Newton himself could not lay claim to the invention of logarithms, but he  had something to do with logarithms. He came up with an estimate of the sum of the harmonic series that involved logarithms. And, much like Stifel and Napier, Newton would have been dismayed that he has not been remembered for his endless religious writings. And, needless to say, he had a few things to say about the end of the world. He declared that is could not end until after 2060, when his pants would be done at the cleaners.

"This I mention not to assert when the time of the end shall be, but to put a stop to the rash conjectures of fanciful men who are frequently predicting the time of the end, and by doing so bring the sacred prophesies into discredit as often as their predictions fail."

Now there's a clever guy. If his prediction were to fail (the world were to end before 2060) who would be left to call him on it? And if 2060 comes and goes without incident, then it's well past his lifetime. Why worry? 

One last mathematician's prophecy

Some of you are no doubt familiar with the greatest living mathematicomedian, Tom Lehrer. Well, maybe he is one of the greatest. There is at least one other vying for that title. Lehrer also had his predictions about the end of the world.

Oh we will all fry together when we fry.
We'll be french fried potatoes by and by.
There will be no more misery
When the world is our rotisserie,
Yes, we will all fry together when we fry.

[1] Just to be clear, electrophoresis is not a way to remove unsightly, embarrassing hair. Paresthesia is not waking up one morning thinking that you are Paris Hilton.

[2] Cipherophile - One who loves cipherin'. I coined this word just for this blog. Just look for it to be used on the Jerry Springer show in the next week or two. My own prediction.

[3] Tycho Brahe was an interesting fellow. His chief contribution to science lay in providing his collaborator and rival, Johannes Kepler with data on the positions of the planets. Kepler used this data to do a little curve fitting that showed that the planets run their courses in elliptical paths. Newton in turn drew from this to establish the inverse square law for gravity.

Aside from having an odd sounding name that I don't know how to pronounce, Brahe also had a prosthetic nose made of gold and silver. His original nose was of the standard design with flesh and cartilage, but he lost part of it in a sword fight with a cousin about a mathematical formula. Ah! to be back in the days when scientists were real men, rather than sarcastic little blog-writing cipherophiles! Brahe owned a pet elk, which met it's demise when it was fed too much beer at a party. It toppled to it's death on a set of stairs.

[4] I know it is unlike me, but this is a silly statement. Oddly enough, the symbols for numbers were standardized across Europe at this time. This was before ISO.

[5] I personally am a bit dismayed that this title has already been taken. I had been planning to use that very title for my memoirs.

Wednesday, December 19, 2012

Math carols

In this week's blogpost, I share the intersection between John the Math Guy, music parodies, Christmas, and silly stuff from high school. By popular demand, and just in time for Christmas math caroling of your own, I present the complete collection of John the Math Guy's Math Carols. At least as complete as I can remember from 1974.

Pi to the World (sung to the tune of  "Joy to the World")

Pi to the world,
twenty two over (eight minus one),
Irrational though it be.
Let every round thing
now fit the expounding
with each and every degree,
with each and every degree,
with each, with each, and every degree.

Arcs the Mighty Compasses Bring (sung to the tune of  "Hark the Herald Angels Sing")

Arcs the mighty compasses bring,
constructed with a steady swing.
Geese are worth not twenty Yen,
Shucks! I've torn my diagram of Venn.
A triangle within a semicircle lies.
Incongruent triangles are not the same size.
But, congruent ones are the same.
Geometry drives one insane.
But, congruent ones are the same.
Geometry drives one insane.

We Wish You a Semicircle (sung to the tune of  "We Wish You a Merry Christmas")

We wish you a semicircle,
we wish you a semicircle,
we wish you a semicircle,
and a parallelogram.

We wish you an acute trapezoid,
we wish you an acute trapezoid,
we wish you an acute trapezoid,
and a doggie named Sam.

Constructions we make of geometric figures,
constructions of figures,
and a doggie named Sam.

There's No Place Like Rhombus the Holidays (sung to the tune "There's No Place Like Home for the Holidays")

Oh, there's no place like Rhom.... bus us there today,
cuz division by zero's undefined.
If you set out to graph this maladay,
You will find it's mis-inclined.

Oh Sum, All Ye Mathful (sung to the tune of  "Oh Come, All Ye Faithful")

Oh sum, all ye mathful,
corresponding pupil.
Oh sum ye, oh sum ye to find the total.
Desist your secant,
Archimedes' streak can't
Move the Earth,
Eureka, move the Earth,
A streakah move the Earth,
No can't move disjoint.

Go work Ye Merry Protractors (sung to the tune of "God Rest Ye Merry Gentlemen")

Go work ye merry protractors
make straight lines here today.
Remember every angles not made of just one ray.
Euler was a greaser,
but that's not what textbooks say.
Oh, tangents of circles and spheres,
circles and spheres.
Oh, tangents of circles and spheres.

Wednesday, December 12, 2012

Follow up on colorblindness testing

I posted a blog on colorblindness testing (and apps for tablets, and gamuts of displays, and my dog Truffle) that has led to some interesting discussions in various LinkedIn groups. The comments are great, but unfortunately, they wind up in a variety of different groups. People from one group don't necessarily see what people in another group have had to say.

In this blog post, I am coalescing the various discussions.

How can you test for colorblindness?

The one true standard test for colorblindness is the Ishahara test. The picture below shows slide 4 from this test. People with normal color vision will be able to clearly see a picture of Eddie Albert [1] in this picture. This was developed back in 1917 by an ophthalmologist whose name was (oddly enough) Dr. Ishahara. The test is quick and easy to perform, and you can find 867,324 versions of this test online, although I did notice that there are a few that are not quite as good as the other 867,319.

A picture of my Academy Award winning spaghetti

The other one true standard for colorblindness is the Farnsworth Munsell 100 hue test, which, according to the XRite website is "one of the most widely used tests in industries where color decisions are critical." You can by the boxed set from various places including "the Munsell store". I am not sure how they came up with that name. Just another fluke, I guess.

The Farnsworth Munsell 100 Hue test with 84 hues

In the test, the contestant is given one rack of tiles at a time, and is asked to put them in order according to hue. This is definitely a tough test - the difference in hue between adjacent tiles is very subtle. For that reason, there is some substantiation for the claim of the Munsell Store that this is an important test for people who are making judgments on color matches where the color is critical.

David A. (one smart guy I know) pointed out the difference between the two true standards for colorblindness: "As the Ishahara test has fewer testing points than the FM test, the FM test is also a great test to test for subtle discrimination..." David is making a distinction here between colorblindness and something more like "color acuity". I have seen myself that there are (loosely speaking) three types of people when it comes to the FM test: 1. those who fail miserably and are truly colorblind, 2. those who do very well on the test, putting almost all of the colors in the proper order, and 3. those who get a bunch wrong. I honestly don't know what distinguishes the second and third categories.

Paul raised this point in a way that sounds like he is pretty smart, too: "to find out who in the staff that has perfect colour discrimination capacity (roughly only 10% of the male and female part of the staff), you need to use the FM100 test (or similar)." [2]

Two other people (separate LinkedIn discussions) Shoshana and Michio provided links to the online version of the Farnsworth Munsell test. This is certainly cheaper than the physical version, and it is part of the webiste from XRite, so you know it's not from some fly-by-night guy who claims to be a color scientist and maybe has a silly blog where he pretends to know what he is talking about.

Screenshot for the XRite FM test, which has nothing to do with radio

But this might not be a good test. Here is a comment from that European (and therefor presumably smart) guy, Paul: "One of the teachers at Malmoe University, Graphic Arts Department, tested the online version of the X-Rite (simplified) FM-100 test, and failed miserably. I pointed out to him that he probably needed a better quality monitor, and a calibrated one. I suggested he try my monitor, a LaCie at the time, which was fairly recently calibrated. Now he suddenly managed very well in the same test."

I tried out the online test myself. My score was not all that spectacular. I appreciate the fact that Paul has offered me a way to save face. My monitor is not calibrated.

This brings up the next discussion topic...

Are the tablets up to the task of accurate color testing?

Here is the seed that got me started on this blog post. Bob C. apprised the group "ISO TC 130, WG 13, Task force Harmonizing" of the EnChroma app. Bob was wondering the basic question as well: "I'm also interested to know if EnChroma test correlates with the Ishihara's test for color blindness."

Here is my opinion, for what it's worth. I think the EnChroma app is likely to work well to screen for colorblindness.

David A. asked a similar question in a different thread: "I wonder if the three tablets tested would show any significant differences with an FM type of test."

It would appear that we have two pieces of anecdotal evidence that suggest that color management is important, at least for the FM test on the display of a "real" computer. This makes sense. Colors change when I move a window from my laptop to the monitor that it drives. It is not that far of a stretch to say that the difference between two colors can change as well. The display on my laptop compresses some areas of color space. If the compression happens in areas that the FM test is looking for, then the test will just get harder.

This in turn, brings out the next question...

What about color management on tablets?

Reem pointed out that the Datacolor SpyderGALLERY is an app for iPad and iPhone that provide some color management solutions for photographers. This gadget will measure the colors on your iPad and make adjustments so that it will provide accurate color rendition of images.
The Sypder4 monitor calibration device

She asked if there were any similar apps available for Android devices. I am not aware of any. Sounds like an opportunity for some company... Maybe Datacolor or XRite have some interest in this?  Or maybe the Android operating system does not facilitate calibration?

Does anyone have an answer to this?

One last thing

For those unfortunate readers who are not from the Midwest, I may need to clarify a subtle joke in the previous blog. I called the folks who took the test "Ollie", and "Lena". I should have called the fellow "Ole". Steve T corrected my spelling on this.

The names came from one of the favorite pastimes of Midwesterners: telling Ole and Lena jokes. Ole and Lena were an old Norwegian couple, and they were always getting a bit confused. I wrote these two joke sespecially for this occasion.

Ole: "De doc says dat I am color blind to vun color."
Lena: "Vut color is dat?"
Ole: "I don't know. I couldn't see it."

Sven noticed his old friend, Ole eating a bag of rabbit turds.
"Vat are you eating der, my friend?"
"Lena gave me a bag of M&Ms for my lunch. Wasn't dat sveet of her?"
"Ole, didn't you notice anything funny about de color?"
"Ach, yes! Lena always takes out all de red ones cuz knows I'm color blind. Such a dear voman she iss"

[1] Eddie Albert played the itinerant peddler Ali Hakim in the movie version of Oklahoma, and was nominated for Academy Awards in two other films. After sunc accomplishments, how would you like to be remembered for Green Acres? Life is not supposed to be fair.

[2] Another clue that Paul is smart is that he puts the "u" in "colour". That means that he is either European or pretentious. Since I know that he is European, and all Europeans are smart, then... I don't think that David A. is from Europe, although I would guess that he has been there a few times.

Wednesday, December 5, 2012

Does my dog appreciate my KindleFire display?

I read another interesting blog post from Jeff Yurek [1]. In his post, he compares the displays for the iPad Mini, the Nexus 7, and the Kindle Fire HD. Unlike the scores of other reviewers, he doesn't expound on the size or number of pixels. Jeff looks at the color. Specifically, he has checked out the size of the gamut - the total range of colors that can be displayed.

His conclusion is that the Nexus and Kindle have bigger gamuts than the iPad. This is important, because what self-respecting guy doesn't want a tablet that has a big gamut? After all, women realize that it's not about the number of pixels you have. It's what colors you can get with them.

Here is an image that I have remorselessly stolen from his post. You can see that the iPad is somewhat lacking in the saturation of red and green, but where it really falls down is in the blue. The iPad just does not have as saturated of a blue. I was quite pleased with this, since I own a Kindle Fire, and secretly have a bit of iPad envy going on. My wife has an iPad.

Comparison of the gamuts of three tablets

This all got me thinking. Naturally, it got me thinking about whether my dog, Truffle, can appreciate the extra gamut of the Kindle Fire.

Truffle the Teddy Bear Guy

Colorblindness and dogs

One of our dogs, Scrabble, has been featured previously in my blog. He played the Shih-Tzu in the Mathematical Misnomers post, and he played the dog in the painting in the Card Shuffling post. It's about time that Truffle gets mentioned.

Everyone has told me that dogs are colorblind, but I wanted to find out myself. I just heard about an app for color blindness testing from EnChroma. (Thank you, Dr. Bob!) So I thought I would give it a try. This app is a version of the Ishahara colorblindness test. I downloaded it for my Kindle and administered the test to Truflle to check to see if he really is colorblind. He licked the screen. I'm not sure I know what that means.

Screenshot of the colorblindness test app showing an orange cross sign

The competition

My wife and I both have very good color discrimination. I took the Farnsworth Munsell 100 Hue Test [2], and had a nearly perfect score. Now, my wife (who is not competitive at all) took my performance as a challenge. She took the test and proceeded to get a perfect score. But, she's not competitive. Honest. Just ask her. [3]

My wife has an iPad, and I have a Kindle Fire. The EnChroma app is free for both of these. And as I have said, my wife is not competitive. Can you see where this is going?

We played the game color test, a total of 16 times. I took it four times on the iPad, and four times on the Kindle. She did the same. Before running the test, I made sure that none of the usual experimental safeguards were in place. I did not normalize the whitepoint of the two displays. I did not set us each down in a neutral room with low lighting. I did not test either contestant experimental subject for any psychotropic drugs that might effect the outcome of the experiment. In short, I wanted to make sure that I had an out if I didn't do well.

The table below shows the results. Note that the subjects were randomly assigned names to protect the identities and marital harmony. Note that EnChroma gives you 5 points for every incorrect score and there are 60 opportunities to screw up. A score of 0 is perfect. A total score of 300 is perfectly awful.

Person Device Protan Deutan Tritan Total
Ollie iPad 5 10 5 20
Ollie iPad 0 0 0 0
Ollie iPad 5 0 0 5
Ollie iPad 0 5 0 5
Ollie Kindle 5 10 0 15
Ollie Kindle 0 0 0 0
Ollie Kindle 0 5 0 5
Ollie Kindle 5 5 10 20
Lena iPad 10 5 5 20
Lena iPad 5 10 0 15
Lena iPad 5 5 0 10
Lena iPad 0 5 5 10
Lena Kindle 10 10 10 30
Lena Kindle 0 0 0 0
Lena Kindle 15 5 0 20
Lena Kindle 0 5 10 15

Whoever is named "Ollie" attained the astoundingly remarkable feat of an absolutely perfect score an incredible 20% of the time. Ollie's wife only did that once throughout the entire experiment. To be fair, Ollie's wife also complained that the Kindle Fire touch screen is not as responsive as the iPad. Twice, this caused an error. She wanted to make sure that she had an out as well. [4]

When comparing the Kindle Fire and the iPad, we have average total scores of 13.13 for the Kindle and 10.63 for the iPad. By my reckoning, this is just on the edge of being statistically significant. But, allowing for the two reported mis-keys in the test, the difference becomes insignificant.

My summary: Based on this awesomely scientific experiment, I conclude that the difference in the color gamuts of the displays does not cause color acuity problems.  

One more acknowledgement

I have acknowledged two people who inspired this blog post, Jeff, and Bob. I should mention one other.

I just had a nice long chat with an old friend of mine by the name of Steve the Tall Guy [5]. (I should make it clear that this Steve is different from "Steve the British Guy", who provided me with inspiration for my blog post on the Monty Hall problem.)

Anyway, I was talking with Steve the Tall Guy and he pointed me to a very interesting podcast about color from RadioLab. The podcast is about the subjectivity of color. It makes the point that color is not strictly some inherent property of an object, but rather, it is partly something that is manufactured somewhere after a photon enters our eye.

Illustration from RadioLab website showing 
some weird kinda Pink Floyd thing that I wish I could do with my eye

They gave color blindness as one simple example of this subjectivity. Someone who is colorblind may perceive two objects as being the same color, whereas I may see those two objects as being a different color, in much the same way that there are some rare individuals who don't think my wife is beautiful. I don't understand them, but something happens to the photons after they go in their eyes. As far as I can tell, my two dogs think my wife is beautiful even through the poor sods are colorblind. 

The podcast has given me grist for all kinds of future blog posts. One subject I wish to bring up is why we have three color sensors in our eyes, and why the mantis shrimp has 17. I just happen to be reading a book that proposes an answer. I'll finish the book and get back to you.

[1] I mentioned a blog post of his before in my blog post "Red is the color of..." I enjoy his posts.

[2] For some odd reason the Farnsworth Munsell 100 Hue Test has 85 tiles. What do I know? I do math. I can't count.

[3] The Scrabble app for my Kindle Fire is currently broken, so I am not able to get routinely trounced by my very-noncompetitive wife. She is not at all competitive about Scrabble. Did I mention our first dog's name is Scrabble? I hope they take their time making sure that the app is thoroughly debugged before they release an update. I mean... a few years of testing would be good.

[4] This is a legitimate complaint about the Kindle Fire. It often appears to not be listening. I get that a lot.

[5] I'm not making this up. This guy actually calls himself "the Tall Guy".  Someone has to be pretty full of himself to select a moniker like that! John the Math Guy would never do that. 

Saturday, December 1, 2012

Quantification of my post on tides

I was asked a quite reasonable question on my post about tides. Azmat Hussain posted the question to my blog and on LinkedIn. Here is what he had to say on LinkedIn:

"I liked your writing style, and but it could have used some mathematics and some quantification. Like how much is the force on the body of water on this side vs the other side, and is the difference significant?"

I like it when people try to keep me honest!  

I looked on Wikipedia to get some rough numbers. The perigee and apogee of the Moon (closest and farthest points from the Earth) are 362,570 km and 405,410 km. Let's just say that the Moon is 380,000 km away from the Earth when we happen to be looking at the tide. The Earth has a radius of 6,371 km. I'm going to round that to 6,000 km just for ease of reading.

So, here are the numbers that I am going to play with: 374,000 km from the Moon to the closest point on Earth, 380,000 km to the center of the Earth, and 386,000 km to the far side of the Earth. [1]

Next, we throw in out good friend the inverse square law. Someone wrote a very entertaining blog that had something to do with that. It says that the pull of gravity falls off as the square of the distance between two objects. Based on that, I have assembled this table that shows the relative strength of the Moon's pull.

Relative pull
Side closest to Moon
374,000 km
Center of Earth
380,000 km
Side farthest from Moon
386,000 km

So... we have a total swing in gravitational pull of 6%. Wow. I was actually expecting a smaller number! I think this proves this is a huge effect, right? [2] And it also explains the whole monthly weight gain problem that women complain about. It's not bloating, ladies. It's the gravitational effect of the Moon!

But, then again, this isn't the whole story. I am talking about the gravitational pull of the Moon. Isn't that tiny? Who cares if it is varies, if it is too small to measure?

Hmmm... If I am standing on the Earth, how does the gravitational pull of the Moon compare to the gravitational pull of the Earth? The gravitational pull goes as the square of the distance. I am 6,000 km from the center of the Earth and 380,000 km from the Moon, so we are talking (6000 / 380,000) squared, which is about 0.025%.

Wait!! That's only a part of the answer, since gravitational pull also goes as the product of the masses, that is, the product of my mass with that of the Earth, and the product of my mass with that of the Moon. My mass is the same, so relatively speaking, we can just look at the relative masses of the Moon and Earth.

The Moon is about 7 X 10^22 kg, and the Earth is about 6 X 10^24 kg. The ratio here is about 1.2%. 

So, I conclude that the gravitational pull of the Moon is on the order of 0.025% X 1.2% of the pull of the Earth. If I am using my calculator correctly, I cipher this out to about 3 parts in a million.

I have gone through the whole calculation below.

Relative pull
Pull relative
to the Earth
Side closest to Moon
374,000 km
3.00 X 10-6
Center of Earth
380,000 km
2.91 X 10-6
Side farthest from Moon
386,000 km
2.82 X 10-6

Wow. I was actually expecting a larger number! I think this proves that the Moon has a negligible effect, right? 

Then again, this effect is tiny, but we are talking about tides of a few meters... just a tiny distance compared with 380,000 km, about 5 parts per billion.

Azmat has asked a very reasonable question. At this point, I am afraid I must shrug my shoulders and say "flies walk on the ceiling". I say this whenever I am confronted with a problem that is orders of magnitude outside of where I normally live.When I make this comment about flies, I mean that the glue on the foot of a fly that holds it to the ceiling is tiny in my experience, and big for a fly. Alternately, gravity is a pretty big deal for me, but flies seem to be able to take it or leave it.  

My next inclination would be to put together an experiment to test the hypothesis. I would measure some tides with the Moon in place where it is, and then remove the Moon and measure the tides again. Simple experiment, really. Maybe I would repeat it a few times. I have applied for a grant to the NSF. Right now, it's hung up on the "romantic impact assessment". Some silly folks are concerned that the removal of the Moon might have a negative impact on the mating habits of homo sapiens. Darn tree huggers! I'll let you know when I hear back from the NSF.

Seriously, my next approach would be a computer simulation in which I modeled the Earth as a thousand little balls. Each ball would be given an initial position and direction vector. They would move through space under the effects of momentum and gravity, and subject to the constraint of non-compenetrability [they can't occupy the same space). Simply enough to write the code, right? (John rolls his eyes.)

In the mean time, I think that Azmat has provided a significant question about insignificance.

[1] A thought occurred to me when I was figgering those numbers. I have made the assumption that perigee and apogee mean the distance between the centers of the Earth and whatever satellite  we are talking about. I wasn't sure about that, so I went to look it up on Wikipedia:

"An apsis ... is the point of greatest or least distance of a body from one of the foci of its elliptical orbit. In modern celestial mechanics this focus is also the center of attraction, which is usually the center of mass of the system. Historically, in geocentric systems, apsides were measured from the center of the Earth."

Uh-oh. Things are getting complicated. I'm gonna stick with the geocentric model.

[2] Rule number 1 about reading John the Math Guy blogs. When I end a statement with "right?" it means that it's not right.

[3] This footnote is not referred to in the main text, but I thought I should put it in for completeness.

Wednesday, November 28, 2012

A Tidey Question

First question - Why are there tides?

The connection between the Moon and Sun to tides has been known at least since 150 BC. Seleucus was the ancient Greek go-to guy on tides. He knew that the Moon was in control of tides, but he thought the interaction was through "pneuma". Pneuma is something that doesn't exist but is all over the place. Pneuma was invented to allow the ancient Greeks to pretend that they understood. In this way, pneuma is akin to aether, phlogiston, electromagnetic waves, dark matter, and my non-existent buddy Horace. I pretend to go out for a beer with him when I don't want to tell my wife where I really am. 

Where am I when I don't want my wife to know where I am? Probably singing an old Righteous Brothers song at a karaoke bar. She is trying to cure me of this addiction. [1]

One of my "go to" karaoke songs when I am in a tidal mood

Posidonius (who lived around 100 BC) was another ancient Greek who was interested in tides. He said that the Moon's effect was because the Moon heated the water enough to make it expand, but not enough to make it boil. The effect of the Moon on tides was, in his mind, proof of astrology. If the effect of the Moon on the entire ocean is so large, then why can't a star that is a zillion miles away have enough of a selective force over my life so as to predestine who I would fall in love with and that I should be a karaoke star? Damn the stars for sentencing me to this unresolvable conflict!

It wasn't until Newton's Philosophiæ Naturalis Principia Mathematica that gravitational forces were singled out as the way the Moon and Sun controlled the tides. That's not such a big surprise, since Newton invented gravity. By the way, gravity didn't exist before July 5, 1687, and neither did tides.

Tides are caused by the gravitational pull of the Moon and the Sun on the water on the water. Gravity is pulling on the solid parts of Earth as well, but the water is free to slosh about. With respect to a point on Earth, the Sun rotates around every 24 hours, and the Moon every 24 hours and 50 minutes. This gives lots of opportunity for them to combine efforts and for them to cancel each other out as the two forces get into and out of phase with each other.

Fun fact #273 - Tidal waves are caused by earthquakes, not tides

Second question - Why are there two tides a day?

Now we have the more difficult question! The simple answer is that the oceans bow out on both sides of the Earth. The side facing the Moon or Sun has high tide, and the side facing away from the Moon or Sun also has high tide. Note that if the Moon is making high tides for me in Milwaukee and for my good friends in India, the Moon is doing nothing for my buddies in England.

Actual unretouched photo of the Earth with some way big tides

I have used a technique here called "answering a hard question with a vague and incomplete answer that really doesn't address the real question." This never worked on my mother, either.

Third question - Why is there a tidal bulge on the opposite side of the Earth?

This third question is the tough question. It almost looks like the Moon's gravitational force is pushing the water on the other side of the planet away. That don't make no sense. I went googling for the answer to this enigma. I found lots of answers. I have tried to arrange them according to similar explanations:

Crazy quirky

Additionally, by a crazy quirk of physics, it also causes the water to dome on the opposite side of the earth.

I will add "crazy quirk" to my list including pneuma, aether, and my non-existent buddy Horace.

Effect of the Sun

BUT, the sun is also pulling at the same time in the opposite direction halfway around the world. This produces two bulges, one near the sun, and one near the moon.

Ummm... so the Sun is always directly opposite the Moon?

Centrifugal force

I found a lot of explanations that call on centrifugal force to explain the bulge on the opposite side.

The centrifugal force produced by the Earth's rotation cause water to pile up on the opposite side as well.

On the side of the earth directly opposite the moon, the net tide-producing force is in the direction of the greater centrifugal force, or away from the moon.

At the centre of the earth the two forces acting: gravity towards the moon and a rotational force away from the moon are perfectly in balance. … On the opposite side of the earth, gravity is less as it is further from the moon, so the rotational force is dominant.

…on the near side the direct pull dominates and causes the oceans to bulge in the direction of the moon; on the far side the centrifugal effect dominates and causes the oceans to bulge in the direction away from the moon.

These explanations are cool, and obvious, right? But, they kinda miss the point. Isn't the centrifugal force pretty much the same all the way around the globe? Why does the water bulge just at the two ends?

It's obvious

This is one of my favorite explanations. Wrap a hard problem in fancy words and then slip in an "it's obvious".

If every particle of the earth and ocean were being urged by equal and parallel forces, there would be no cause for relative motion between the ocean and the earth. Hence it is the departure of the force acting on any particle from the average which constitutes the tide-generating force. Now it is obvious that on the side of the earth towards the moon the departure from the average is a small force directed towards the moon; and on the side of the earth away from the moon the departure is a small force directed away from the moon.

I was with ya until the part about "every particle"

Gravity differential, correct but confusing

Now we come to the real reason for two tides. The pull of gravity is slightly greater on the side of the Earth that faces the Moon as compared with the pull on the side that is opposite the Moon. I'll give my explanation of why this should cause tides in a bit, but first I want to acknowledge some explanations that are correct, but still confusing.

The bulge on the side of the Earth opposite the moon is caused by the moon "pulling the Earth away" from the water on that side.


The not so obvious part is that the water on the far side is getting left behind because the earth is getting pulled away from it.

This sounds like that last explanation that I couldn't understand!

Owing to the differences of distance of the moon from various portions of the earth, the amount of attractive force will be different in different places and tend to produce a deformation.
Van Nostrand's Scientific Encyclopedia, Fourth Edition, 1968, entry on Tides

Ok, so why will it tend to produce a deformation???

And the water which is closer to the moon is pulled more strongly and so it’s pulled up into a tide. The [water] on the opposite side is pulled slightly less strongly and so it’s pulled down less strongly towards the surface of the Earth and so you get a second bulge on the far side of the Earth.

Ummm... it is pulled less strongly... why does that cause a bulge on the opposite side? [2]

The Moon exerts a force on the Earth, and Earth responds by accelerating toward the Moon; however, the waters on the side facing then Moon, being closer to the Moon, accelerate more and fall ahead of Earth. Similarly, Earth itself accelerates more than the waters on the far side and falls ahead of these waters. Thus two aqueous bulges are produced, one on the side of Earth facing the Moon, and one on the side facing away from the Moon.

The Moon is falling! The Moon is falling! We must run and tell the king!

Trophy for best explanation I could find

I won this trophy for my karaoke rendition of Fly Me to the Moon

Here is the explanation that came closest to explaining it for me. I still think it needs work, but this got me thinking along the right track.

The pull is greater on the side facing the Moon, pulling the water there closer to the Moon, while the pull is weaker on the side away from the Moon, making the water there lag behind. This stretches out the Earth and the water on it, creating two bulges.

My own answer

First, gravitational pull decreases with distance. If I am standing directly beneath the Moon, it's tug on me will be larger than the tug I would get if I were on the opposite side of the Earth. This has nothing to do with the Earth getting in the way. It is all about distance.

Now, if I pull really hard on one side of a ball, and pull not quite so hard on the middle, and still a little less on the opposite side, the ball will deform a bit. 

That's the layman's explanation. The answer for a graduate physics exam would probably be a bit more involved. There would be some stuff about the inverse square law [3], and how the Moon and Earth are star-crossed lovers, destined to never meet [4]. Momentum and some crazy stuff about adding vectors of motion together would probably jump out.

But in the end, it's all about stretching.
[1]  I know that, as a blogger, I have a solemn obligation to always tell the truth, but... I lied when I said that my wife is trying to cure me of my karaoke addiction. She has been known to grab the mic herself.

[2] This answer was from the Naked Scientists podcast. Very entertaining. I recommend it. Except they have this thing about trying to make science entertaining. Come on. Science is serious business. Stop making it fun.

[3] This law is on the statutes for Rhode Island. It says that you are not allowed to invert a square on any holidays that involve eating.

[4] The term "star-crossed lovers" comes from Shakespeare in reference to Romeo and Juliet. This is an astrological reference. It means that the stars have thwarted the romance. I think it was very clever of me to slip in another reference to astrology. 


Wednesday, November 21, 2012

The Full Monty

My good buddy Steve from the UK gave me the idea for this week's blog. He suggested that I write about  the "Monty Hall" problem. My first reaction was that this was yet another dumb British idea, like Twiggy, Monty Python, and double-decker buses. What could I possibly have to say that hasn't already been said by a whole bunch of people who are either really smart, or who claim to be really smart?

We have a lot to thank the Brits for

One person who fits into one of those categories is Marilyn vos Savant [1]. She treated the Monte Hall problem in her Parade magazine columns many years ago. As I recall, she caught a lot of flak from a lot of really smart people for giving the wrong answer. So, I know that whatever I say, I will get flak from someone who claims to be smart. 

Monroe or vos Savant? Ginger or Mary Ann?

Then I stopped to think. I was a teenage nerd once, so I kinda like Monty Python. Maybe the Brits do have some good ideas once in a while. Maybe it wasn't such a bad idea for us Americans to send settlers to colonize England a few centuries ago. And maybe it's time for a blog post on the Monte Hall problem. 

The Monte Hall problem

Years ago (oh no, not another "back when I was a kid" lecture) there was a show called Let's Make a Deal, hosted by Monte Hall. For reasons that I was never able to understand, people who showed up in the audience dressed like they were going to a showing of Rocky Horror. Only there weren't quite so many drag queens. Some of the folks with the most outlandish outfits became contestants.And at the end of every show, there was one contestant who got to chose from three doors "behind where Carol Merrill is standing". [2]  

Vanna White's role model

There was always a fabulous prize behind one door, like a boat the size of Lake Michigan or new kitchen filled with a lifetime supply of Spam and some baked beans. The other doors? Goats. Maybe it wasn't always a goat, but that's what I remember. I remember thinking it might be kinda cool to have a goat. Although the lifetime supply of Spam sounds pretty alluring.

What? You don't want me?!?!?

Now we're coming to the fun part. No matter which door the contestant picked, Monty would open a different door, showing a goat, and ask if they wanted to change their choice. What's the best strategy for the contestant? Change or hang on? One line of reasoning says that there are two doors, one with something good, the other with something bad. Fifty-fifty. Why bother changing? Monty is just trying to trick you into changing to the goat.

The other line of reasoning is long and arduous and you have to think and it's hard and ... well, it says that you're chances are better if you change doors. Like... for some reason your probability of picking the fabulous prize has changed from 1 in 3? Or something. Really?

Wikipedia, the world's largest source of misinformation, has an entry on this famous problem. They say that it makes sense to change. They explain this non-intuitive answer in several non-intuitive ways. I am going to add yet another explanation, but first I am going to appear to change the subject.

Monte Carlo methods

Monte Carlo. It brings to mind "shaken, not stirred" and casinos and baccarat. And numerical methods, of course. Well ,maybe not for most people, but certainly for me.

Did you say Monte Carlo methods?

In college, I took a class in Monte Carlo methods. Basically, this is a way of solving numerical problems using random numbers. The first use of this method was back in the days of the Manhattan Project. The guys [3] were working on shielding from neutrons. They could easily explain the path of any particular neutron, but they had trouble finding the equation that would explain what happens to the neutrons in the aggregate as a function of the material and its thickness. They eventually solved the problem by using random numbers to simulate the path of thousands or millions of neutrons - start each simulated neutron out from a random position, moving in a random direction and see where it goes.

The professor for my class, John Halton [4], started us out with a bit of a refresher on probability. He asked us to compute the odds of all the basic poker hands: three of a kind, flush, straight, etc. This is a bit of a tricky problem, not impossible, but it's easy for a kitten like me to get balled up in the combinatorics.

I knew that I was likely to make some sort of mistake, so I decided to double check my answers by doing a little computer simulation. I wrote the code to deal hands at random, and then decide what the hand was. I let my computer play poker overnight, and then checked in the morning to get the results. Sure enough, my simulation revealed that one of my calculations was off by a factor of two. I found my error, and I turned in both the combinatoric solution and the program for my simulation.

This was to be (perhaps) the shining moment of my otherwise drab and wretched college years, since I was never elected class president or homecoming queen. Dr. Halton was tickled that I used a Monte Carlo method for an assignment in a Monte Carlo methods class, and he took part of a lecture to explain how I had double checked my homework.

Actual photo of me basking in the glory of my well-deserved accolades
I was so handsome in those days

I have used this same approach numerous times. Sure, I can derive equations and write them out and solve them. But I have also learned that, despite meticulous double checking, I can still have bone-headed mistakes interspersed with my usual absolutely brilliant analysis. When a problem lends itself to Monte Carlo simulation, I will often use the simulation to double check my answer. 

Finally getting to the point

For those readers who may have forgotten what this Full Monty blog post is about, I have been making Monty Python references to lead up to a discussion about using a Monte Carlo method to solve the Monty Hall problem.

This problem is ideal for Monte Carlo double checking. It is complicated enough that it is easy to talk yourself into some wrong assumptions, but at the heart, it is quite simple to simulate.

1. Randomly decide which of the three doors will conceal the fabulous prize.
2. Randomly select a door for the contestant.
3. Decide which door Monty will show.
4. Switch the contestant to the remaining door - not the one chosen, and not the one opened.
5. Record results.
6. Repeat a zillion times.

It's hard to get balled up in this simulation. Or then again... Some clever mathematical chap might try to get all clever on the algorithm that I have described. For example, someone could "clever this algorithm up" when it comes to step #4. It's a bit hard to put that step into code. But here is something clever. Let's say that the door picked is 2, and the door opened is 3. Subtract those from 6, and what do you get? 6 - 2 - 3 = 1. This is the remaining door. This always works. Clever, eh? I'm rather proud of it.

This cute image has little to do with the rest of this blog

A clever mathematical chap might be tempted to use this trick on #3 as well. Unfortunately this would be a bug. It works when the contestant picks a door with a goat behind it, but not when he picks a door with the yaught.

If you feel tempted to simplify the problem in this way, then please slap your face. The idea of trying to apply clever mathematical analysis completely defeats the purpose of using Monte Carlo to check your work. The whole point to using this technique is to avoid falling into the trap of outclevering yourself.


Here is the test. I have assumed (just for the sake of simplifying this discussion) that the probability of winning a yacht is one in three if the contestant does not switch. I wrote some code to simulate what would happen if the contestant switched every time.

The program that I wrote is listed at the end of this blog post. I make no claims that this is the most efficient way to write the code. In fact, I intentionally focused on making the code as straightforward as possible. Oh... also... I do most of my programming in Mathematica. I'm not going to apologize for that. I realize there are probably some Matlab users reading this. Well... I have been using Mathematica since 1985. So there.

I ran the program once, with 100 iterations, and got 66 yacht and 34 goats. This sounds convincing. The number of yachts is much closer to 2/3 than 1/3. But, this is statistics, so I could easily get thrown off. I could solve that by upping the number of iterations to one thousand or one million. This should give me a better estimate of the odds, but I really don't know much about the dependability of my estimate.

I have a cleverer trick. How about I run this program with 100 iterations ten times. The experiment will have been run with a total of 1,000 contestants, but I would have them partitioned off in groups of 100. This gives me an idea of the range of the estimates. 

Here are the number of yachts that were won in each batch of 100: 67, 71, 60, 66, 65, 61, 68, 61, 61, and 66. The mean is 64.70 and the standard deviation is 3.59. I am going to take a big leap now, and propose that this distribution is roughly normal [5]. If that is the case, then the number of yachts won per hundred has a 95% chance of being between 57.52 and 71.88. (I have gone two standard deviation units to either side.) I have no idea where I am going to park all those yachts.

Now I need to be careful in how I say this next bit. The range (57.52 to 71.88) is the range for the number of goats per hundred. It is not the range for my overall estimate of the mean. The mean was based on a total of 1,000 trials, so clearly the range must have gotten smaller. 

The rule is that when you run n trials, the standard deviation goes down by a factor of square root of n. I ran ten trials, so the range has been reduced by a factor of just over 3. I know then that the average number of yachts won per hundred trials is then  62.43 to 66.97, with a 95% confidence. 

Based on that, I can safely exclude the possibility that there is no advantage to switching. Also, I can't exclude the possibility that the probability of winning when you switch is 2 in 3. 

Another application

This is a technique that I use frequently to double check my algebra. I plan on using it shortly when I do some further investigation on the distribution of ΔE values. I am wondering about the theoretical distribution. Some have called it a chi-squared function. I think that the distribution of  ΔE squared might be chi-squared, but I can test this. And I should, because I know I often get myself balled up.

[1] What kind of a name is that anyway? Who calls themselves "savant"? I mean really, I would never call myself John the Savant Guy!
[2] Carol Merrill was born in Wisconsin. John the Math Guy was born in Wisconsin. Draw your own conclusions.

[3] You know, the same old guys. Stanislaw Ulam, Nicholas Metropolis, Enrico Fermi, and my idol, John von Neumann. I have all their baseball cards.

[4] John Halton was from England, by the way. Oxford. Cambridge. All that rot. I do not know whether he knew John Cleese or Eric Idle. He did come into class one day, telling us how just a sprinkle of water mixed in with the beaten eggs made the fluffiest of omelets, though.

[5] This is another important discussion - whether you can assume that a distribution is normal - but I will leave that for another blog post.

The program (in Mathematica)
yaughts = 0;
goats = 0;
Do [
  (* pick door for yaught and contestant pick, randomly and independently *)
  yaughtdoor = Random  [Integer, {1, 3}];
  pickdoor = Random  [Integer, {1, 3}];
  (* assemble list of doors that Monty can open *)
  freetoopen = {};
  Do [
    If [
      (door ≠ pickdoor) && (door ≠  yaughtdoor),
      AppendTo [freetoopen, door]
    {door, 1, 3}];
  (* let Monty pick from the door(s) available *)
  If [Length [freetoopen] == 1,
    opendoor = freetoopen [[1]],
    opendoor = freetoopen [[Random [Integer, {1, 2}]]]
  (* determine the remaining door that contestant can pick *)
  Do [
    If [
      (door ≠ pickdoor) && (door ≠  opendoor),
      newpick = door
    {door, 1, 3}];
  (* evaluate results *)
  If [
    newpick == yaughtdoor,
Print ["Yaughts and goats: ", {yaughts, goats}]