From http://rachel53461.wordpress.com/2011/08/20/the-math-converter/