Tuesday, November 23, 2004

Terence, this is stupid stuff

I just added a Robosapien and a USB aquarium to my ThinkGeek wish list. I don't understand my desire for such items. But I do understand that I must have them.
Read more...

Wednesday, November 17, 2004

Temperature Conversion

Here's a bit I caught in a West Wing rerun yesterday:
Bartlet: Stevie, fourth grader, PS 31, Manhattan, asks, "What is the temperature on Mars?" Well, Stevie, if one of our expert panelists were here, they would tell you the average temperature ranges from 15 degrees to minus 140.

C.J.: That happens to be wrong. It ranges from 60 to minus 225.

Bartlet: I converted it to Celsius in my head.
I've been reasonably good at converting from Celsius to Fahrenheit (and back) for quite a while, and I'm generally able to obtain a good approximation in my head in a minute or so. But that scene made a minute feel like a really long time. Within 5 minutes of seeing this, I came up with a fast and accurate method for doing temperature conversion in my head.

Fahrenheit to Celsius

The formula for converting degrees Fahrenheit to degrees Celsius is
(5/9)(degF - 32)
which is handily approximated as half of (degF - 32). If you fudge up a little bit from the halfway mark, you can get closer, but you have to have a good feel for what "a little bit" is. If we quantify "a little bit", we discover that the resulting computation is no harder than dividing by 2.

First off, notice that
5/9 = 0.55555...
So we can get reasonable everyday precision by recasting the above formula as
(0.55)(degF - 32)
which is the same as
(0.5)(degF - 32) + (0.05)(degF - 32)
or
(0.5)(degF - 32) + ((0.5)(degF - 32)) / 10
That last bit about dividing by 10 is, of course, simply a shift of the decimal point to the left. What this boils down to is that if you can subtract 32 and divide by 2 in your head, you can do the math very quickly. As an example, here's the conversion of 60F to Celsius:
60 - 32  = 28

28 / 2 = 14
14 / 10 = 1.4
14 + 1.4 = 15.4
So 60F = 15.4C. And you can get better and better precision by continuing to add fractions (keep shifting the decimal point on that 14 and adding to the result):
0.5 * 28     = 14

0.55 * 28 = 14 + 1.4 = 15.4
0.555 * 28 = 14 + 1.4 + 0.14 = 15.54
0.5555 * 28 = 14 + 1.4 + 0.14 + 0.014 = 15.554

Celsius to Fahrenheit

The formula for converting degrees Fahrenheit to degrees Celsius is
9/5 * degC + 32
which is handily approximated as twice degC plus 32. You can fudge down a little bit to get closer, but, as with the conversion in the opposite direction, quantifying "a little bit" leads to a simple and more accurate method:
9/5 = 1.8

= 1 + 0.8
= 2 - 0.2
By using the final recast of the constant, we capitalize on a single computation (doubling) along with a decimal point shift. Let's see what our formula looks like now:
9/5 * degC + 32 = (1.8)(degC) + 32

= degC + (0.8)(degC) + 32
= (2)(degC) - (0.2)(degC) + 32
So converting from Celsius to Fahrenheit effectively requires that you be able to double a number and add 32 in your head (you also have to be able to subtract that fraction, but if you can add 32, that shouldn't be a problem). Let's try converting 22C to Fahrenheit:
2 * 22        = 44

44 - 0.2 * 22 = 44 - 4.4
= 39.6
39.6 + 32 = 71.6
There's no repeating decimal here, so this is as precise as you can get.
Read more...