Transcendental Two [updated]

What is especially ironic is that if you grep through piles of source code you'll find a huge number of calls that look roughly like sin(angle*(2*Math.PI/360)). This has a necessarily slightly inaccurate value of pi, which is likely to be exactly the same value as the one in the 8087's sin/cos implementation - the two errors come pretty close to canceling since the argument is divided by the value of pi used in the implementation of sin/cos.
Update: Yes, I understand that there are lots of deep, important mathematical reasons that sin & cos are defined in terms of 2*pi. The point I was trying to make is that if you peel open the covers of an implementation of sin/cos, 2*pi is a very difficult period to cope with. At the same time, if you look at software that uses sin/cos, you'll find that a huge fraction of them use something other than 2*pi (degrees are real common), and convert when invoking sin/cos.
August 1, 2005 |