Sunday, December 02, 2007

“Units”

The other day I had to convert the quantity 150 wavenumbers (the inverse of the wavelength of a certain frequency of light) to meV (the energy of a photon of that wavelength, in milli-electron Volts). I have a spreadsheet somewhere that does this, as it has the values of Planck's constant and the speed of light encoded. I could also have gotten the current best value of these constants and done the calculation on a calculator. However, this time I had an epiphany: I opened up a terminal window and entered:

$ units
2438 units, 71 prefixes, 32 nonlinear units

You have: 150 wavenumbers
You want: meV
        * 18.597628
        / 0.053770298

A yes, I'd finally remembered the old unix command units, available in Ubuntu with the command

$ sudo apt-get install units

It's a pretty powerful program. It has some weird roundoff errors, though. For example

$ units
2438 units, 71 prefixes, 32 nonlinear units

You have: 1 mile^2
You want: acre
        * 639.99744
        / 0.0015625063

Instead of 640 acres exactly. But you can ask the age old question of what is the speed of light in a somewhat popular unit:

$ units
2438 units, 71 prefixes, 32 nonlinear units

You have: 299792458 m/sec
You want: furlongs/fortnight
        * 1.8026175e+12
        / 5.5474886e-13

0 comments: