Bug 13852 - sincosf(), sinf(), cosf(), tanf() are incorrect for large inputs on x86
Summary: sincosf(), sinf(), cosf(), tanf() are incorrect for large inputs on x86
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.15
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: glibc_2.15
Depends on: 13658 15563
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-15 13:43 UTC by Andreas Jaeger
Modified: 2014-06-26 13:57 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Jaeger 2012-03-15 13:43:48 UTC
+++ This bug was initially created as a clone of Bug #13658 +++

sincosf() is inaccurate for large inputs on x86_64: with glibc 2.13,

#define _GNU_SOURCE
#include <stdio.h>
#include <math.h>

int main (void)
{
  volatile float x = 1.0e22;
  float s1, s2, c1;

  sincosf (x, &s1, &c1);
  s2 = sinf (x);
  printf ("s1 = %.17g\n", s1);
  printf ("s2 = %.17g\n", s2);
  return 0;
}

outputs:
s1 = 0.28122705221176147
s2 = 0.28122705221176147

Correct value:
0.85220084976718879
Comment 1 Andreas Jaeger 2012-03-15 14:56:58 UTC
This applies to sinf, cosf, tanf and sincosf.
Comment 2 Andreas Jaeger 2012-03-15 15:47:20 UTC
This applies only to x86 - and better use 0x1p65 as exact input value, the result is: 0.047236487235904796.
Comment 3 Andreas Jaeger 2012-03-15 17:06:13 UTC
Fixed in git head:
2012-03-15  Andreas Jaeger  <aj@suse.de>

	[BZ #13852]
	* sysdeps/i386/fpu/e_rem_pio2f.c: Delete so that i386 uses the
	ieee754/flt-32 implementation for sin, cos and sincos.
	* sysdeps/i386/fpu/k_rem_pio2f.c: Likewise.
	* sysdeps/i386/fpu/s_cosf.S: Likewise.
	* sysdeps/i386/fpu/s_sincosf.S: Likewise.
	* sysdeps/i386/fpu/s_sinf.S: Likewise.
	* sysdeps/i386/fpu/s_tanf.S: Delete so that i386 uses the
	ieee754/flt-32 implementation for tan.

	* math/libm-test.inc (cos_test): Enable some large input tests for
	float as well
	(sin_test): Likewise.
	(sincos_test): Likewise.
	(tan_test): Add tests for large input.

	* sysdeps/i386/fpu/libm-test-ulps: Update.