/* sindg.c
*
* Circular sine of angle in degrees
*
*
*
* SYNOPSIS :
*
* double x , y , sindg ( ) ;
*
* y = sindg ( x ) ;
*
*
*
* DESCRIPTION :
*
* Range reduction is into intervals of 45 degrees .
*
* Two polynomial approximating functions are employed .
* Between 0 and pi / 4 the sine is approximated by
* x + x * * 3 P ( x * * 2 ) .
* Between pi / 4 and pi / 2 the cosine is represented as
* 1 - x * * 2 P ( x * * 2 ) .
*
*
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* DEC + - 1000 3100 3 . 3 e - 17 9 . 0 e - 18
* IEEE + - 1000 30000 2 . 3 e - 16 5 . 6 e - 17
*
* ERROR MESSAGES :
*
* message condition value returned
* sindg total loss x > 8 . 0 e14 ( DEC ) 0 . 0
* x > 1 . 0 e14 ( IEEE )
*
*/
/* cosdg.c
*
* Circular cosine of angle in degrees
*
*
*
* SYNOPSIS :
*
* double x , y , cosdg ( ) ;
*
* y = cosdg ( x ) ;
*
*
*
* DESCRIPTION :
*
* Range reduction is into intervals of 45 degrees .
*
* Two polynomial approximating functions are employed .
* Between 0 and pi / 4 the cosine is approximated by
* 1 - x * * 2 P ( x * * 2 ) .
* Between pi / 4 and pi / 2 the sine is represented as
* x + x * * 3 P ( x * * 2 ) .
*
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* DEC + - 1000 3400 3 . 5 e - 17 9 . 1 e - 18
* IEEE + - 1000 30000 2 . 1 e - 16 5 . 7 e - 17
* See also sin ( ) .
*
*/
/* Cephes Math Library Release 2.0: April, 1987
* Copyright 1985 , 1987 by Stephen L . Moshier
* Direct inquiries to 30 Frost Street, Cambridge, MA 02140 */
#include "mconf.h"
#ifdef UNK
static double sincof[] = {
1 .58962301572218447952 E-10 ,
-2 .50507477628503540135 E-8 ,
2 .75573136213856773549 E-6 ,
-1 .98412698295895384658 E-4 ,
8 .33333333332211858862 E-3 ,
-1 .66666666666666307295 E-1
};
static double coscof[] = {
1 .13678171382044553091 E-11 ,
-2 .08758833757683644217 E-9 ,
2 .75573155429816611547 E-7 ,
-2 .48015872936186303776 E-5 ,
1 .38888888888806666760 E-3 ,
-4 .16666666666666348141 E-2 ,
4 .99999999999999999798 E-1
};
static double PI180 = 1 .74532925199432957692 E-2 ; /* pi/180 */
static double lossth = 1 .0 e14;
#endif
#ifdef DEC
static unsigned short sincof[] = {
0030056 ,0143750 ,0177170 ,0073013 ,
0131727 ,0027455 ,0044510 ,0132205 ,
0033470 ,0167432 ,0131752 ,0042263 ,
0135120 ,0006400 ,0146776 ,0174027 ,
0036410 ,0104210 ,0104207 ,0137202 ,
0137452 ,0125252 ,0125252 ,0125103
};
static unsigned short coscof[] = {
0027107 ,0176030 ,0153315 ,0110312 ,
0131017 ,0072476 ,0007450 ,0123243 ,
0032623 ,0171174 ,0070066 ,0146445 ,
0134320 ,0006400 ,0147355 ,0163313 ,
0035666 ,0005540 ,0133012 ,0165067 ,
0137052 ,0125252 ,0125252 ,0125206 ,
0040000 ,0000000 ,0000000 ,0000000
};
static unsigned short P1[] = {0036616 ,0175065 ,0011224 ,0164711 };
#define PI180 *(double *)P1
static double lossth = 8 .0 e14;
#endif
#ifdef IBMPC
static unsigned short sincof[] = {
0 x0ec1,0 x1fcf,0 xd8fd,0 x3de5,
0 x1691,0 xa929,0 xe5e5,0 xbe5a,
0 x4896,0 x567d,0 x1de3,0 x3ec7,
0 xdf03,0 x19bf,0 x01a0,0 xbf2a,
0 xf7d0,0 x1110,0 x1111,0 x3f81,
0 x5548,0 x5555,0 x5555,0 xbfc5
};
static unsigned short coscof[] = {
0 xb219,0 x1ad9,0 xff83,0 x3da8,
0 x14d4,0 xc1e5,0 xeea7,0 xbe21,
0 xd9a5,0 x8e06,0 x7e4f,0 x3e92,
0 xbcd9,0 x19dd,0 x01a0,0 xbefa,
0 x5d47,0 x16c1,0 xc16c,0 x3f56,
0 x5551,0 x5555,0 x5555,0 xbfa5,
0 x0000,0 x0000,0 x0000,0 x3fe0
};
static unsigned short P1[] = {0 x9d39,0 xa252,0 xdf46,0 x3f91};
#define PI180 *(double *)P1
static double lossth = 1 .0 e14;
#endif
#ifdef MIEEE
static unsigned short sincof[] = {
0 x3de5,0 xd8fd,0 x1fcf,0 x0ec1,
0 xbe5a,0 xe5e5,0 xa929,0 x1691,
0 x3ec7,0 x1de3,0 x567d,0 x4896,
0 xbf2a,0 x01a0,0 x19bf,0 xdf03,
0 x3f81,0 x1111,0 x1110,0 xf7d0,
0 xbfc5,0 x5555,0 x5555,0 x5548
};
static unsigned short coscof[] = {
0 x3da8,0 xff83,0 x1ad9,0 xb219,
0 xbe21,0 xeea7,0 xc1e5,0 x14d4,
0 x3e92,0 x7e4f,0 x8e06,0 xd9a5,
0 xbefa,0 x01a0,0 x19dd,0 xbcd9,
0 x3f56,0 xc16c,0 x16c1,0 x5d47,
0 xbfa5,0 x5555,0 x5555,0 x5551,
0 x3fe0,0 x0000,0 x0000,0 x0000
};
static unsigned short P1[] = {
0 x3f91,0 xdf46,0 xa252,0 x9d39
};
#define PI180 *(double *)P1
static double lossth = 1 .0 e14;
#endif
#ifdef ANSIPROT
extern double polevl ( double , void *, int );
extern double floor ( double );
extern double ldexp ( double , int );
#else
double polevl(), floor(), ldexp();
#endif
extern double PIO4;
double sindg(x)
double x;
{
double y, z, zz;
int j, sign;
/* make argument positive but save the sign */
sign = 1 ;
if ( x < 0 )
{
x = -x;
sign = -1 ;
}
if ( x > lossth )
{
mtherr( "sindg" , TLOSS );
return (0 .0 );
}
y = floor( x/45 .0 ); /* integer part of x/PIO4 */
/* strip high bits of integer part to prevent integer overflow */
z = ldexp( y, -4 );
z = floor(z); /* integer part of y/8 */
z = y - ldexp( 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 ;
}
j = j & 07 ; /* octant modulo 360 degrees */
/* reflect in x axis */
if ( j > 3 )
{
sign = -sign;
j -= 4 ;
}
z = x - y * 45 .0 ; /* x mod 45 degrees */
z *= PI180; /* multiply by pi/180 to convert to radians */
zz = z * z;
if ( (j==1 ) || (j==2 ) )
{
y = 1 .0 - zz * polevl( zz, coscof, 6 );
}
else
{
y = z + z * (zz * polevl( zz, sincof, 5 ));
}
if (sign < 0 )
y = -y;
return (y);
}
double cosdg(x)
double x;
{
double y, z, zz;
int j, sign;
/* make argument positive */
sign = 1 ;
if ( x < 0 )
x = -x;
if ( x > lossth )
{
mtherr( "cosdg" , TLOSS );
return (0 .0 );
}
y = floor( x/45 .0 );
z = ldexp( y, -4 );
z = floor(z); /* integer part of y/8 */
z = y - ldexp( z, 4 ); /* y - 16 * (y/16) */
/* integer and fractional part modulo one octant */
j = z;
if ( j & 1 ) /* map zeros to origin */
{
j += 1 ;
y += 1 .0 ;
}
j = j & 07 ;
if ( j > 3 )
{
j -=4 ;
sign = -sign;
}
if ( j > 1 )
sign = -sign;
z = x - y * 45 .0 ; /* x mod 45 degrees */
z *= PI180; /* multiply by pi/180 to convert to radians */
zz = z * z;
if ( (j==1 ) || (j==2 ) )
{
y = z + z * (zz * polevl( zz, sincof, 5 ));
}
else
{
y = 1 .0 - zz * polevl( zz, coscof, 6 );
}
if (sign < 0 )
y = -y;
return (y);
}
Messung V0.5 in Prozent C=93 H=100 G=96
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-23)
¤
*© Formatika GbR, Deutschland