Initial working version -- needs man page and accuracy testing
Checked calculation accuracy to better than 1%