summaryrefslogtreecommitdiffstats
path: root/lib/msun/src/k_sinf.c
blob: d393db7092afd519f7f36e8f50d75eba1b67c606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* k_sinf.c -- float version of k_sin.c
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
 * Optimized by Bruce D. Evans.
 */

/*
 * ====================================================
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 *
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * is preserved.
 * ====================================================
 */

#ifndef lint
static char rcsid[] = "$FreeBSD$";
#endif

#include "math.h"
#include "math_private.h"

/* |sin(x)/x - s(x)| < 2**-32.5 (~[-1.57e-10, 1.572e-10]). */
static const float
half = 0.5,
S1  = -0xaaaaab.0p-26,		/* -0.16666667163 */
S2  =  0x8888bb.0p-30,		/*  0.0083333803341 */
S3  = -0xd02de1.0p-36,		/* -0.00019853517006 */
S4  =  0xbe6dbe.0p-42;		/*  0.0000028376084629 */

float
__kernel_sinf(float x, float y, int iy)
{
	float z,r,v;

	z	=  x*x;
	v	=  z*x;
	r	=  S2+z*(S3+z*S4);
	if(iy==0) return x+v*(S1+z*r);
	else      return x-((z*(half*y-v*r)-y)-v*S1);
}
OpenPOWER on IntegriCloud