/* sinl.c
*
* Circular sine , long double precision
*
*
*
* SYNOPSIS :
*
* long double x , y , sinl ( ) ;
*
* y = sinl ( x ) ;
*
*
*
* DESCRIPTION :
*
* Range reduction is into intervals of pi / 4 . The reduction
* error is nearly eliminated by contriving an extended precision
* modular arithmetic .
*
* Two polynomial approximating functions are employed .
* Between 0 and pi / 4 the sine is approximated by the Cody
* and Waite polynomial form
* x + x * * 3 P ( x * * 2 ) .
* Between pi / 4 and pi / 2 the cosine is represented as
* 1 - . 5 x * * 2 + x * * 4 Q ( x * * 2 ) .
*
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* IEEE + - 5 . 5 e11 200 , 000 1 . 2 e - 19 2 . 9 e - 20
*
* ERROR MESSAGES :
*
* message condition value returned
* sin total loss x > 2 * * 39 0 . 0
*
* Loss of precision occurs for x > 2 * * 39 = 5 . 49755813888 e11 .
* The routine as implemented flags a TLOSS error for
* x > 2 * * 39 and returns 0 . 0 .
*/
/* cosl.c
*
* Circular cosine , long double precision
*
*
*
* SYNOPSIS :
*
* long double x , y , cosl ( ) ;
*
* y = cosl ( x ) ;
*
*
*
* DESCRIPTION :
*
* Range reduction is into intervals of pi / 4 . The reduction
* error is nearly eliminated by contriving an extended precision
* modular arithmetic .
*
* Two polynomial approximating functions are employed .
* Between 0 and pi / 4 the cosine is approximated by
* 1 - . 5 x * * 2 + x * * 4 Q ( x * * 2 ) .
* Between pi / 4 and pi / 2 the sine is represented by the Cody
* and Waite polynomial form
* x + x * * 3 P ( x * * 2 ) .
*
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* IEEE + - 5 . 5 e11 50000 1 . 2 e - 19 2 . 9 e - 20
*/
/* sin.c */
/*
Cephes Math Library Release 2 . 7 : May , 1998
Copyright 1985 , 1990 , 1998 by Stephen L . Moshier
*/
#include "mconf.h"
#ifdef UNK
static long double sincof[7 ] = {
-7 .5785404094842805756289 E-13 L,
1 .6058363167320443249231 E-10 L,
-2 .5052104881870868784055 E-8 L,
2 .7557319214064922217861 E-6 L,
-1 .9841269841254799668344 E-4 L,
8 .3333333333333225058715 E-3 L,
-1 .6666666666666666640255 E-1 L,
};
static long double coscof[7 ] = {
4 .7377507964246204691685 E-14 L,
-1 .1470284843425359765671 E-11 L,
2 .0876754287081521758361 E-9 L,
-2 .7557319214999787979814 E-7 L,
2 .4801587301570552304991 E-5 L,
-1 .3888888888888872993737 E-3 L,
4 .1666666666666666609054 E-2 L,
};
static long double DP1 = 7 .853981554508209228515625 E-1 L;
static long double DP2 = 7 .946627356147928367136046290398 E-9 L;
static long double DP3 = 3 .061616997868382943065164830688 E-17 L;
#endif
#ifdef IBMPC
static short sincof[] = {
0 x4e27,0 xe1d6,0 x2389,0 xd551,0 xbfd6, XPD
0 x64d7,0 xe706,0 x4623,0 xb090,0 x3fde, XPD
0 x01b1,0 xbf34,0 x2946,0 xd732,0 xbfe5, XPD
0 xc8f7,0 x9845,0 x1d29,0 xb8ef,0 x3fec, XPD
0 x6514,0 x0c53,0 x00d0,0 xd00d,0 xbff2, XPD
0 x569a,0 x8888,0 x8888,0 x8888,0 x3ff8, XPD
0 xaa97,0 xaaaa,0 xaaaa,0 xaaaa,0 xbffc, XPD
};
static short coscof[] = {
0 x7436,0 x6f99,0 x8c3a,0 xd55e,0 x3fd2, XPD
0 x2f37,0 x58f4,0 x920f,0 xc9c9,0 xbfda, XPD
0 x5350,0 x659e,0 xc648,0 x8f76,0 x3fe2, XPD
0 x4d2b,0 xf5c6,0 x7dba,0 x93f2,0 xbfe9, XPD
0 x53ed,0 x0c66,0 x00d0,0 xd00d,0 x3fef, XPD
0 x7b67,0 x0b60,0 x60b6,0 xb60b,0 xbff5, XPD
0 xaa9a,0 xaaaa,0 xaaaa,0 xaaaa,0 x3ffa, XPD
};
static short P1[] = {0 x0000,0 x0000,0 xda80,0 xc90f,0 x3ffe, XPD};
static short P2[] = {0 x0000,0 x0000,0 xa300,0 x8885,0 x3fe4, XPD};
static short P3[] = {0 x3707,0 xa2e0,0 x3198,0 x8d31,0 x3fc8, XPD};
#define DP1 *(long double *)P1
#define DP2 *(long double *)P2
#define DP3 *(long double *)P3
#endif
#ifdef MIEEE
static long sincof[] = {
0 xbfd60000,0 xd5512389,0 xe1d64e27,
0 x3fde0000,0 xb0904623,0 xe70664d7,
0 xbfe50000,0 xd7322946,0 xbf3401b1,
0 x3fec0000,0 xb8ef1d29,0 x9845c8f7,
0 xbff20000,0 xd00d00d0,0 x0c536514,
0 x3ff80000,0 x88888888,0 x8888569a,
0 xbffc0000,0 xaaaaaaaa,0 xaaaaaa97,
};
static long coscof[] = {
0 x3fd20000,0 xd55e8c3a,0 x6f997436,
0 xbfda0000,0 xc9c9920f,0 x58f42f37,
0 x3fe20000,0 x8f76c648,0 x659e5350,
0 xbfe90000,0 x93f27dba,0 xf5c64d2b,
0 x3fef0000,0 xd00d00d0,0 x0c6653ed,
0 xbff50000,0 xb60b60b6,0 x0b607b67,
0 x3ffa0000,0 xaaaaaaaa,0 xaaaaaa9a,
};
static long P1[] = {0 x3ffe0000,0 xc90fda80,0 x00000000};
static long P2[] = {0 x3fe40000,0 x8885a300,0 x00000000};
static long P3[] = {0 x3fc80000,0 x8d313198,0 xa2e03707};
#define DP1 *(long double *)P1
#define DP2 *(long double *)P2
#define DP3 *(long double *)P3
#endif
static long double lossth = 5 .49755813888 e11L; /* 2^39 */
extern long double PIO4L;
#ifdef ANSIPROT
extern long double polevll ( long double , void *, int );
extern long double floorl ( long double );
extern long double ldexpl ( long double , int );
extern int isnanl ( long double );
extern int isfinitel ( long double );
#else
long double polevll(), floorl(), ldexpl(), isnanl(), isfinitel();
#endif
#ifdef INFINITIES
extern long double INFINITYL;
#endif
#ifdef NANS
extern long double NANL;
#endif
long double sinl(x)
long double x;
{
long double y, z, zz;
int j, sign;
#ifdef NANS
if ( isnanl(x) )
return (x);
#endif
#ifdef MINUSZERO
if ( x == 0 .0 L )
return (x);
#endif
#ifdef NANS
if ( !isfinitel(x) )
{
mtherr( "sinl" , DOMAIN );
#ifdef NANS
return (NANL);
#else
return (0 .0 L);
#endif
}
#endif
/* make argument positive but save the sign */
sign = 1 ;
if ( x < 0 )
{
x = -x;
sign = -1 ;
}
if ( x > lossth )
{
mtherr( "sinl" , TLOSS );
return (0 .0 L);
}
y = floorl( x/PIO4L ); /* integer part of x/PIO4 */
/* strip high bits of integer part to prevent integer overflow */
z = ldexpl( y, -4 );
z = floorl(z); /* integer part of y/8 */
z = y - ldexpl( z, 4 ); /* y - 16 * (y/16) */
j = z; /* convert to integer for tests on the phase angle */
/* map zeros to origin */
if ( j & 1 )
{
j += 1 ;
y += 1 .0 L;
}
j = j & 07 ; /* octant modulo 360 degrees */
/* reflect in x axis */
if ( j > 3 )
{
sign = -sign;
j -= 4 ;
}
/* Extended precision modular arithmetic */
z = ((x - y * DP1) - y * DP2) - y * DP3;
zz = z * z;
if ( (j==1 ) || (j==2 ) )
{
y = 1 .0 L - ldexpl(zz,-1 ) + zz * zz * polevll( zz, coscof, 6 );
}
else
{
y = z + z * (zz * polevll( zz, sincof, 6 ));
}
if (sign < 0 )
y = -y;
return (y);
}
long double cosl(x)
long double x;
{
long double y, z, zz;
long i;
int j, sign;
#ifdef NANS
if ( isnanl(x) )
return (x);
#endif
#ifdef INFINITIES
if ( !isfinitel(x) )
{
mtherr( "cosl" , DOMAIN );
#ifdef NANS
return (NANL);
#else
return (0 .0 L);
#endif
}
#endif
/* make argument positive */
sign = 1 ;
if ( x < 0 )
x = -x;
if ( x > lossth )
{
mtherr( "cosl" , TLOSS );
return (0 .0 L);
}
y = floorl( x/PIO4L );
z = ldexpl( y, -4 );
z = floorl(z); /* integer part of y/8 */
z = y - ldexpl( z, 4 ); /* y - 16 * (y/16) */
/* integer and fractional part modulo one octant */
i = z;
if ( i & 1 ) /* map zeros to origin */
{
i += 1 ;
y += 1 .0 L;
}
j = i & 07 ;
if ( j > 3 )
{
j -=4 ;
sign = -sign;
}
if ( j > 1 )
sign = -sign;
/* Extended precision modular arithmetic */
z = ((x - y * DP1) - y * DP2) - y * DP3;
zz = z * z;
if ( (j==1 ) || (j==2 ) )
{
y = z + z * (zz * polevll( zz, sincof, 6 ));
}
else
{
y = 1 .0 L - ldexpl(zz,-1 ) + zz * zz * polevll( zz, coscof, 6 );
}
if (sign < 0 )
y = -y;
return (y);
}
Messung V0.5 in Prozent C=94 H=100 G=96
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-14)
¤
*© Formatika GbR, Deutschland