17. iPhones and the Butterfly:
Mathematics is precise. So are hand calculators and computers. Whenever you perform a mathematical operation and then perform the inverse operation, you obtain the initial number. For example, divide 10 by 3, and then mutiply the result by 3 and you will again get 10, as you should. Take the square root of 2.0, then square the result and you again get 2.0. And, of course, whenever you repeat a computation on a computer, precisely the same answer must result every time.
Well, no, not always!
Take any old hand-held calculators. Make sure that it has buttons for “square” and “square root”. Type in the number 10, hit the “square root” key, and then hit the “square” key. Not surprisingly, the number 10 appears on the display. After all, the square of the square root of 10 is 10. Try again, but this time hit the “square root” button thirty times in a row, and then hit the “square” button thirty times in a row. You should again obtain 10 as an answer. But brace yourself. This time the output shows something like 9.5338764.
Maybe you could not get ahold of an old calculator. So let’s try something really modern, like the calculator app on an iPhone. It is much more sophisticated, of course, as evidenced by the fact that – when held in landscape mode – it displays sixteen digits on the screen, twice as many as the old calculators. But now consider this: enter the number 123,456,789, hit the ‘square root’ button just once, and then hit the ‘square’ button once. Unsurprisingly, the screen displays the identical 9-digit number. But now deduct the original 123,456,789 from this result. You will not see a zero, as you may have expected, but something like ‘2e-25’. What this means is that the real result, stored in the iPhone’s innards, is 123456789.0000000000000000000000002. Granted, the error is minute, it only appears at the 25th digit after the decimal point. But an error it is nonetheless.
What about desktop and laptop computer? Let’s put the question to the test and start up a spreadsheet, like Excel®. Enter the number 30 into cell A1 and then enter “=(10^(1/2^A1))^(2^A1)” into cell A2. The answer is 10, as you would expect. Now increase the number in cell A1 to 31. The result is 10.00000004. Strange, but who cares about 0.00000004 anyway? Now be bold and enter 50 into cell A1 and watch what happens. The displayed answer is 9.4877 or something similar! Enter 51, and the answer displayed is 12.1825. Enter 52 or 53, and the displayed answers are, both times, 7.3891. These numbers are nowhere near the correct answer of 10. Enter 55 or any number greater than that and everything goes completely haywire: the displayed answers are 1.0 What happened? Is this a bug?
No, it is not a bug, it’s a feature…well, sort of.
In the early 1960s a meteorologist at MIT, Edward Lorenz, ran a computer program which simulated weather conditions. At one point he jotted down an intermediate result, and then let the simulation continue on to hailstorms, thunder and lightning. Next morning, he started the virtual evolution of weather again from the intermediate result that he had jotted down the previous day. Then he went to the cafeteria for a cup of coffee. Upon the return to the lab, he had a surprise. Instead of the foul weather that he expected in his virtual world, the sun was shining, a soft breeze was blowing and the birds were chirping. (Actually, there were no birds in Lorenz’s simulation, but it sounds nice anyway.) Why did the computer produce completely different weather conditions on the second run even though the same numerical input had been used?
Lorenz’s observation was the first encounter with a phenomenon that was soon to be known as “chaos theory”. When we speak of chaos we generally mean disarray or confusion. In mathematics chaos is often defined as “sensitivity of the outcome to initial conditions”. An ever so slight error or variation in the input may compund itself during subsequent operations, and may even result, sometimes with grave consequences, in a blow up. (See the chapter on /// air disaster)
The day before the fateful occurrence at the MIT lab, Lorenz had jotted down the numbers to three digits after the decimal and then let the computer continue the simulation. The next day, before the coffee break, he entered the initial numbers that he had jotted down. With this he inadvertently truncated the numbers that the computer stored internally to, say, eight digits after the comma, to just three digits. By truncating the numbers, he had changed the initial conditions. And since the weather is very sensitive to these initial conditions, sunshine happened instead of hailstorms.
The reason for the strange results displayed in old hand-held calculators is that they store only between twelve and fifteen digits internally. The minute errors that may arise in digits sixteen and beyond are compounded and after a few dozen iterations the compounded error becomes very noticeable.
iPhones and desktop and laptop computers are more robust but they too are subject to the limitations of digitization. An iPhone displays about twice as many digits as the handheld calculators of yore and stores another sixteen internally without displaying them. 32 digits may seem like a whole lot but even that is not enough. As the example above showed, when the result of just a single mathematical operation is inspected sufficiently closely, an error may show up.
This phenomenon is often called the “butterfly effect”: a butterfly flapping its wings in Brazil can produce a thunderstorm in Florida. Even if the wing-flapping corresponds to a disturbance to the Brazilian air of no more than the 20th digit after the decimal, the disturbance propagates and expands. By the time it reaches the Sunshine State the minute disturbance could have jogged itself up to gale force.
Incidentally, the butterfly effect also has a good side to it. Since a butterfly in Brazil can disturb the serene weather in Florida, the same butterfly could calm a hurricane in Texas by simply flapping its wings in a certain fashion. (Of course, a butterfly in Texas could be counter-flapping, thus causing havoc in Brazil or Florida.) This process is called ‘controlling chaos’ and has even been put to medical use with some success. By applying ever so small electric shocks at precisely the right moment, an erratic heartbeat can be regularized and a heart attack avoided.
Comments, corrections, observations: