In comp.lang.java.programmer message <trigonometric-Java-
20080103160235@ram.dialup.fu-berlin.de>, Thu, 3 Jan 2008 15:03:25,
Stefan Ram <ram@zedat.fu-berlin.de> posted:
> ›x87 fsin/fcos use a particular approximation to pi, which
> effectively means the period of the function is changed,
> which can lead to large errors outside [-pi/4, pi/4]. [...]
> What we do in the JVM on x86 is moderately obvious: we
> range check the argument, and if it's outside the range
> [-pi/4, pi/4] we do the precise range reduction by hand,
> and then call fsin. So Java is accurate, but slower.‹
Where does the argument commonly come from?
The only case I know of in which arguments of many times pi appear is in
calculating the phase of a waveform using something like
2 pi J / N
In that case one should, ISTM, first subtract from J whichever multiple
of N gives a result in [0, 1) or (-0,5, +0.5] or similar.
Of course, that needs an intelligent application programmer, rather than
an intelligent system programmer.

Signature
(c) John Stockton, Surrey, UK. *@merlyn.demon.co.uk / ??.Stockton@physics.org
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Correct <= 4-line sig. separator as above, a line precisely "-- " (SoRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)