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

Quelle  j0.c

  Sprache: C
 

/* j0.c
 *
 * Bessel function of order zero
 *
 *
 *
 * SYNOPSIS:
 *
 * double x, y, j0();
 *
 * y = j0( x );
 *
 *
 *
 * DESCRIPTION:
 *
 * Returns Bessel function of order zero of the argument.
 *
 * The domain is divided into the intervals [0, 5] and
 * (5, infinity). In the first interval the following rational
 * approximation is used:
 *
 *
 *        2         2
 * (w - r  ) (w - r  ) P (w) / Q (w)
 *       1         2    3       8
 *
 *            2
 * where w = x  and the two r's are zeros of the function.
 *
 * In the second interval, the Hankel asymptotic expansion
 * is employed with two rational functions of degree 6/6
 * and 7/7.
 *
 *
 *
 * ACCURACY:
 *
 *                      Absolute error:
 * arithmetic   domain     # trials      peak         rms
 *    DEC       0, 30       10000       4.4e-17     6.3e-18
 *    IEEE      0, 30       60000       4.2e-16     1.1e-16
 *
 */

/* y0.c
 *
 * Bessel function of the second kind, order zero
 *
 *
 *
 * SYNOPSIS:
 *
 * double x, y, y0();
 *
 * y = y0( x );
 *
 *
 *
 * DESCRIPTION:
 *
 * Returns Bessel function of the second kind, of order
 * zero, of the argument.
 *
 * The domain is divided into the intervals [0, 5] and
 * (5, infinity). In the first interval a rational approximation
 * R(x) is employed to compute
 *   y0(x)  = R(x)  +   2 * log(x) * j0(x) / PI.
 * Thus a call to j0() is required.
 *
 * In the second interval, the Hankel asymptotic expansion
 * is employed with two rational functions of degree 6/6
 * and 7/7.
 *
 *
 *
 * ACCURACY:
 *
 *  Absolute error, when y0(x) < 1; else relative error:
 *
 * arithmetic   domain     # trials      peak         rms
 *    DEC       0, 30        9400       7.0e-17     7.9e-18
 *    IEEE      0, 30       30000       1.3e-15     1.6e-16
 *
 */


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


/* Note: all coefficients satisfy the relative error criterion
 * except YP, YQ which are designed for absolute error. */


#include "mconf.h"

#ifdef UNK
static double PP[7] = {
    7.96936729297347051624E-48.28352392107440799803E-2,
    1.23953371646414299388E0,  5.44725003058768775090E0,
    8.74716500199817011941E0,  5.30324038235394892183E0,
    9.99999999999999997821E-1,
};
static double PQ[7] = {
    9.24408810558863637013E-48.56288474354474431428E-2,
    1.25352743901058953537E0,  5.47097740330417105182E0,
    8.76190883237069594232E0,  5.30605288235394617618E0,
    1.00000000000000000218E0,
};
#endif
#ifdef DEC
static unsigned short PP[28] = {
    0035520016460401407330054470003725101226050115356,
    0107170004023601244120071500005630300406560047737,
    0045720004526300410130172143004500401421030040651,
    0132045002624100264060040200000000000000000000000,
};
static unsigned short PQ[28] = {
    0035562005200600700340134666003725700570550055242,
    0123424004024000716260046630003237100406570011077,
    0032013001273100410140030307005033100064140040651,
    0145457006502101503040040200000000000000000000000,
};
#endif
#ifdef IBMPC
static unsigned short PP[28] = {
    0x6b27, 0x983b, 0x1d30, 0x3f4a, 0xd1cf, 0xb35d, 0x34b0,
    0x3fb5, 0x0b98, 0x4e68, 0xd521, 0x3ff3, 0x0956, 0xe97a,
    0xc9fb, 0x4015, 0x9888, 0x6940, 0x7e8c, 0x4021, 0x25a1,
    0xa594, 0x3684, 0x4015, 0x0000, 0x0000, 0x0000, 0x3ff0,
};
static unsigned short PQ[28] = {
    0x9737, 0xce03, 0x4a80, 0x3f4e, 0x54e3, 0xab54, 0xebc5,
    0x3fb5, 0x069f, 0xc9b3, 0x0e72, 0x3ff4, 0x62bb, 0xe681,
    0xe247, 0x4015, 0x21a1, 0xea1b, 0x8618, 0x4021, 0x3a19,
    0xed42, 0x3965, 0x4015, 0x0000, 0x0000, 0x0000, 0x3ff0,
};
#endif
#ifdef MIEEE
static unsigned short PP[28] = {
    0x3f4a, 0x1d30, 0x983b, 0x6b27, 0x3fb5, 0x34b0, 0xb35d,
    0xd1cf, 0x3ff3, 0xd521, 0x4e68, 0x0b98, 0x4015, 0xc9fb,
    0xe97a, 0x0956, 0x4021, 0x7e8c, 0x6940, 0x9888, 0x4015,
    0x3684, 0xa594, 0x25a1, 0x3ff0, 0x0000, 0x0000, 0x0000,
};
static unsigned short PQ[28] = {
    0x3f4e, 0x4a80, 0xce03, 0x9737, 0x3fb5, 0xebc5, 0xab54,
    0x54e3, 0x3ff4, 0x0e72, 0xc9b3, 0x069f, 0x4015, 0xe247,
    0xe681, 0x62bb, 0x4021, 0x8618, 0xea1b, 0x21a1, 0x4015,
    0x3965, 0xed42, 0x3a19, 0x3ff0, 0x0000, 0x0000, 0x0000,
};
#endif

#ifdef UNK
static double QP[8] = {
    -1.13663838898469149931E-2, -1.28252718670509318512E0,
    -1.95539544257735972385E1,  -9.32060152123768231369E1,
    -1.77681167980488050595E2,  -1.47077505154951170175E2,
    -5.14105326766599330220E1,  -6.05014350600728481186E0,
};
static double QQ[7] = {
    /*  1.00000000000000000000E0,*/
    6.43178256118178023184E1, 8.56430025976980587198E2,
    3.88240183605401609683E3, 7.24046774195652478189E3,
    5.93072701187316984827E3, 2.06209331660327847417E3,
    2.42005740240291393179E2,
};
#endif
#ifdef DEC
static unsigned short QP[32] = {
    01364720035021014245101411150140244002473101506200105642,
    01412340067177012416100601410141672006457201515570043036,
    01420610127141000312700435170142023001172700602710144544,
    01415150122142012662001431500140701011530601067150007344,
};
static unsigned short QQ[28] = {
    /*0040200,0000000,0000000,0000000,*/
    0041600012127200047410026544004252600156050105654,
    0161771004316201231550165644006264500433420041675,
    0167576013075600432710052720016563101542140043000,
    0160576003461401720240042162000057000305000051235,
};
#endif
#ifdef IBMPC
static unsigned short QP[32] = {
    0x384a, 0x38a5, 0x4742, 0xbf87, 0x1174, 0x3a32, 0x853b, 0xbff4,
    0x2c0c, 0xf50e, 0x8dcf, 0xc033, 0xe8c4, 0x5a6d, 0x4d2f, 0xc057,
    0xe8ea, 0x20ca, 0x35cc, 0xc066, 0x392d, 0xec17, 0x627a, 0xc062,
    0x18cd, 0x55b2, 0xb48c, 0xc049, 0xa1dd, 0xd1b9, 0x3358, 0xc018,
};
static unsigned short QQ[28] = {
    /*0x0000,0x0000,0x0000,0x3ff0,*/
    0x25ac, 0x413c, 0x1457, 0x4050, 0x9c7f, 0xb175, 0xc370,
    0x408a, 0x8cb5, 0xbd74, 0x54cd, 0x40ae, 0xd63e, 0xbdef,
    0x4877, 0x40bc, 0x3b11, 0x1d73, 0x2aba, 0x40b7, 0x9e82,
    0xc731, 0x1c2f, 0x40a0, 0x0a54, 0x0628, 0x402f, 0x406e,
};
#endif
#ifdef MIEEE
static unsigned short QP[32] = {
    0xbf87, 0x4742, 0x38a5, 0x384a, 0xbff4, 0x853b, 0x3a32, 0x1174,
    0xc033, 0x8dcf, 0xf50e, 0x2c0c, 0xc057, 0x4d2f, 0x5a6d, 0xe8c4,
    0xc066, 0x35cc, 0x20ca, 0xe8ea, 0xc062, 0x627a, 0xec17, 0x392d,
    0xc049, 0xb48c, 0x55b2, 0x18cd, 0xc018, 0x3358, 0xd1b9, 0xa1dd,
};
static unsigned short QQ[28] = {
    /*0x3ff0,0x0000,0x0000,0x0000,*/
    0x4050, 0x1457, 0x413c, 0x25ac, 0x408a, 0xc370, 0xb175,
    0x9c7f, 0x40ae, 0x54cd, 0xbd74, 0x8cb5, 0x40bc, 0x4877,
    0xbdef, 0xd63e, 0x40b7, 0x2aba, 0x1d73, 0x3b11, 0x40a0,
    0x1c2f, 0xc731, 0x9e82, 0x406e, 0x402f, 0x0628, 0x0a54,
};
#endif

#ifdef UNK
static double YP[8] = {
    1.55924367855235737965E4,  -1.46639295903971606143E7,
    5.43526477051876500413E9,  -9.82136065717911466409E11,
    8.75906394395366999549E13, -3.46628303384729719441E15,
    4.42733268572569800351E16, -1.84950800436986690637E16,
};
static double YQ[7] = {
    /* 1.00000000000000000000E0,*/
    1.04128353664259848412E3,  6.26107330137134956842E5,
    2.68919633393814121987E8,  8.64002487103935000337E10,
    2.02979612750105546709E13, 3.17157752842975028269E15,
    2.50596256172653059228E17,
};
#endif
#ifdef DEC
static unsigned short YP[32] = {
    00435630120677004226400461660146137014037101134440042260,
    00502410175707010050200633440152144012573700072650164526,
    00536370051621016303500605460155105000441601073060060023,
    00560350045133003013200000240155603006513201440610131732,
};
static unsigned short YQ[28] = {
    /*0040200,0000000,0000000,0000000,*/
    0042602002442201355570162663004503001556650044075,
    0160135004720000354320105446010400500512400167331,
    0056063002274300532230127746002576400121600055064,
    0044206017753201455450056536011137501637150127201,
};
#endif
#ifdef IBMPC
static unsigned short YP[32] = {
    0x898f, 0xe896, 0x7437, 0x40ce, 0x8896, 0x32e4, 0xf81f, 0xc16b,
    0x4cdd, 0xf028, 0x3f78, 0x41f4, 0xbd2b, 0xe1d6, 0x957b, 0xc26c,
    0xac2d, 0x3cc3, 0xea72, 0x42d3, 0xcc02, 0xd1d8, 0xa121, 0xc328,
    0x4003, 0x660b, 0xa94b, 0x4363, 0x367b, 0x5906, 0x6d4b, 0xc350,
};
static unsigned short YQ[28] = {
    /*0x0000,0x0000,0x0000,0x3ff0,*/
    0xfcb6, 0x576d, 0x4522, 0x4090, 0xbc0c, 0xa907, 0x1b76,
    0x4123, 0xd101, 0x5164, 0x0763, 0x41b0, 0x64bc, 0x2b86,
    0x1ddb, 0x4234, 0x828e, 0xc57e, 0x75fc, 0x42b2, 0x596d,
    0xdfeb, 0x8910, 0x4326, 0xb5d0, 0xbcf9, 0xd25f, 0x438b,
};
#endif
#ifdef MIEEE
static unsigned short YP[32] = {
    0x40ce, 0x7437, 0xe896, 0x898f, 0xc16b, 0xf81f, 0x32e4, 0x8896,
    0x41f4, 0x3f78, 0xf028, 0x4cdd, 0xc26c, 0x957b, 0xe1d6, 0xbd2b,
    0x42d3, 0xea72, 0x3cc3, 0xac2d, 0xc328, 0xa121, 0xd1d8, 0xcc02,
    0x4363, 0xa94b, 0x660b, 0x4003, 0xc350, 0x6d4b, 0x5906, 0x367b,
};
static unsigned short YQ[28] = {
    /*0x3ff0,0x0000,0x0000,0x0000,*/
    0x4090, 0x4522, 0x576d, 0xfcb6, 0x4123, 0x1b76, 0xa907,
    0xbc0c, 0x41b0, 0x0763, 0x5164, 0xd101, 0x4234, 0x1ddb,
    0x2b86, 0x64bc, 0x42b2, 0x75fc, 0xc57e, 0x828e, 0x4326,
    0x8910, 0xdfeb, 0x596d, 0x438b, 0xd25f, 0xbcf9, 0xb5d0,
};
#endif

#ifdef UNK
/*  5.783185962946784521175995758455807035071 */
static double DR1 = 5.78318596294678452118E0;
/* 30.47126234366208639907816317502275584842 */
static double DR2 = 3.04712623436620863991E1;
#endif

#ifdef DEC
static unsigned short R1[] = {0040671000773400010610056734};
#define DR1 *(double *)R1
static unsigned short R2[] = {0041363014244500304160165567};
#define DR2 *(double *)R2
#endif

#ifdef IBMPC
static unsigned short R1[] = {0x2bbb, 0x8046, 0x21fb, 0x4017};
#define DR1 *(double *)R1
static unsigned short R2[] = {0xdd6f, 0xa621, 0x78a4, 0x403e};
#define DR2 *(double *)R2
#endif

#ifdef MIEEE
static unsigned short R1[] = {0x4017, 0x21fb, 0x8046, 0x2bbb};
#define DR1 *(double *)R1
static unsigned short R2[] = {0x403e, 0x78a4, 0xa621, 0xdd6f};
#define DR2 *(double *)R2
#endif

#ifdef UNK
static double RP[4] = {
    -4.79443220978201773821E9,
    1.95617491946556577543E12,
    -2.49248344360967716204E14,
    9.70862251047306323952E15,
};
static double RQ[8] = {
    /* 1.00000000000000000000E0,*/
    4.99563147152651017219E2,  1.73785401676374683123E5,
    4.84409658339962045305E7,  1.11855537045356834862E10,
    2.11277520115489217587E12, 3.10518229857422583814E14,
    3.18121955943204943306E16, 1.71086294081043136091E18,
};
#endif
#ifdef DEC
static unsigned short RP[16] = {
    01502160161235006434400144500052343013521600356240144153,
    01541420130247000331000036670055411017370300477720176635,
};
static unsigned short RQ[32] = {
    /*0040200,0000000,0000000,0000000,*/
    00423710144025003226501361370044451013313101324200151466,
    00464700144641007254000306360050446012660000450420044243,
    00523650172633011030100710630054215003242400622720043513,
    00557420005013017173100723350057275017064600366630013134,
};
#endif
#ifdef IBMPC
static unsigned short RP[16] = {
    0x8325, 0xad1c, 0xdc53, 0xc1f1, 0x990d, 0xc772, 0x7751, 0x427c,
    0x00f7, 0xe0d9, 0x5614, 0xc2ec, 0x5fb4, 0x69ff, 0x3ef8, 0x4341,
};
static unsigned short RQ[32] = {
    /*0x0000,0x0000,0x0000,0x3ff0,*/
    0xb78c, 0xa696, 0x3902, 0x407f, 0x1a67, 0x36a2, 0x36cb, 0x4105,
    0x0634, 0x2eac, 0x1934, 0x4187, 0x4914, 0x0944, 0xd5b0, 0x4204,
    0x2e46, 0x7218, 0xbeb3, 0x427e, 0x48e9, 0x8c97, 0xa6a2, 0x42f1,
    0x2e9c, 0x7e7b, 0x4141, 0x435c, 0x62cc, 0xc7b6, 0xbe34, 0x43b7,
};
#endif
#ifdef MIEEE
static unsigned short RP[16] = {
    0xc1f1, 0xdc53, 0xad1c, 0x8325, 0x427c, 0x7751, 0xc772, 0x990d,
    0xc2ec, 0x5614, 0xe0d9, 0x00f7, 0x4341, 0x3ef8, 0x69ff, 0x5fb4,
};
static unsigned short RQ[32] = {
    /*0x3ff0,0x0000,0x0000,0x0000,*/
    0x407f, 0x3902, 0xa696, 0xb78c, 0x4105, 0x36cb, 0x36a2, 0x1a67,
    0x4187, 0x1934, 0x2eac, 0x0634, 0x4204, 0xd5b0, 0x0944, 0x4914,
    0x427e, 0xbeb3, 0x7218, 0x2e46, 0x42f1, 0xa6a2, 0x8c97, 0x48e9,
    0x435c, 0x4141, 0x7e7b, 0x2e9c, 0x43b7, 0xbe34, 0xc7b6, 0x62cc,
};
#endif

#ifdef ANSIPROT
extern double polevl(doublevoid *, int);
extern double p1evl(doublevoid *, int);
extern double log(double);
extern double sin(double);
extern double cos(double);
extern double sqrt(double);
double j0(double);
#else
double polevl(), p1evl(), log(), sin(), cos(), sqrt();
double j0();
#endif
extern double TWOOPI, SQ2OPI, PIO4;

double j0(x) double x;
{
  double w, z, p, q, xn;

  if (x < 0)
    x = -x;

  if (x <= 5.0) {
    z = x * x;
    if (x < 1.0e-5)
      return (1.0 - z / 4.0);

    p = (z - DR1) * (z - DR2);
    p = p * polevl(z, RP, 3) / p1evl(z, RQ, 8);
    return (p);
  }

  w = 5.0 / x;
  q = 25.0 / (x * x);
  p = polevl(q, PP, 6) / polevl(q, PQ, 6);
  q = polevl(q, QP, 7) / p1evl(q, QQ, 7);
  xn = x - PIO4;
  p = p * cos(xn) - w * q * sin(xn);
  return (p * SQ2OPI / sqrt(x));
}

/* y0() 2 */
/* Bessel function of second kind, order zero */

/* Rational approximation coefficients YP[], YQ[] are used here.
 * The function computed is  y0(x)  -  2 * log(x) * j0(x) / PI,
 * whose value at x = 0 is  2 * ( log(0.5) + EUL ) / PI
 * = 0.073804295108687225.
 */


/*
#define PIO4 .78539816339744830962
#define SQ2OPI .79788456080286535588
*/

extern double MAXNUM;

double y0(x) double x;
{
  double w, z, p, q, xn;

  if (x <= 5.0) {
    if (x <= 0.0) {
      mtherr("y0", DOMAIN);
      return (-MAXNUM);
    }
    z = x * x;
    w = polevl(z, YP, 7) / p1evl(z, YQ, 7);
    w += TWOOPI * log(x) * j0(x);
    return (w);
  }

  w = 5.0 / x;
  z = 25.0 / (x * x);
  p = polevl(z, PP, 6) / polevl(z, PQ, 6);
  q = polevl(z, QP, 7) / p1evl(z, QQ, 7);
  xn = x - PIO4;
  p = p * sin(xn) + w * q * cos(xn);
  return (p * SQ2OPI / sqrt(x));
}

Messung V0.5 in Prozent
C=96 H=94 G=94

¤ Dauer der Verarbeitung: 0.8 Sekunden  ¤

*© 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.