Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Cephes/   (Cephes Mathematical Library ©)  Datei vom 9.5.2026 mit Größe 5 kB image not shown  

Quelle  tandg.c

  Sprache: C
 

/* tandg.c
 *
 * Circular tangent of argument in degrees
 *
 *
 *
 * SYNOPSIS:
 *
 * double x, y, tandg();
 *
 * y = tandg( x );
 *
 *
 *
 * DESCRIPTION:
 *
 * Returns the circular tangent of the argument x in degrees.
 *
 * Range reduction is modulo pi/4.  A rational function
 *       x + x**3 P(x**2)/Q(x**2)
 * is employed in the basic interval [0, pi/4].
 *
 *
 *
 * ACCURACY:
 *
 *                      Relative error:
 * arithmetic   domain     # trials      peak         rms
 *    DEC      0,10          8000      3.4e-17      1.2e-17
 *    IEEE     0,10         30000      3.2e-16      8.4e-17
 *
 * ERROR MESSAGES:
 *
 *   message         condition          value returned
 * tandg total loss   x > 8.0e14 (DEC)      0.0
 *                    x > 1.0e14 (IEEE)
 * tandg singularity  x = 180 k  +  90     MAXNUM
 */

/* cotdg.c
 *
 * Circular cotangent of argument in degrees
 *
 *
 *
 * SYNOPSIS:
 *
 * double x, y, cotdg();
 *
 * y = cotdg( x );
 *
 *
 *
 * DESCRIPTION:
 *
 * Returns the circular cotangent of the argument x in degrees.
 *
 * Range reduction is modulo pi/4.  A rational function
 *       x + x**3 P(x**2)/Q(x**2)
 * is employed in the basic interval [0, pi/4].
 *
 *
 * ERROR MESSAGES:
 *
 *   message         condition          value returned
 * cotdg total loss   x > 8.0e14 (DEC)      0.0
 *                    x > 1.0e14 (IEEE)
 * cotdg singularity  x = 180 k            MAXNUM
 */


/*
Cephes Math Library Release 2.8:  June, 2000
Copyright 1984, 1987, 2000 by Stephen L. Moshier
*/


#include "mconf.h"

#ifdef UNK
static double P[] = {-1.30936939181383777646E4, 1.15351664838587416140E6,
                     -1.79565251976484877988E7};
static double Q[] = {
    /* 1.00000000000000000000E0,*/
    1.36812963470692954678E4, -1.32089234440210967447E6,
    2.50083801823357915839E7, -5.38695755929454629881E7};
static double PI180 = 1.74532925199432957692E-2;
static double lossth = 1.0e14;
#endif

#ifdef DEC
static unsigned short P[] = {0143514011330601111710174674,
                             0045214014754500277440167346,
                             0146210017752601145140105660};
static unsigned short Q[] = {
    /*0040200,0000000,0000000,0000000,*/
    00435250142457007263300256170145241003674201405250162256,
    00462760146176001352601435730146515007740101627620150607};
static unsigned short P1[] = {0036616017506500112240164711};
#define PI180 *(double *)P1
static double lossth = 8.0e14;
#endif

#ifdef IBMPC
static unsigned short P[] = {0x3f38, 0xd24f, 0x92d8, 0xc0c9, 0x9ddd, 0xa5fc,
                             0x99ec, 0x4131, 0x9176, 0xd329, 0x1fea, 0xc171};
static unsigned short Q[] = {
    /*0x0000,0x0000,0x0000,0x3ff0,*/
    0x6572, 0xeeb3, 0xb8a5, 0x40ca, 0xbc96, 0x582a, 0x27bc, 0xc134,
    0xd8ef, 0xc2ea, 0xd98f, 0x4177, 0x5a31, 0x3cbe, 0xafe0, 0xc189};
static unsigned short P1[] = {0x9d39, 0xa252, 0xdf46, 0x3f91};
#define PI180 *(double *)P1
static double lossth = 1.0e14;
#endif

#ifdef MIEEE
static unsigned short P[] = {0xc0c9, 0x92d8, 0xd24f, 0x3f38, 0x4131, 0x99ec,
                             0xa5fc, 0x9ddd, 0xc171, 0x1fea, 0xd329, 0x9176};
static unsigned short Q[] = {0x40ca, 0xb8a5, 0xeeb3, 0x6572, 0xc134, 0x27bc,
                             0x582a, 0xbc96, 0x4177, 0xd98f, 0xc2ea, 0xd8ef,
                             0xc189, 0xafe0, 0x3cbe, 0x5a31};
static unsigned short P1[] = {0x3f91, 0xdf46, 0xa252, 0x9d39};
#define PI180 *(double *)P1
static double lossth = 1.0e14;
#endif

#ifdef ANSIPROT
extern double polevl(doublevoid *, int);
extern double p1evl(doublevoid *, int);
extern double floor(double);
extern double ldexp(doubleint);
static double tancot(doubleint);
#else
double polevl(), p1evl(), floor(), ldexp();
static double tancot();
#endif
extern double MAXNUM;
extern double PIO4;

double tandg(x) double x;
return (tancot(x, 0)); }

double cotdg(x) double x;
return (tancot(x, 1)); }

static double tancot(xx, cotflg) double xx;
int cotflg;
{
  double x, y, z, zz;
  int j, sign;

  /* make argument positive but save the sign */
  if (xx < 0) {
    x = -xx;
    sign = -1;
  } else {
    x = xx;
    sign = 1;
  }

  if (x > lossth) {
    mtherr("tandg", TLOSS);
    return (0.0);
  }

  /* compute x mod PIO4 */
  y = floor(x / 45.0);

  /* strip high bits of integer part */
  z = ldexp(y, -3);
  z = floor(z);        /* integer part of y/8 */
  z = y - ldexp(z, 3); /* y - 16 * (y/16) */

  /* integer and fractional part modulo one octant */
  j = z;

  /* map zeros and singularities to origin */
  if (j & 1) {
    j += 1;
    y += 1.0;
  }

  z = x - y * 45.0;
  z *= PI180;

  zz = z * z;

  if (zz > 1.0e-14)
    y = z + z * (zz * polevl(zz, P, 2) / p1evl(zz, Q, 4));
  else
    y = z;

  if (j & 2) {
    if (cotflg)
      y = -y;
    else {
      if (y != 0.0) {
        y = -1.0 / y;
      } else {
        mtherr("tandg", SING);
        y = MAXNUM;
      }
    }
  } else {
    if (cotflg) {
      if (y != 0.0)
        y = 1.0 / y;
      else {
        mtherr("cotdg", SING);
        y = MAXNUM;
      }
    }
  }

  if (sign < 0)
    y = -y;

  return (y);
}

Messung V0.5 in Prozent
C=94 H=87 G=90

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.