Coloring numbers

Attaching units to numbers reduces the chance of mistakes. For example, if you’re about to add 3 pounds to 7 feet, you’ve probably done something wrong. (The result would be 10 what?) In engineering, this is called “dimensional analysis.”

In computer science, the analogous discipline is strong typing. In strongly typed programming languages, a function that expects a floating point number will complain bitterly if you pass in a JPEG image instead.

When I’m doing math, I’ll sometimes start out with back-of-the-envelope scribbling until I start getting confused. Often the way out of my confusion is to be explicit about function domains and ranges, very much like strong typing in programming.

But sometimes natural typing isn’t enough, and it helps to create artificial distinctions. For example, torque and work both have units of force times distance, but it would be a mistake to add torque and work.

Sometimes it helps me to imagine numbers having different colors. Say I’ve got a function f(x) and I imagine that it takes in red numbers and produces blue numbers, while another function g(x) takes in blue numbers and produces green numbers. That helps me keep straight that expressions like g(f(x)) are OK, but expressions like f(x) + g(x) are probably not.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>