Yes, I keep telling Jens that the right way to do trig functions in degrees is to start by converting the angle in degrees to something in the range [0, 45], which may involve swapping sin with cos and may involve changing the sign of the eventual result, then multiply by π/180, which is how Prof. Kahan says to do it, but he (Jens) doesn't believe me that it matters.
It seems as if such a small error would not matter, but the problem is not that is an error of 10^-16 at an arbitrary number, but the fact that sin(0) is not 0, which is a known value. For example would never report true, even though it is within one quadrillionth of 0.
Here is what I learned in my computer science course: when using floating-point arithmetic, check for close enough, not equality.
Instead of [scratchblocks]<(number) = (what I want)>[/scratchblocks],
do [scratchblocks]<([abs v] of ((number) - (what I want))) < [0.001]>[/scratchblocks].
Sorry, I meant to say that sin of 180 is not 0:
Yeah I knew that, just not quite awake. Sorry. But my answer about how to compute trig functions of angles in degrees still stands.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.