Saturday, September 25, 2010

Mirages

I'm sure you've seen something like this before.  It looks like there's water on the road, but there's not. It's a mirage.  Why does this happen?  I never knew why until I read Perfect Form, the book I talked about in my last post.

Before I can explain mirages, I need to explain something that French mathematician Pierre de Fermat proposed in 1662 called the Principle of Least Time.  (Actually, Fermat was a lawyer by trade, and just did math on the side.  But these days, people remember him mainly for his math.)

The Principle of Least Time is pretty simple, actually.  All it says is that light takes the fastest path to get from point A to point B.  Now, it turns out that light goes faster through hot air than cold air.  (Why that is, we'll leave for another day.)  In the picture above, the hot asphalt is heating the air above the road.  So the closer a beam of light is to the road, the faster it will be able to reach your eye.  In other words, a beam of light will naturally want to "hug the road".  The diagram above shows a similar situation where the hot desert sand is heating the air above.

(As an aside, you might wonder how a beam of light "knows" the fastest path.  To determine its path, doesn't it need to know its destination?  Is there a higher Intelligence at work?  These are questions for another post.)

So let's take another look at that photo of the road mirage.  Imagine you are there, looking at the car on the left.  What does it mean to "look at" the car?  It means a beam of light is traveling from point A (the car) to point B (your eye).  What path will that beam of light take?  Well, it might go in a straight line, but then it would be wasting a lot of time traveling through cooler air.  Remember, light can travel faster close to the hot road.  So wouldn't it take less time overall if the beam of light first moved itself down close to the road, then traveled low to the road for most of the distance, and then at the end bent upward to meet your eye?  That's exactly what happens, as illustrated (way out of scale) by the diagram above of the guy in the desert.  See, when the light bends upward to your eye, your eye doesn't know what kind of convoluted path it took.  Your brain just processes the beam of light as if it went in a straight line all along.  So, looking at the photo again, your eye sees an image of the car below where it really is.  It looks like it's reflected in the road.  The road must be wet!  That's the mirage.

Now, I could stop right here, and hopefully it would all sort of make sense.  And yet we've done no math.  That's the thing about math.  Sometimes, you can get the gist of an interesting fact about the world we live in without any math at all.  If you wanted to explain to your curious child why mirages happen, the non-mathematical explanation above would probably get you as far as you need to go.  But if your job was to determine the exact distance from the viewer of the fake car reflection, given precise assumptions about the temperature gradient with altitude, then you'd need to find yourself some math.

Enter the calculus of variations, the subject of Perfect Form.  To understand this part of my post, you need some appreciation of plain old high school calculus.  You might remember from your calculus class that a lot of the problems went something like this.  Given some function f(x), find the point where it reaches a minimum or maximum value.  To do this, you first figure out the derivative f'(x) of f(x) and then find the values of x that make f'(x) = 0.  The example above shows a curving function with two points where its derivative is 0 (flat).  In this example, the function reaches a minimum when x = -6.

To solve our mirage problem, we need something like this.  Just like the high school calculus problem above, we're looking for a minimum.  We need to find the path from point A (distant car) to point B (eye) that minimizes the time it takes light to travel from point A to point B.  The key difference here is that we need to find a path that minimizes a value (time, in this case), not a number that minimizes a value.  How can we do this?  Take the derivative over paths instead of over numbers?  In a sense, yes.  But what does this mean?  And whatever it means, how can it be done when we don't even know what the shape of the path looks like?  (Is it a polynomial?  Is it sinusoidal?  Something else?  We can't assume.)  That is the calculus of variations.  The diagram above gives some intuition about it.  The minimum path is shown in red, and the green paths differ from the red path by a delta function v(x) -- rather than a delta number as in regular calculus.

The calculus of variations is quite elegant and quite powerful, and I'm really glad I took the week to read Perfect Form.  Once you understand the techniques in that book, not only will you be able to "do the math" on the mirage problem, but you will feel the power of having the keys to a much larger kingdom.  For example, did you know that under certain initial conditions, the path of light through a fiber optic cable is a series of alternating half-circles?  This is shown pictorially on the cover of Perfect Form.  If you have some basic appreciation for differential equations and a basic knowledge of first-year physics, you should be able to get a lot out of the book.

By the way, the road mirage is called an inferior mirage because the light bends up to the eye from below, making the mirage appear below the true object.  There is also the possibility of a superior mirage when the temperature gradient is reversed -- when the hot air is higher than the cold air.  This often happens over water.  Whereas hot asphalt or hot sand warms the air near the ground, water often cools the air close to it.  This can produce some wacky effects, hinted at in the diagram above.  Boats or even whole cities can float upside down in the air.

Here is a picture of this effect in action -- a large ship that appears reflected in the sky. With superior mirages, it's also sometimes possible to see over the horizon -- a reflected image of something that's already disappeared beyond the curvature of the earth. Our understanding of these phenomena traces back to Fermat in 1662.

Perfect Form

I spend too much time on Facebook.  But every time I'm about to cancel my account there, something pops up that demonstrates to me again that Facebook really does add value to my life.  This happened most recently six weeks ago, the day before our family vacation, when my friend Doug Tygar made a post recommending introductory books on the calculus of variations.  I had never even heard of the calculus of variations before, but I know that Doug has impeccable taste, so I used my Amazon Prime membership to have his top-ranked book shipped to our vacation destination so it would be waiting for me when I got there the next day.  It turns out that the calculus of variations is really interesting, and something I wouldn't normally have come across.  More about the calculus of variations in a future post, perhaps.

Our vacation, by the way, was at my parents' house on Smith Mountain Lake in Virginia.  And the book that Doug recommended was Perfect Form by Don Lemons.

I really liked Perfect Form.  It explains how light takes the quickest path and moving objects take the path of least work.  The examples along the way were interesting, such as why you see a mirage in the desert and how fiber optics work.  I was impressed with the simplicity and elegance of the approach, and Lemons's exposition was a model of clarity.  Sadly, it's a bit too advanced to have been covered in my freshman physics classes in college.  And since I didn't continue on in physics, I never had occasion to learn about this stuff -- or even learn about the existence of this stuff -- in the 24 years since.  I turned 42 on our vacation.

My wife Phyllis and I have two kids.  Benjamin is 6, and Cassandra is 2.   Benjamin is developing a strong interest in science.  He dissected a squid in a tide pools class he took this summer at the UC Berekeley Academic Talent Development Program.  A few nights ago, he couldn't get to sleep because he was anxious about something, and I calmed him down by showing him pictures of leaf veins and explaining what purpose they serve.  I think having kids has given me a renewed interest in learning a bunch of stuff about the world that I missed the first time around.  This blog is going to be about that journey.

This brings me back to Facebook.  Reading books and learning things takes time, especially in a two-career two-child household.  Facebook was sucking up too much of my time.  So, courtesy of my colleague Max Poletto, I added these entries to my /etc/hosts file yesterday:
127.0.0.1    facebook.com
127.0.0.1    www.facebook.com
For anyone reading this who isn't into computers, this will effectively block me from accessing Facebook.  I feel better already.