double cos(double x) { double y[2],z=0.0; int32_t n, ix; GET_HIGH_WORD(ix, x); /* |x| ~< pi/4 */ ix &= 0x7fffffff; if (ix <= 0x3fe921fb) { if (ix < 0x3e46a09e) /* if x < 2**-27 * sqrt(2) */ /* raise inexact if x != 0 */ if ((int)x == 0) return 1.0; return __cos(x, z); } /* cos(Inf or NaN) is NaN */ if (ix >= 0x7ff00000) return x-x; /* argument reduction needed */ n = __rem_pio2(x, y); switch (n&3) { case 0: return __cos(y[0], y[1]); case 1: return -__sin(y[0], y[1], 1); case 2: return -__cos(y[0], y[1]); default: return __sin(y[0], y[1], 1); } }
double sin(double x) { double y[2]; uint32_t ix; unsigned n; /* High word of x. */ GET_HIGH_WORD(ix, x); ix &= 0x7fffffff; /* |x| ~< pi/4 */ if (ix <= 0x3fe921fb) { if (ix < 0x3e500000) { /* |x| < 2**-26 */ /* raise inexact if x != 0 and underflow if subnormal*/ FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); return x; } return __sin(x, 0.0, 0); } /* sin(Inf or NaN) is NaN */ if (ix >= 0x7ff00000) return x - x; /* argument reduction needed */ n = __rem_pio2(x, y); switch (n&3) { case 0: return __sin(y[0], y[1], 1); case 1: return __cos(y[0], y[1]); case 2: return -__sin(y[0], y[1], 1); default: return -__cos(y[0], y[1]); } }
/* * complex(kind=8) raised to a real(kind=8) = _CTOR * * x = a+b*i * * if ((x == 0+0*i) && (y == 0)) then return(NAN) * if (x == 0+0*i) then return(0+0*i) * if (y == 0) then return(1+0*i) */ void _CTOR(c_complex_t *ret_val, c_complex_t x, _f_real8 *r) { _f_real8 __atan2(_f_real8 x, _f_real8 y); _f_real8 __cos(_f_real8 x); _f_real8 __exp(_f_real8 x); _f_real8 __log(_f_real8 x); _f_real8 __sin(_f_real8 x); _f_real8 _CABS(c_complex_t z); _f_real8 y = *r; _f_real8 one; _f_real8 two; if (x.real == (_f_real8) 0.0 && x.imag == (_f_real8) 0.0) { if (y == (_f_real8) 0.0) { ret_val->real = _SGL_NaN; ret_val->imag = _SGL_NaN; } else { ret_val->real = (_f_real8) 0.0; ret_val->imag = (_f_real8) 0.0; } return; } one = y * __atan2(x.imag, x.real); two = y * __log(_CABS(x)); ret_val->real = __exp(two) * __cos(one); ret_val->imag = __exp(two) * __sin(one); }
static double sinpi(double x) { int n; /* argument reduction: x = |x| mod 2 */ /* spurious inexact when x is odd int */ x = x * 0.5; x = 2 * (x - floor(x)); /* reduce x into [-.25,.25] */ n = 4 * x; n = (n + 1) / 2; x -= n * 0.5; x *= pi; switch (n) { default: /* case 4 */ case 0: return __sin(x, 0, 0); case 1: return __cos(x, 0); case 2: return __sin(-x, 0, 0); case 3: return -__cos(x, 0); } }
void sincos(double x, double *sin, double *cos) { double y[2], s, c; uint32_t ix; unsigned n; GET_HIGH_WORD(ix, x); ix &= 0x7fffffff; /* |x| ~< pi/4 */ if (ix <= 0x3fe921fb) { /* if |x| < 2**-27 * sqrt(2) */ if (ix < 0x3e46a09e) { /* raise inexact if x!=0 and underflow if subnormal */ FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); *sin = x; *cos = 1.0; return; } *sin = __sin(x, 0.0, 0); *cos = __cos(x, 0.0); return; } /* sincos(Inf or NaN) is NaN */ if (ix >= 0x7ff00000) { *sin = *cos = x - x; return; } /* argument reduction needed */ n = __rem_pio2(x, y); s = __sin(y[0], y[1], 1); c = __cos(y[0], y[1]); switch (n&3) { case 0: *sin = s; *cos = c; break; case 1: *sin = c; *cos = -s; break; case 2: *sin = -s; *cos = -c; break; case 3: default: *sin = -c; *cos = s; break; } }
/* * CSIN - complex(kind=8) - pass by value * * Semantics: sin(z) = sin(a)*cosh(b) + cos(a)*sinh(b)*i * (where z = a + b*i) */ void _CSIN(c_complex_t *ret_val, c_complex_t z) { _f_real8 __cos(_f_real8 x); _f_real8 __cosh(_f_real8 x); _f_real8 __sin(_f_real8 x); _f_real8 __sinh(_f_real8 x); ret_val->real = __sin(z.real) * __cosh(z.imag); ret_val->imag = __cos(z.real) * __sinh(z.imag); }
void _CHCOS( h_complex_t *ret_val, h_complex_t z ) { _f_real8 __cos(_f_real8 x); _f_real8 __cosh(_f_real8 x); _f_real8 __sin(_f_real8 x); _f_real8 __sinh(_f_real8 x); _f_real8 real = (_f_real8) z.real; _f_real8 imag = (_f_real8) z.imag; ret_val->real = (_f_real4) (__cos(real) * __cosh(imag)); ret_val->imag = (_f_real4) (- (__sin(real) * __sinh(imag))); }
void _CHEXP(h_complex_t *ret_val, h_complex_t z ) { _f_real8 __exp(_f_real8 x); _f_real8 __cos(_f_real8 x); _f_real8 __sin(_f_real8 x); _f_real8 real = (_f_real8) z.real; _f_real8 imag = (_f_real8) z.imag; _f_real8 realtmp = __exp(real); ret_val->real = (_f_real4) (realtmp * __cos(imag)); ret_val->imag = (_f_real4) (realtmp * __sin(imag)); }
static ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect) { ALechoState *state = (ALechoState*)effect; ALuint frequency = Context->Device->Frequency; ALfp lrpan, cw, a, g; state->Tap[0].delay = (ALuint)ALfp2int((ALfpMult(Effect->Echo.Delay, int2ALfp(frequency)) + int2ALfp(1))); state->Tap[1].delay = (ALuint)ALfp2int(ALfpMult(Effect->Echo.LRDelay, int2ALfp(frequency))); state->Tap[1].delay += state->Tap[0].delay; lrpan = (ALfpMult(Effect->Echo.Spread, float2ALfp(0.5f)) + float2ALfp(0.5f)); state->GainL = aluSqrt( lrpan); state->GainR = aluSqrt((int2ALfp(1)-lrpan)); state->FeedGain = Effect->Echo.Feedback; cw = __cos(ALfpDiv(float2ALfp(2.0*M_PI * LOWPASSFREQCUTOFF), int2ALfp(frequency))); g = (int2ALfp(1) - Effect->Echo.Damping); a = int2ALfp(0); if(g < float2ALfp(0.9999f)) { /* 1-epsilon */ // a = (1 - g*cw - aluSqrt(2*g*(1-cw) - g*g*(1 - cw*cw))) / (1 - g); a = ALfpDiv((int2ALfp(1) - ALfpMult(g,cw) - aluSqrt((ALfpMult(ALfpMult(int2ALfp(2),g),(int2ALfp(1)-cw)) - ALfpMult(ALfpMult(g,g),(int2ALfp(1) - ALfpMult(cw,cw)))))), (int2ALfp(1) - g)); } state->iirFilter.coeff = a; }
static double sin_pi(double x) { double y,z; int n,ix; GET_HIGH_WORD(ix, x); ix &= 0x7fffffff; if (ix < 0x3fd00000) return __sin(pi*x, 0.0, 0); y = -x; /* negative x is assumed */ /* * argument reduction, make sure inexact flag not raised if input * is an integer */ z = floor(y); if (z != y) { /* inexact anyway */ y *= 0.5; y = 2.0*(y - floor(y)); /* y = |x| mod 2.0 */ n = (int)(y*4.0); } else { if (ix >= 0x43400000) { y = 0.0; /* y must be even */ n = 0; } else { if (ix < 0x43300000) z = y + two52; /* exact */ GET_LOW_WORD(n, z); n &= 1; y = n; n <<= 2; } } switch (n) { case 0: y = __sin(pi*y, 0.0, 0); break; case 1: case 2: y = __cos(pi*(0.5-y), 0.0); break; case 3: case 4: y = __sin(pi*(1.0-y), 0.0, 0); break; case 5: case 6: y = -__cos(pi*(y-1.5), 0.0); break; default: y = __sin(pi*(y-2.0), 0.0, 0); break; } return -y; }
void __sincos (double x, double *sinx, double *cosx) { SET_RESTORE_ROUND_53BIT (FE_TONEAREST); *sinx = __sin (x); *cosx = __cos (x); }
double __ieee754_y1(double x) { double z, s,c,ss,cc,u,v,u1,u2,v1,v2,v3,z2,z4; int32_t hx,ix,lx; EXTRACT_WORDS(hx,lx,x); ix = 0x7fffffff&hx; /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ if(__builtin_expect(ix>=0x7ff00000, 0)) return one/(x+x*x); if(__builtin_expect((ix|lx)==0, 0)) return -HUGE_VAL+x; /* -inf and overflow exception. */; if(__builtin_expect(hx<0, 0)) return zero/(zero*x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ __sincos (x, &s, &c); ss = -s-c; cc = s-c; if(ix<0x7fe00000) { /* make sure x+x not overflow */ z = __cos(x+x); if ((s*c)>zero) cc = z/ss; else ss = z/cc; } /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) * where x0 = x-3pi/4 * Better formula: * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) * = 1/sqrt(2) * (sin(x) - cos(x)) * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) * = -1/sqrt(2) * (cos(x) + sin(x)) * To avoid cancellation, use * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ if(ix>0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrt(x); else { u = pone(x); v = qone(x); z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrt(x); } return z; } if(__builtin_expect(ix<=0x3c900000, 0)) { /* x < 2**-54 */ return(-tpi/x); } z = x*x; #ifdef DO_NOT_USE_THIS u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4]))); v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4])))); #else u1 = U0[0]+z*U0[1];z2=z*z; u2 = U0[2]+z*U0[3];z4=z2*z2; u = u1 + z2*u2 + z4*U0[4]; v1 = one+z*V0[0]; v2 = V0[1]+z*V0[2]; v3 = V0[3]+z*V0[4]; v = v1 + z2*v2 + z4*v3; #endif return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x)); }
double __ieee754_j0(double x) { double z, s,c,ss,cc,r,u,v,r1,r2,s1,s2,z2,z4; int32_t hx,ix; GET_HIGH_WORD(hx,x); ix = hx&0x7fffffff; if(ix>=0x7ff00000) return one/(x*x); x = fabs(x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ __sincos (x, &s, &c); ss = s-c; cc = s+c; if(ix<0x7fe00000) { /* make sure x+x not overflow */ z = -__cos(x+x); if ((s*c)<zero) cc = z/ss; else ss = z/cc; } /* * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) */ if(ix>0x48000000) z = (invsqrtpi*cc)/__ieee754_sqrt(x); else { u = pzero(x); v = qzero(x); z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrt(x); } return z; } if(ix<0x3f200000) { /* |x| < 2**-13 */ math_force_eval(huge+x); /* raise inexact if x != 0 */ if(ix<0x3e400000) return one; /* |x|<2**-27 */ else return one - 0.25*x*x; } z = x*x; #ifdef DO_NOT_USE_THIS r = z*(R02+z*(R03+z*(R04+z*R05))); s = one+z*(S01+z*(S02+z*(S03+z*S04))); #else r1 = z*R[2]; z2=z*z; r2 = R[3]+z*R[4]; z4=z2*z2; r = r1 + z2*r2 + z4*R[5]; s1 = one+z*S[1]; s2 = S[2]+z*S[3]; s = s1 + z2*s2 + z4*S[4]; #endif if(ix < 0x3FF00000) { /* |x| < 1.00 */ return one + z*(-0.25+(r/s)); } else { u = 0.5*x; return((one+u)*(one-u)+z*(r/s)); } }
double __ieee754_j1(double x) { double z, s,c,ss,cc,r,u,v,y,r1,r2,s1,s2,s3,z2,z4; int32_t hx,ix; GET_HIGH_WORD(hx,x); ix = hx&0x7fffffff; if(__builtin_expect(ix>=0x7ff00000, 0)) return one/x; y = fabs(x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ __sincos (y, &s, &c); ss = -s-c; cc = s-c; if(ix<0x7fe00000) { /* make sure y+y not overflow */ z = __cos(y+y); if ((s*c)>zero) cc = z/ss; else ss = z/cc; } /* * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) */ if(ix>0x48000000) z = (invsqrtpi*cc)/__ieee754_sqrt(y); else { u = pone(y); v = qone(y); z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrt(y); } if(hx<0) return -z; else return z; } if(__builtin_expect(ix<0x3e400000, 0)) { /* |x|<2**-27 */ if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */ } z = x*x; #ifdef DO_NOT_USE_THIS r = z*(r00+z*(r01+z*(r02+z*r03))); s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); r *= x; #else r1 = z*R[0]; z2=z*z; r2 = R[1]+z*R[2]; z4=z2*z2; r = r1 + z2*r2 + z4*R[3]; r *= x; s1 = one+z*S[1]; s2 = S[2]+z*S[3]; s3 = S[4]+z*S[5]; s = s1 + z2*s2 + z4*s3; #endif return(x*0.5+r/s); }
void __sincos (double x, double *sinx, double *cosx) { int32_t ix; /* High word of x. */ GET_HIGH_WORD (ix, x); /* |x| ~< pi/4 */ ix &= 0x7fffffff; if (ix >= 0x7ff00000) { /* sin(Inf or NaN) is NaN */ *sinx = *cosx = x - x; } else { *sinx = __sin (x); *cosx = __cos (x); } }
double __ieee754_gamma_r (double x, int *signgamp) { int32_t hx; u_int32_t lx; EXTRACT_WORDS (hx, lx, x); if (__glibc_unlikely (((hx & 0x7fffffff) | lx) == 0)) { /* Return value for x == 0 is Inf with divide by zero exception. */ *signgamp = 0; return 1.0 / x; } if (__builtin_expect (hx < 0, 0) && (u_int32_t) hx < 0xfff00000 && __rint (x) == x) { /* Return value for integer x < 0 is NaN with invalid exception. */ *signgamp = 0; return (x - x) / (x - x); } if (__glibc_unlikely ((unsigned int) hx == 0xfff00000 && lx == 0)) { /* x == -Inf. According to ISO this is NaN. */ *signgamp = 0; return x - x; } if (__glibc_unlikely ((hx & 0x7ff00000) == 0x7ff00000)) { /* Positive infinity (return positive infinity) or NaN (return NaN). */ *signgamp = 0; return x + x; } if (x >= 172.0) { /* Overflow. */ *signgamp = 0; return DBL_MAX * DBL_MAX; } else if (x > 0.0) { *signgamp = 0; int exp2_adj; double ret = gamma_positive (x, &exp2_adj); return __scalbn (ret, exp2_adj); } else if (x >= -DBL_EPSILON / 4.0) { *signgamp = 0; return 1.0 / x; } else { double tx = __trunc (x); *signgamp = (tx == 2.0 * __trunc (tx / 2.0)) ? -1 : 1; if (x <= -184.0) /* Underflow. */ return DBL_MIN * DBL_MIN; double frac = tx - x; if (frac > 0.5) frac = 1.0 - frac; double sinpix = (frac <= 0.25 ? __sin (M_PI * frac) : __cos (M_PI * (0.5 - frac))); int exp2_adj; double ret = M_PI / (-x * sinpix * gamma_positive (-x, &exp2_adj)); return __scalbn (ret, -exp2_adj); } }
double __ieee754_y0(double x) { double z, s,c,ss,cc,u,v,z2,z4,z6,u1,u2,u3,v1,v2; int32_t hx,ix,lx; EXTRACT_WORDS(hx,lx,x); ix = 0x7fffffff&hx; /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0, y0(0) is -inf. */ if(ix>=0x7ff00000) return one/(x+x*x); if((ix|lx)==0) return -HUGE_VAL+x; /* -inf and overflow exception. */ if(hx<0) return zero/(zero*x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0)) * where x0 = x-pi/4 * Better formula: * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) * = 1/sqrt(2) * (sin(x) + cos(x)) * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) * = 1/sqrt(2) * (sin(x) - cos(x)) * To avoid cancellation, use * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ __sincos (x, &s, &c); ss = s-c; cc = s+c; /* * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) */ if(ix<0x7fe00000) { /* make sure x+x not overflow */ z = -__cos(x+x); if ((s*c)<zero) cc = z/ss; else ss = z/cc; } if(ix>0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrt(x); else { u = pzero(x); v = qzero(x); z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrt(x); } return z; } if(ix<=0x3e400000) { /* x < 2**-27 */ return(U[0] + tpi*__ieee754_log(x)); } z = x*x; #ifdef DO_NOT_USE_THIS u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06))))); v = one+z*(v01+z*(v02+z*(v03+z*v04))); #else u1 = U[0]+z*U[1]; z2=z*z; u2 = U[2]+z*U[3]; z4=z2*z2; u3 = U[4]+z*U[5]; z6=z4*z2; u = u1 + z2*u2 + z4*u3 + z6*U[6]; v1 = one+z*V[0]; v2 = V[1]+z*V[2]; v = v1 + z2*v2 + z4*V[3]; #endif return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x))); }
double __ieee754_y1 (double x) { double z, s, c, ss, cc, u, v, u1, u2, v1, v2, v3, z2, z4; int32_t hx, ix, lx; EXTRACT_WORDS (hx, lx, x); ix = 0x7fffffff & hx; /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ if (__glibc_unlikely (ix >= 0x7ff00000)) return one / (x + x * x); if (__glibc_unlikely ((ix | lx) == 0)) return -1 / zero; /* -inf and divide by zero exception. */ /* -inf and overflow exception. */; if (__glibc_unlikely (hx < 0)) return zero / (zero * x); if (ix >= 0x40000000) /* |x| >= 2.0 */ { __sincos (x, &s, &c); ss = -s - c; cc = s - c; if (ix < 0x7fe00000) /* make sure x+x not overflow */ { z = __cos (x + x); if ((s * c) > zero) cc = z / ss; else ss = z / cc; } /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) * where x0 = x-3pi/4 * Better formula: * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) * = 1/sqrt(2) * (sin(x) - cos(x)) * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) * = -1/sqrt(2) * (cos(x) + sin(x)) * To avoid cancellation, use * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ if (ix > 0x48000000) z = (invsqrtpi * ss) / sqrt (x); else { u = pone (x); v = qone (x); z = invsqrtpi * (u * ss + v * cc) / sqrt (x); } return z; } if (__glibc_unlikely (ix <= 0x3c900000)) /* x < 2**-54 */ { z = -tpi / x; if (isinf (z)) __set_errno (ERANGE); return z; } z = x * x; u1 = U0[0] + z * U0[1]; z2 = z * z; u2 = U0[2] + z * U0[3]; z4 = z2 * z2; u = u1 + z2 * u2 + z4 * U0[4]; v1 = one + z * V0[0]; v2 = V0[1] + z * V0[2]; v3 = V0[3] + z * V0[4]; v = v1 + z2 * v2 + z4 * v3; return (x * (u / v) + tpi * (__ieee754_j1 (x) * __ieee754_log (x) - one / x)); }
double __ieee754_j1 (double x) { double z, s, c, ss, cc, r, u, v, y, r1, r2, s1, s2, s3, z2, z4; int32_t hx, ix; GET_HIGH_WORD (hx, x); ix = hx & 0x7fffffff; if (__glibc_unlikely (ix >= 0x7ff00000)) return one / x; y = fabs (x); if (ix >= 0x40000000) /* |x| >= 2.0 */ { __sincos (y, &s, &c); ss = -s - c; cc = s - c; if (ix < 0x7fe00000) /* make sure y+y not overflow */ { z = __cos (y + y); if ((s * c) > zero) cc = z / ss; else ss = z / cc; } /* * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) */ if (ix > 0x48000000) z = (invsqrtpi * cc) / sqrt (y); else { u = pone (y); v = qone (y); z = invsqrtpi * (u * cc - v * ss) / sqrt (y); } if (hx < 0) return -z; else return z; } if (__glibc_unlikely (ix < 0x3e400000)) /* |x|<2**-27 */ { if (huge + x > one) /* inexact if x!=0 necessary */ { double ret = math_narrow_eval (0.5 * x); math_check_force_underflow (ret); if (ret == 0 && x != 0) __set_errno (ERANGE); return ret; } } z = x * x; r1 = z * R[0]; z2 = z * z; r2 = R[1] + z * R[2]; z4 = z2 * z2; r = r1 + z2 * r2 + z4 * R[3]; r *= x; s1 = one + z * S[1]; s2 = S[2] + z * S[3]; s3 = S[4] + z * S[5]; s = s1 + z2 * s2 + z4 * s3; return (x * 0.5 + r / s); }
Err mathlib_cos(UInt16 refnum, double x, double *result) { #pragma unused(refnum) *result = __cos(x); return mlErrNone; }