In 1.3, the specification for java.lang.Math.{sin, cos} was changed
from an operational definition (use FDLIBM algorithms) to a
declarative one (use any approximation with 1 ulp accuracy and good
monotonicity properties). On x86 platforms, for values smaller in
magnitude than 2^63, effectively the C1 and C2 compilers use the raw
x86 instructions fsin and fcos to implement Math.{sin, cos}. This
does not follow the spec since the 66 bit argument reduction used by
fsin/fcos introduces large deviations from the true values of sine and
cosine for some inputs. Outside of +/-2^63, C1 and C2 use FDLIBM
algorithms which do proper argument reduction. This introduces an
inconsistency in the periodicity of the approximation to sine/cosine.
The solution is to have the Math.{sin, cos} do their own argument
reduction to [-pi/4, pi/4] and then call fsin/fcos; this will
guarantee the specified accuracy and monotonicity properties. The
needed argument reduction functions are already available from FDLIBM,
http://www.netlib.org/fdlibm.
This bug is filed against C1 as bug id 4345903.
from an operational definition (use FDLIBM algorithms) to a
declarative one (use any approximation with 1 ulp accuracy and good
monotonicity properties). On x86 platforms, for values smaller in
magnitude than 2^63, effectively the C1 and C2 compilers use the raw
x86 instructions fsin and fcos to implement Math.{sin, cos}. This
does not follow the spec since the 66 bit argument reduction used by
fsin/fcos introduces large deviations from the true values of sine and
cosine for some inputs. Outside of +/-2^63, C1 and C2 use FDLIBM
algorithms which do proper argument reduction. This introduces an
inconsistency in the periodicity of the approximation to sine/cosine.
The solution is to have the Math.{sin, cos} do their own argument
reduction to [-pi/4, pi/4] and then call fsin/fcos; this will
guarantee the specified accuracy and monotonicity properties. The
needed argument reduction functions are already available from FDLIBM,
http://www.netlib.org/fdlibm.
This bug is filed against C1 as bug id 4345903.
- duplicates
-
JDK-4220710 Java 1.2 trig functions mess up on big values
- Closed
- relates to
-
JDK-4294075 java.lang.StrictMath.cos/sin results are not within 1ulp on Win98
- Closed
-
JDK-4345903 On x86 platforms, C1 Math.{sin, cos} implementations violate the 1.3 spec
- Resolved
-
JDK-4287874 kestrel FCS Build M,Following JCK1.3-RC1 tests failed with java_plugin on win32
- Closed
-
JDK-4807358 REGRESSION: Performance regression in trigonometric functions
- Closed
-
JDK-4306749 java.lang.Math.cos/sin results are not within 1ulp on Win98
- Closed
(1 relates to)