home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / Cephes.pod < prev    next >
Encoding:
Text File  |  2002-09-09  |  115.2 KB  |  4,776 lines

  1. =head1 NAME
  2.  
  3. Math::Cephes - perl interface to the cephes math library
  4.  
  5. =head1 SYNOPSIS
  6.  
  7.   use Math::Cephes qw(:all);
  8.  
  9. =head1 DESCRIPTION
  10.  
  11.   This module provides an interface to over 150 functions of the 
  12.   cephes math library of Stephen Moshier. No functions are exported 
  13.   by default, but rather must be imported explicitly, as in
  14.  
  15.      use Math::Cephes qw(sin cos);
  16.  
  17.   There are a number of export tags defined which allow
  18.   importing groups of functions:
  19.  
  20. =over 4
  21.  
  22. =item  use Math::Cephes qw(:constants);
  23.  
  24.   imports the variables
  25.  
  26.   $PI      :   3.14159265358979323846      #  pi
  27.   $PIO2    :   1.57079632679489661923      #  pi/2
  28.   $PIO4    :   0.785398163397448309616     #  pi/4
  29.   $SQRT2   :   1.41421356237309504880      #  sqrt(2)
  30.   $SQRTH   :   0.707106781186547524401     #  sqrt(2)/2
  31.   $LOG2E   :   1.4426950408889634073599    #  1/log(2)
  32.   $SQ2OPI  :   0.79788456080286535587989   #  sqrt( 2/pi )
  33.   $LOGE2   :   0.693147180559945309417     #  log(2)
  34.   $LOGSQ2  :   0.346573590279972654709     #  log(2)/2
  35.   $THPIO4  :   2.35619449019234492885      #  3*pi/4
  36.   $TWOOPI  :   0.636619772367581343075535  #  2/pi
  37.  
  38.   As well, there are 4 machine-specific numbers available:
  39.  
  40.    $MACHEP : machine roundoff error
  41.    $MAXLOG : maximum log on the machine
  42.    $MINLOG : minimum log on the machine
  43.    $MAXNUM : largest number represented
  44.  
  45. =item  use Math::Cephes qw(:trigs);
  46.  
  47.   imports 
  48.  
  49.  acos:  Inverse circular cosine
  50.  asin:  Inverse circular sine
  51.  atan:  Inverse circular tangent (arctangent)
  52.  atan2:  Quadrant correct inverse circular tangent
  53.  cos:  Circular cosine
  54.  cosdg:  Circular cosine of angle in degrees
  55.  cot:  Circular cotangent
  56.  cotdg:  Circular cotangent of argument in degrees
  57.  hypot: hypotenuse associated with the sides of a right triangle
  58.  radian: Degrees, minutes, seconds to radians
  59.  sin:  Circular sine
  60.  sindg:  Circular sine of angle in degrees
  61.  tan:  Circular tangent
  62.  tandg:  Circular tangent of argument in degrees
  63.  cosm1:  Relative error approximations for function arguments near unity
  64.  
  65. =item  use Math::Cephes qw(:hypers);
  66.  
  67.   imports 
  68.  
  69.  acosh:  Inverse hyperbolic cosine
  70.  asinh:  Inverse hyperbolic sine
  71.  atanh:  Inverse hyperbolic tangent
  72.  cosh:  Hyperbolic cosine
  73.  sinh:  Hyperbolic sine
  74.  tanh:  Hyperbolic tangent
  75.  
  76. =item  use Math::Cephes qw(:explog);
  77.  
  78.   imports 
  79.  
  80.  exp:  Exponential function
  81.  expxx: exp(x*x)
  82.  exp10:  Base 10 exponential function (Common antilogarithm)
  83.  exp2:  Base 2 exponential function
  84.  log:  Natural logarithm
  85.  log10:  Common logarithm
  86.  log2:  Base 2 logarithm
  87.  log1p,expm1:  Relative error approximations for function arguments near unity.
  88.  
  89. =item  use Math::Cephes qw(:cmplx);
  90.  
  91.   imports 
  92.  
  93.  new_cmplx: create a new complex number object
  94.  cabs:  Complex absolute value
  95.  cacos:  Complex circular arc cosine
  96.  cacosh: Complex inverse hyperbolic cosine
  97.  casin:  Complex circular arc sine
  98.  casinh: Complex inverse hyperbolic sine
  99.  catan:  Complex circular arc tangent
  100.  catanh: Complex inverse hyperbolic tangent
  101.  ccos:  Complex circular cosine
  102.  ccosh: Complex hyperbolic cosine
  103.  ccot:  Complex circular cotangent
  104.  cexp:  Complex exponential function
  105.  clog:  Complex natural logarithm
  106.  cadd: add two complex numbers
  107.  csub: subtract two complex numbers
  108.  cmul: multiply two complex numbers
  109.  cdiv: divide two complex numbers
  110.  cmov: copy one complex number to another
  111.  cneg: negate a complex number
  112.  cpow: Complex power function 
  113.  csin:  Complex circular sine
  114.  csinh: Complex hyperbolic sine
  115.  csqrt:  Complex square root
  116.  ctan:  Complex circular tangent
  117.  ctanh: Complex hyperbolic tangent
  118.  
  119. =item  use Math::Cephes qw(:utils);
  120.  
  121.   imports 
  122.  
  123.  cbrt:  Cube root
  124.  ceil:  ceil
  125.  drand:  Pseudorandom number generator
  126.  fabs:  Absolute value
  127.  fac:  Factorial function
  128.  floor:  floor
  129.  frexp:  frexp
  130.  ldexp:  multiplies x by 2**n.
  131.  lrand:  Pseudorandom number generator
  132.  lsqrt:  Integer square root
  133.  pow:  Power function
  134.  powi:  Real raised to integer power
  135.  round:  Round double to nearest or even integer valued double
  136.  sqrt:  Square root
  137.  
  138. =item  use Math::Cephes qw(:bessels);
  139.  
  140.   imports 
  141.  
  142.  i0:  Modified Bessel function of order zero
  143.  i0e:  Modified Bessel function of order zero, exponentially scaled
  144.  i1:  Modified Bessel function of order one
  145.  i1e:  Modified Bessel function of order one, exponentially scaled
  146.  iv:  Modified Bessel function of noninteger order
  147.  j0:  Bessel function of order zero
  148.  j1:  Bessel function of order one
  149.  jn:  Bessel function of integer order
  150.  jv:  Bessel function of noninteger order
  151.  k0:  Modified Bessel function, third kind, order zero
  152.  k0e:  Modified Bessel function, third kind, order zero, exponentially scaled
  153.  k1:  Modified Bessel function, third kind, order one
  154.  k1e:  Modified Bessel function, third kind, order one, exponentially scaled
  155.  kn:  Modified Bessel function, third kind, integer order
  156.  y0:  Bessel function of the second kind, order zero
  157.  y1:  Bessel function of second kind of order one
  158.  yn:  Bessel function of second kind of integer order
  159.  yv:  Bessel function Yv with noninteger v
  160.  
  161. =item  use Math::Cephes qw(:dists);
  162.  
  163.   imports 
  164.  
  165.  bdtr:  Binomial distribution
  166.  bdtrc:  Complemented binomial distribution
  167.  bdtri:  Inverse binomial distribution
  168.  btdtr:  Beta distribution
  169.  chdtr:  Chi-square distribution
  170.  chdtrc:  Complemented Chi-square distribution
  171.  chdtri:  Inverse of complemented Chi-square distribution
  172.  fdtr:  F distribution
  173.  fdtrc:  Complemented F distribution
  174.  fdtri:  Inverse of complemented F distribution
  175.  gdtr:  Gamma distribution function
  176.  gdtrc:  Complemented gamma distribution function
  177.  nbdtr:  Negative binomial distribution
  178.  nbdtrc:  Complemented negative binomial distribution
  179.  nbdtri:  Functional inverse of negative binomial distribution
  180.  ndtr:  Normal distribution function
  181.  ndtri:  Inverse of Normal distribution function
  182.  pdtr:  Poisson distribution
  183.  pdtrc:  Complemented poisson distribution
  184.  pdtri:  Inverse Poisson distribution
  185.  stdtr:  Student's t distribution
  186.  stdtri:  Functional inverse of Student's t distribution
  187.  
  188. =item  use Math::Cephes qw(:gammas);
  189.  
  190.   imports 
  191.  
  192.  fac:  Factorial function
  193.  gamma:  Gamma function
  194.  igam:  Incomplete gamma integral
  195.  igamc:  Complemented incomplete gamma integral
  196.  igami:  Inverse of complemented imcomplete gamma integral
  197.  psi:  Psi (digamma) function
  198.  rgamma:  Reciprocal gamma function
  199.  
  200. =item  use Math::Cephes qw(:betas);
  201.  
  202.   imports 
  203.  
  204.  beta:  Beta function
  205.  incbet:  Incomplete beta integral
  206.  incbi:  Inverse of imcomplete beta integral
  207.  lbeta:  Natural logarithm of |beta|
  208.  
  209. =item  use Math::Cephes qw(:elliptics);
  210.  
  211.   imports 
  212.  
  213.  ellie:  Incomplete elliptic integral of the second kind
  214.  ellik:  Incomplete elliptic integral of the first kind
  215.  ellpe:  Complete elliptic integral of the second kind
  216.  ellpj:  Jacobian Elliptic Functions
  217.  ellpk:  Complete elliptic integral of the first kind
  218.  
  219. =item  use Math::Cephes qw(:hypergeometrics);
  220.  
  221.   imports 
  222.  
  223.  hyp2f0:  Gauss hypergeometric function   F
  224.  hyp2f1:  Gauss hypergeometric function   F
  225.  hyperg:  Confluent hypergeometric function
  226.  onef2:  Hypergeometric function 1F2
  227.  threef0:  Hypergeometric function 3F0
  228.  
  229. =item  use Math::Cephes qw(:misc);
  230.  
  231.   imports 
  232.  
  233.  airy:  Airy function
  234.  bernum: Bernoulli numbers
  235.  dawsn:  Dawson's Integral
  236.  ei: Exponential integral
  237.  erf:  Error function
  238.  erfc:  Complementary error function 
  239.  expn:  Exponential integral En
  240.  fresnl:  Fresnel integral
  241.  plancki: Integral of Planck's black body radiation formula
  242.  polylog: Polylogarithm function
  243.  shichi:  Hyperbolic sine and cosine integrals
  244.  sici:  Sine and cosine integrals
  245.  simpson: Simpson's rule to find an integral
  246.  spence:  Dilogarithm
  247.  struve:  Struve function
  248.  vecang: angle between two vectors
  249.  zeta:  Riemann zeta function of two arguments
  250.  zetac:  Riemann zeta function
  251.  
  252. =item  use Math::Cephes qw(:fract);
  253.  
  254.   imports 
  255.  
  256.  new_fract: create a new fraction object
  257.  radd: add two fractions
  258.  rmul: multiply two fractions
  259.  rsub: subtracttwo fractions
  260.  rdiv: divide two fractions
  261.  euclid: finds the greatest common divisor
  262.  
  263. =back
  264.  
  265. =head1 FUNCTIONS
  266.  
  267.   A description of the various functions available follows.
  268.  
  269. =over 4 
  270.  
  271. =item I<acosh>: Inverse hyperbolic cosine
  272.  
  273.  SYNOPSIS:
  274.  
  275.  # double x, y, acosh();
  276.  
  277.  $y = acosh( $x );
  278.  
  279.  DESCRIPTION:
  280.  
  281.  Returns inverse hyperbolic cosine of argument.
  282.  
  283.  If 1 <= x < 1.5, a rational approximation
  284.  
  285.     sqrt(z) * P(z)/Q(z)
  286.  
  287.  where z = x-1, is used.  Otherwise,
  288.  
  289.  acosh(x)  =  log( x + sqrt( (x-1)(x+1) ).
  290.  
  291.  ACCURACY:
  292.                       Relative error:
  293.  arithmetic   domain     # trials      peak         rms
  294.     DEC       1,3         30000       4.2e-17     1.1e-17
  295.     IEEE      1,3         30000       4.6e-16     8.7e-17
  296.  
  297.  ERROR MESSAGES:
  298.  
  299.    message         condition      value returned
  300.  acosh domain       |x| < 1            NAN
  301.  
  302. =item I<airy>: Airy function
  303.  
  304.  SYNOPSIS:
  305.  
  306.  # double x, ai, aiprime, bi, biprime;
  307.  # int airy();
  308.  
  309.  ($flag, $ai, $aiprime, $bi, $biprime) = airy( $x );
  310.  
  311.  DESCRIPTION:
  312.  
  313.  Solution of the differential equation
  314.  
  315.     y"(x) = xy.
  316.  
  317.  The function returns the two independent solutions Ai, Bi
  318.  and their first derivatives Ai'(x), Bi'(x).
  319.  
  320.  Evaluation is by power series summation for small x,
  321.  by rational minimax approximations for large x.
  322.  
  323.  ACCURACY:
  324.  Error criterion is absolute when function <= 1, relative
  325.  when function > 1, except * denotes relative error criterion.
  326.  For large negative x, the absolute error increases as x^1.5.
  327.  For large positive x, the relative error increases as x^1.5.
  328.  
  329.  Arithmetic  domain   function  # trials      peak         rms
  330.  IEEE        -10, 0     Ai        10000       1.6e-15     2.7e-16
  331.  IEEE          0, 10    Ai        10000       2.3e-14*    1.8e-15*
  332.  IEEE        -10, 0     Ai'       10000       4.6e-15     7.6e-16
  333.  IEEE          0, 10    Ai'       10000       1.8e-14*    1.5e-15*
  334.  IEEE        -10, 10    Bi        30000       4.2e-15     5.3e-16
  335.  IEEE        -10, 10    Bi'       30000       4.9e-15     7.3e-16
  336.  DEC         -10, 0     Ai         5000       1.7e-16     2.8e-17
  337.  DEC           0, 10    Ai         5000       2.1e-15*    1.7e-16*
  338.  DEC         -10, 0     Ai'        5000       4.7e-16     7.8e-17
  339.  DEC           0, 10    Ai'       12000       1.8e-15*    1.5e-16*
  340.  DEC         -10, 10    Bi        10000       5.5e-16     6.8e-17
  341.  DEC         -10, 10    Bi'        7000       5.3e-16     8.7e-17
  342.  
  343. =item I<radian>: Degrees, minutes, seconds to radians
  344.  
  345.  SYNOPSIS:
  346.  
  347.  # double d, m, s, radian();
  348.  
  349.  $r = radian( $d, $m, $s );
  350.  
  351.  DESCRIPTION:
  352.  
  353.  Converts an angle of degrees, minutes, seconds to radians.
  354.  
  355. =item I<hypot>: returns the hypotenuse associated with the sides of a right triangle
  356.  
  357.  SYNOPSIS:
  358.  
  359.  # double a, b, c, hypot();
  360.  
  361.  $c = hypot( $a, $b );
  362.  
  363.  DESCRIPTION:
  364.  
  365.  Calculates the hypotenuse associated with the sides of a 
  366.  right triangle, according to
  367.  
  368.     c = sqrt( a**2 + b**2)
  369.  
  370. =item I<asin>: Inverse circular sine
  371.  
  372.  SYNOPSIS:
  373.  
  374.  # double x, y, asin();
  375.  
  376.  $y = asin( $x );
  377.  
  378.  DESCRIPTION:
  379.  
  380.  Returns radian angle between -pi/2 and +pi/2 whose sine is x.
  381.  
  382.  A rational function of the form x + x**3 P(x**2)/Q(x**2)
  383.  is used for |x| in the interval [0, 0.5].  If |x| > 0.5 it is
  384.  transformed by the identity
  385.  
  386.     asin(x) = pi/2 - 2 asin( sqrt( (1-x)/2 ) ).
  387.  
  388.  ACCURACY:
  389.  
  390.                       Relative error:
  391.  arithmetic   domain     # trials      peak         rms
  392.     DEC      -1, 1        40000       2.6e-17     7.1e-18
  393.     IEEE     -1, 1        10^6        1.9e-16     5.4e-17
  394.  
  395.  ERROR MESSAGES:
  396.  
  397.    message         condition      value returned
  398.  asin domain        |x| > 1           NAN
  399.  
  400. =item I<acos>: Inverse circular cosine
  401.  
  402.  SYNOPSIS:
  403.  
  404.  # double x, y, acos();
  405.  
  406.  $y = acos( $x );
  407.  
  408.  DESCRIPTION:
  409.  
  410.  Returns radian angle between 0 and pi whose cosine
  411.  is x.
  412.  
  413.  Analytically, acos(x) = pi/2 - asin(x).  However if |x| is
  414.  near 1, there is cancellation error in subtracting asin(x)
  415.  from pi/2.  Hence if x < -0.5,
  416.  
  417.     acos(x) =     pi - 2.0 * asin( sqrt((1+x)/2) );
  418.  
  419.  or if x > +0.5,
  420.  
  421.     acos(x) =     2.0 * asin(  sqrt((1-x)/2) ).
  422.  
  423.  ACCURACY:
  424.  
  425.                       Relative error:
  426.  arithmetic   domain     # trials      peak         rms
  427.     DEC       -1, 1       50000       3.3e-17     8.2e-18
  428.     IEEE      -1, 1       10^6        2.2e-16     6.5e-17
  429.  
  430.  ERROR MESSAGES:
  431.  
  432.    message         condition      value returned
  433.  asin domain        |x| > 1           NAN
  434.  
  435. =item I<asinh>: Inverse hyperbolic sine
  436.  
  437.  SYNOPSIS:
  438.  
  439.  # double x, y, asinh();
  440.  
  441.  $y = asinh( $x );
  442.  
  443.  DESCRIPTION:
  444.  
  445.  Returns inverse hyperbolic sine of argument.
  446.  
  447.  If |x| < 0.5, the function is approximated by a rational
  448.  form  x + x**3 P(x)/Q(x).  Otherwise,
  449.  
  450.      asinh(x) = log( x + sqrt(1 + x*x) ).
  451.  
  452.  ACCURACY:
  453.  
  454.                       Relative error:
  455.  arithmetic   domain     # trials      peak         rms
  456.     DEC      -3,3         75000       4.6e-17     1.1e-17
  457.     IEEE     -1,1         30000       3.7e-16     7.8e-17
  458.     IEEE      1,3         30000       2.5e-16     6.7e-17
  459.  
  460. =item I<atan>: Inverse circular tangent (arctangent)
  461.  
  462.  SYNOPSIS:
  463.  
  464.  # double x, y, atan();
  465.  
  466.  $y = atan( $x );
  467.  
  468.  DESCRIPTION:
  469.  
  470.  Returns radian angle between -pi/2 and +pi/2 whose tangent
  471.  is x.
  472.  
  473.  Range reduction is from three intervals into the interval
  474.  from zero to 0.66.  The approximant uses a rational
  475.  function of degree 4/5 of the form x + x**3 P(x)/Q(x).
  476.  
  477.  ACCURACY:
  478.  
  479.                       Relative error:
  480.  arithmetic   domain     # trials      peak         rms
  481.     DEC       -10, 10     50000       2.4e-17     8.3e-18
  482.     IEEE      -10, 10      10^6       1.8e-16     5.0e-17
  483.  
  484. =item I<atan2>: Quadrant correct inverse circular tangent
  485.  
  486.  SYNOPSIS:
  487.  
  488.  # double x, y, z, atan2();
  489.  
  490.  $z = atan2( $y, $x );
  491.  
  492.  DESCRIPTION:
  493.  
  494.  Returns radian angle whose tangent is y/x.
  495.  Define compile time symbol ANSIC = 1 for ANSI standard,
  496.  range -PI < z <= +PI, args (y,x); else ANSIC = 0 for range
  497.  0 to 2PI, args (x,y).
  498.  
  499.  ACCURACY:
  500.  
  501.                       Relative error:
  502.  arithmetic   domain     # trials      peak         rms
  503.     IEEE      -10, 10      10^6       2.5e-16     6.9e-17
  504.  See atan.c.
  505.  
  506. =item I<atanh>: Inverse hyperbolic tangent
  507.  
  508.  SYNOPSIS:
  509.  
  510.  # double x, y, atanh();
  511.  
  512.  $y = atanh( $x );
  513.  
  514.  DESCRIPTION:
  515.  
  516.  Returns inverse hyperbolic tangent of argument in the range
  517.  MINLOG to MAXLOG.
  518.  
  519.  If |x| < 0.5, the rational form x + x**3 P(x)/Q(x) is
  520.  employed.  Otherwise,
  521.         atanh(x) = 0.5 * log( (1+x)/(1-x) ).
  522.  
  523.  ACCURACY:
  524.  
  525.                       Relative error:
  526.  arithmetic   domain     # trials      peak         rms
  527.     DEC       -1,1        50000       2.4e-17     6.4e-18
  528.     IEEE      -1,1        30000       1.9e-16     5.2e-17
  529.  
  530. =item I<bdtr>: Binomial distribution
  531.  
  532.  SYNOPSIS:
  533.  
  534.  # int k, n;
  535.  # double p, y, bdtr();
  536.  
  537.  $y = bdtr( $k, $n, $p );
  538.  
  539.  DESCRIPTION:
  540.  
  541.  Returns the sum of the terms 0 through k of the Binomial
  542.  probability density:
  543.  
  544.    k
  545.    --  ( n )   j      n-j
  546.    >   (   )  p  (1-p)
  547.    --  ( j )
  548.   j=0
  549.  
  550.  The terms are not summed directly; instead the incomplete
  551.  beta integral is employed, according to the formula
  552.  
  553.   y = bdtr( k, n, p ) = incbet( n-k, k+1, 1-p ).
  554.  
  555.  The arguments must be positive, with p ranging from 0 to 1.
  556.  
  557.  ACCURACY:
  558.  
  559.  Tested at random points (a,b,p), with p between 0 and 1.
  560.  
  561.                a,b                     Relative error:
  562.  arithmetic  domain     # trials      peak         rms
  563.   For p between 0.001 and 1:
  564.     IEEE     0,100       100000      4.3e-15     2.6e-16
  565.  See also incbet.c.
  566.  
  567.  ERROR MESSAGES:
  568.  
  569.    message         condition      value returned
  570.  bdtr domain         k < 0            0.0
  571.                      n < k
  572.                      x < 0, x > 1
  573.  
  574. =item I<bdtrc>: Complemented binomial distribution
  575.  
  576.  SYNOPSIS:
  577.  
  578.  # int k, n;
  579.  # double p, y, bdtrc();
  580.  
  581.  $y = bdtrc( $k, $n, $p );
  582.  
  583.  DESCRIPTION:
  584.  
  585.  Returns the sum of the terms k+1 through n of the Binomial
  586.  probability density:
  587.  
  588.    n
  589.    --  ( n )   j      n-j
  590.    >   (   )  p  (1-p)
  591.    --  ( j )
  592.   j=k+1
  593.  
  594.  The terms are not summed directly; instead the incomplete
  595.  beta integral is employed, according to the formula
  596.  
  597.  y = bdtrc( k, n, p ) = incbet( k+1, n-k, p ).
  598.  
  599.  The arguments must be positive, with p ranging from 0 to 1.
  600.  
  601.  ACCURACY:
  602.  
  603.  Tested at random points (a,b,p).
  604.  
  605.                a,b                     Relative error:
  606.  arithmetic  domain     # trials      peak         rms
  607.   For p between 0.001 and 1:
  608.     IEEE     0,100       100000      6.7e-15     8.2e-16
  609.   For p between 0 and .001:
  610.     IEEE     0,100       100000      1.5e-13     2.7e-15
  611.  
  612.  ERROR MESSAGES:
  613.  
  614.    message         condition      value returned
  615.  bdtrc domain      x<0, x>1, n<k       0.0
  616.  
  617. =item I<bdtri>: Inverse binomial distribution
  618.  
  619.  SYNOPSIS:
  620.  
  621.  # int k, n;
  622.  # double p, y, bdtri();
  623.  
  624.  $p = bdtr( $k, $n, $y );
  625.  
  626.  DESCRIPTION:
  627.  
  628.  Finds the event probability p such that the sum of the
  629.  terms 0 through k of the Binomial probability density
  630.  is equal to the given cumulative probability y.
  631.  
  632.  This is accomplished using the inverse beta integral
  633.  function and the relation
  634.  
  635.  1 - p = incbi( n-k, k+1, y ).
  636.  
  637.  ACCURACY:
  638.  
  639.  Tested at random points (a,b,p).
  640.  
  641.                a,b                     Relative error:
  642.  arithmetic  domain     # trials      peak         rms
  643.   For p between 0.001 and 1:
  644.     IEEE     0,100       100000      2.3e-14     6.4e-16
  645.     IEEE     0,10000     100000      6.6e-12     1.2e-13
  646.   For p between 10^-6 and 0.001:
  647.     IEEE     0,100       100000      2.0e-12     1.3e-14
  648.     IEEE     0,10000     100000      1.5e-12     3.2e-14
  649.  See also incbi.c.
  650.  
  651.  ERROR MESSAGES:
  652.  
  653.    message         condition      value returned
  654.  bdtri domain     k < 0, n <= k         0.0
  655.                   x < 0, x > 1
  656.  
  657. =item I<beta>: Beta function
  658.  
  659.  SYNOPSIS:
  660.  
  661.  # double a, b, y, beta();
  662.  
  663.  $y = beta( $a, $b );
  664.  
  665.  DESCRIPTION:
  666.  
  667.                    -     -
  668.                   | (a) | (b)
  669.  beta( a, b )  =  -----------.
  670.                      -
  671.                     | (a+b)
  672.  
  673.  For large arguments the logarithm of the function is
  674.  evaluated using lgam(), then exponentiated.
  675.  
  676.  ACCURACY:
  677.  
  678.                       Relative error:
  679.  arithmetic   domain     # trials      peak         rms
  680.     DEC        0,30        1700       7.7e-15     1.5e-15
  681.     IEEE       0,30       30000       8.1e-14     1.1e-14
  682.  
  683.  ERROR MESSAGES:
  684.  
  685.    message         condition          value returned
  686.  beta overflow    log(beta) > MAXLOG       0.0
  687.                   a or b <0 integer        0.0
  688.  
  689. =item I<lbeta>: Natural logarithm of |beta|
  690.  
  691.  SYNOPSIS:
  692.  
  693.  # double a, b;
  694.  
  695.  # double lbeta( a, b );
  696.  
  697.  $y = lbeta( $a, $b);
  698.  
  699. =item I<btdtr>: Beta distribution
  700.  
  701.  SYNOPSIS:
  702.  
  703.  # double a, b, x, y, btdtr();
  704.  
  705.  $y = btdtr( $a, $b, $x );
  706.  
  707.  DESCRIPTION:
  708.  
  709.  Returns the area from zero to x under the beta density
  710.  function:
  711.  
  712.                           x
  713.             -             -
  714.            | (a+b)       | |  a-1      b-1
  715.  P(x)  =  ----------     |   t    (1-t)    dt
  716.            -     -     | |
  717.           | (a) | (b)   -
  718.                          0
  719.  
  720.  This function is identical to the incomplete beta
  721.  integral function incbet(a, b, x).
  722.  
  723.  The complemented function is
  724.  
  725.  1 - P(1-x)  =  incbet( b, a, x );
  726.  
  727.  ACCURACY:
  728.  
  729.  See incbet.c.
  730.  
  731. =item I<cbrt>: Cube root
  732.  
  733.  SYNOPSIS:
  734.  
  735.  # double x, y, cbrt();
  736.  
  737.  $y = cbrt( $x );
  738.  
  739.  DESCRIPTION:
  740.  
  741.  Returns the cube root of the argument, which may be negative.
  742.  
  743.  Range reduction involves determining the power of 2 of
  744.  the argument.  A polynomial of degree 2 applied to the
  745.  mantissa, and multiplication by the cube root of 1, 2, or 4
  746.  approximates the root to within about 0.1%.  Then Newton's
  747.  iteration is used three times to converge to an accurate
  748.  result.
  749.  
  750.  ACCURACY:
  751.  
  752.                       Relative error:
  753.  arithmetic   domain     # trials      peak         rms
  754.     DEC        -10,10     200000      1.8e-17     6.2e-18
  755.     IEEE       0,1e308     30000      1.5e-16     5.0e-17
  756.  
  757. =item I<chdtr>: Chi-square distribution
  758.  
  759.  SYNOPSIS:
  760.  
  761.  # double v, x, y, chdtr();
  762.  
  763.  $y = chdtr( $v, $x );
  764.  
  765.  DESCRIPTION:
  766.  
  767.  Returns the area under the left hand tail (from 0 to x)
  768.  of the Chi square probability density function with
  769.  v degrees of freedom.
  770.  
  771.                                   inf.
  772.                                     -
  773.                         1          | |  v/2-1  -t/2
  774.   P( x | v )   =   -----------     |   t      e     dt
  775.                     v/2  -       | |
  776.                    2    | (v/2)   -
  777.                                    x
  778.  
  779.  where x is the Chi-square variable.
  780.  
  781.  The incomplete gamma integral is used, according to the
  782.  formula
  783.  
  784.     y = chdtr( v, x ) = igam( v/2.0, x/2.0 ).
  785.  
  786.  The arguments must both be positive.
  787.  
  788.  ACCURACY:
  789.  
  790.  See igam().
  791.  
  792.  ERROR MESSAGES:
  793.  
  794.    message         condition      value returned
  795.  chdtr domain   x < 0 or v < 1        0.0
  796.  
  797. =item I<chdtrc>: Complemented Chi-square distribution
  798.  
  799.  SYNOPSIS:
  800.  
  801.  # double v, x, y, chdtrc();
  802.  
  803.  $y = chdtrc( $v, $x );
  804.  
  805.  DESCRIPTION:
  806.  
  807.  Returns the area under the right hand tail (from x to
  808.  infinity) of the Chi square probability density function
  809.  with v degrees of freedom:
  810.  
  811.                                   inf.
  812.                                     -
  813.                         1          | |  v/2-1  -t/2
  814.   P( x | v )   =   -----------     |   t      e     dt
  815.                     v/2  -       | |
  816.                    2    | (v/2)   -
  817.                                    x
  818.  
  819.  where x is the Chi-square variable.
  820.  
  821.  The incomplete gamma integral is used, according to the
  822.  formula
  823.  
  824.     y = chdtrc( v, x ) = igamc( v/2.0, x/2.0 ).
  825.  
  826.  The arguments must both be positive.
  827.  
  828.  ACCURACY:
  829.  
  830.  See igamc().
  831.  
  832.  ERROR MESSAGES:
  833.  
  834.    message         condition      value returned
  835.  chdtrc domain  x < 0 or v < 1        0.0
  836.  
  837. =item I<chdtri>: Inverse of complemented Chi-square distribution
  838.  
  839.  SYNOPSIS:
  840.  
  841.  # double df, x, y, chdtri();
  842.  
  843.  $x = chdtri( $df, $y );
  844.  
  845.  DESCRIPTION:
  846.  
  847.  Finds the Chi-square argument x such that the integral
  848.  from x to infinity of the Chi-square density is equal
  849.  to the given cumulative probability y.
  850.  
  851.  This is accomplished using the inverse gamma integral
  852.  function and the relation
  853.  
  854.     x/2 = igami( df/2, y );
  855.  
  856.  ACCURACY:
  857.  
  858.  See igami.c.
  859.  
  860.  ERROR MESSAGES:
  861.  
  862.    message         condition      value returned
  863.  chdtri domain   y < 0 or y > 1        0.0
  864.                      v < 1
  865.  
  866. =item I<clog>: Complex natural logarithm
  867.  
  868.  SYNOPSIS:
  869.  
  870.  # void clog();
  871.  # cmplx z, w;
  872.  
  873.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  874.  $w = new_cmplx();
  875.  clog($z, $w );
  876.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  877.  
  878.  DESCRIPTION:
  879.  
  880.  Returns complex logarithm to the base e (2.718...) of
  881.  the complex argument x.
  882.  
  883.  If z = x + iy, r = sqrt( x**2 + y**2 ),
  884.  then
  885.        w = log(r) + i arctan(y/x).
  886.  
  887.  The arctangent ranges from -PI to +PI.
  888.  
  889.  ACCURACY:
  890.  
  891.                       Relative error:
  892.  arithmetic   domain     # trials      peak         rms
  893.     DEC       -10,+10      7000       8.5e-17     1.9e-17
  894.     IEEE      -10,+10     30000       5.0e-15     1.1e-16
  895.  
  896.  Larger relative error can be observed for z near 1 +i0.
  897.  In IEEE arithmetic the peak absolute error is 5.2e-16, rms
  898.  absolute error 1.0e-16.
  899.  
  900. =item I<cexp>: Complex exponential function
  901.  
  902.  SYNOPSIS:
  903.  
  904.  # void cexp();
  905.  # cmplx z, w;
  906.  
  907.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  908.  $w = new_cmplx();
  909.  cexp($z, $w );
  910.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  911.  
  912.  DESCRIPTION:
  913.  
  914.  Returns the exponential of the complex argument z
  915.  into the complex result w.
  916.  
  917.  If
  918.      z = x + iy,
  919.      r = exp(x),
  920.  
  921.  then
  922.  
  923.      w = r cos y + i r sin y.
  924.  
  925.  ACCURACY:
  926.  
  927.                       Relative error:
  928.  arithmetic   domain     # trials      peak         rms
  929.     DEC       -10,+10      8700       3.7e-17     1.1e-17
  930.     IEEE      -10,+10     30000       3.0e-16     8.7e-17
  931.  
  932. =item I<csin>: Complex circular sine
  933.  
  934.  SYNOPSIS:
  935.  
  936.  # void csin();
  937.  # cmplx z, w;
  938.  
  939.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  940.  $w = new_cmplx();
  941.  csin($z, $w );
  942.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  943.  
  944.  DESCRIPTION:
  945.  
  946.  If
  947.      z = x + iy,
  948.  
  949.  then
  950.  
  951.      w = sin x  cosh y  +  i cos x sinh y.
  952.  
  953.  ACCURACY:
  954.  
  955.                       Relative error:
  956.  arithmetic   domain     # trials      peak         rms
  957.     DEC       -10,+10      8400       5.3e-17     1.3e-17
  958.     IEEE      -10,+10     30000       3.8e-16     1.0e-16
  959.  Also tested by csin(casin(z)) = z.
  960.  
  961. =item I<ccos>: Complex circular cosine
  962.  
  963.  SYNOPSIS:
  964.  
  965.  # void ccos();
  966.  # cmplx z, w;
  967.  
  968.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  969.  $w = new_cmplx();
  970.  ccos($z, $w );
  971.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  972.  
  973.  DESCRIPTION:
  974.  
  975.  If
  976.      z = x + iy,
  977.  
  978.  then
  979.  
  980.      w = cos x  cosh y  -  i sin x sinh y.
  981.  
  982.  ACCURACY:
  983.  
  984.                       Relative error:
  985.  arithmetic   domain     # trials      peak         rms
  986.     DEC       -10,+10      8400       4.5e-17     1.3e-17
  987.     IEEE      -10,+10     30000       3.8e-16     1.0e-16
  988.  
  989. =item I<ctan>: Complex circular tangent
  990.  
  991.  SYNOPSIS:
  992.  
  993.  # void ctan();
  994.  # cmplx z, w;
  995.  
  996.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  997.  $w = new_cmplx();
  998.  ctan($z, $w );
  999.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  1000.  
  1001.  DESCRIPTION:
  1002.  
  1003.  If
  1004.      z = x + iy,
  1005.  
  1006.  then
  1007.  
  1008.            sin 2x  +  i sinh 2y
  1009.      w  =  --------------------.
  1010.             cos 2x  +  cosh 2y
  1011.  
  1012.  On the real axis the denominator is zero at odd multiples
  1013.  of PI/2.  The denominator is evaluated by its Taylor
  1014.  series near these points.
  1015.  
  1016.  ACCURACY:
  1017.  
  1018.                       Relative error:
  1019.  arithmetic   domain     # trials      peak         rms
  1020.     DEC       -10,+10      5200       7.1e-17     1.6e-17
  1021.     IEEE      -10,+10     30000       7.2e-16     1.2e-16
  1022.  Also tested by ctan * ccot = 1 and catan(ctan(z))  =  z.
  1023.  
  1024. =item I<ccot>: Complex circular cotangent
  1025.  
  1026.  SYNOPSIS:
  1027.  
  1028.  # void ccot();
  1029.  # cmplx z, w;
  1030.  
  1031.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1032.  $w = new_cmplx();
  1033.  ccot($z, $w );
  1034.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  1035.  
  1036.  DESCRIPTION:
  1037.  
  1038.  If
  1039.      z = x + iy,
  1040.  
  1041.  then
  1042.  
  1043.            sin 2x  -  i sinh 2y
  1044.      w  =  --------------------.
  1045.             cosh 2y  -  cos 2x
  1046.  
  1047.  On the real axis, the denominator has zeros at even
  1048.  multiples of PI/2.  Near these points it is evaluated
  1049.  by a Taylor series.
  1050.  
  1051.  ACCURACY:
  1052.  
  1053.                       Relative error:
  1054.  arithmetic   domain     # trials      peak         rms
  1055.     DEC       -10,+10      3000       6.5e-17     1.6e-17
  1056.     IEEE      -10,+10     30000       9.2e-16     1.2e-16
  1057.  Also tested by ctan * ccot = 1 + i0.
  1058.  
  1059. =item I<casin>: Complex circular arc sine
  1060.  
  1061.  SYNOPSIS:
  1062.  
  1063.  # void casin();
  1064.  # cmplx z, w;
  1065.  
  1066.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1067.  $w = new_cmplx();
  1068.  casin($z, $w );
  1069.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  1070.  
  1071.  DESCRIPTION:
  1072.  
  1073.  Inverse complex sine:
  1074.  
  1075.                                2
  1076.  w = -i clog( iz + csqrt( 1 - z ) ).
  1077.  
  1078.  ACCURACY:
  1079.  
  1080.                       Relative error:
  1081.  arithmetic   domain     # trials      peak         rms
  1082.     DEC       -10,+10     10100       2.1e-15     3.4e-16
  1083.     IEEE      -10,+10     30000       2.2e-14     2.7e-15
  1084.  Larger relative error can be observed for z near zero.
  1085.  Also tested by csin(casin(z)) = z.
  1086.  
  1087. =item I<cacos>: Complex circular arc cosine
  1088.  
  1089.  SYNOPSIS:
  1090.  
  1091.  # void cacos();
  1092.  # cmplx z, w;
  1093.  
  1094.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1095.  $w = new_cmplx();
  1096.  cacos($z, $w );
  1097.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  1098.  
  1099.  DESCRIPTION:
  1100.  
  1101.  w = arccos z  =  PI/2 - arcsin z.
  1102.  
  1103.  ACCURACY:
  1104.  
  1105.                       Relative error:
  1106.  arithmetic   domain     # trials      peak         rms
  1107.     DEC       -10,+10      5200      1.6e-15      2.8e-16
  1108.     IEEE      -10,+10     30000      1.8e-14      2.2e-15
  1109.  
  1110. =item I<catan>: Complex circular arc tangent
  1111.  
  1112.  SYNOPSIS:
  1113.  
  1114.  # void catan();
  1115.  # cmplx z, w;
  1116.  
  1117.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1118.  $w = new_cmplx();
  1119.  catan($z, $w );
  1120.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  1121.  
  1122.  DESCRIPTION:
  1123.  
  1124.  If
  1125.      z = x + iy,
  1126.  
  1127.  then
  1128.           1       (    2x     )
  1129.  Re w  =  - arctan(-----------)  +  k PI
  1130.           2       (     2    2)
  1131.                   (1 - x  - y )
  1132.  
  1133.                ( 2         2)
  1134.           1    (x  +  (y+1) )
  1135.  Im w  =  - log(------------)
  1136.           4    ( 2         2)
  1137.                (x  +  (y-1) )
  1138.  
  1139.  Where k is an arbitrary integer.
  1140.  
  1141.  ACCURACY:
  1142.  
  1143.                       Relative error:
  1144.  arithmetic   domain     # trials      peak         rms
  1145.     DEC       -10,+10      5900       1.3e-16     7.8e-18
  1146.     IEEE      -10,+10     30000       2.3e-15     8.5e-17
  1147.  The check catan( ctan(z) )  =  z, with |x| and |y| < PI/2,
  1148.  had peak relative error 1.5e-16, rms relative error
  1149.  2.9e-17.  See also clog().
  1150.  
  1151. =item I<csinh>: Complex hyperbolic sine
  1152.  
  1153.   SYNOPSIS:
  1154.  
  1155.   # void csinh();
  1156.   # cmplx z, w;
  1157.  
  1158.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1159.  $w = new_cmplx();
  1160.  csinh($z, $w );
  1161.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  1162.  
  1163.   DESCRIPTION:
  1164.  
  1165.   csinh z = (cexp(z) - cexp(-z))/2
  1166.           = sinh x * cos y  +  i cosh x * sin y .
  1167.  
  1168.   ACCURACY:
  1169.  
  1170.                        Relative error:
  1171.   arithmetic   domain     # trials      peak         rms
  1172.      IEEE      -10,+10     30000       3.1e-16     8.2e-17
  1173.  
  1174. =item I<casinh>: Complex inverse hyperbolic sine
  1175.  
  1176.   SYNOPSIS:
  1177.  
  1178.   # void casinh();
  1179.   # cmplx z, w;
  1180.  
  1181.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1182.  $w = new_cmplx();
  1183.  casinh($z, $w );
  1184.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  1185.  print_new_cmplx($w);                 # prints $w as Re($w) + i Im($w) 
  1186.  
  1187.   DESCRIPTION:
  1188.  
  1189.   casinh z = -i casin iz .
  1190.  
  1191.   ACCURACY:
  1192.  
  1193.                        Relative error:
  1194.   arithmetic   domain     # trials      peak         rms
  1195.      IEEE      -10,+10     30000       1.8e-14     2.6e-15
  1196.  
  1197. =item I<ccosh>: Complex hyperbolic cosine
  1198.  
  1199.   SYNOPSIS:
  1200.  
  1201.   # void ccosh();
  1202.   # cmplx z, w;
  1203.   
  1204.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1205.  $w = new_cmplx();
  1206.  ccosh($z, $w );
  1207.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  1208.  
  1209.   DESCRIPTION:
  1210.  
  1211.   ccosh(z) = cosh x  cos y + i sinh x sin y .
  1212.  
  1213.   ACCURACY:
  1214.  
  1215.                        Relative error:
  1216.   arithmetic   domain     # trials      peak         rms
  1217.      IEEE      -10,+10     30000       2.9e-16     8.1e-17
  1218.  
  1219. =item I<cacosh>: Complex inverse hyperbolic cosine
  1220.  
  1221.   SYNOPSIS:
  1222.  
  1223.   # void cacosh();
  1224.   # cmplx z, w;
  1225.  
  1226.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1227.  $w = new_cmplx();
  1228.  cacosh($z, $w );
  1229.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w 
  1230.  
  1231.   DESCRIPTION:
  1232.  
  1233.   acosh z = i acos z .
  1234.  
  1235.   ACCURACY:
  1236.  
  1237.                        Relative error:
  1238.   arithmetic   domain     # trials      peak         rms
  1239.      IEEE      -10,+10     30000       1.6e-14     2.1e-15
  1240.  
  1241. =item I<ctanh>: Complex hyperbolic tangent
  1242.  
  1243.  SYNOPSIS:
  1244.  
  1245.  # void ctanh();
  1246.  # cmplx z, w;
  1247.  
  1248.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1249.  $w = new_cmplx();
  1250.  ctanh($z, $w );
  1251.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w  
  1252.  
  1253.  DESCRIPTION:
  1254.  
  1255.  tanh z = (sinh 2x  +  i sin 2y) / (cosh 2x + cos 2y) .
  1256.  
  1257.  ACCURACY:
  1258.  
  1259.                       Relative error:
  1260.  arithmetic   domain     # trials      peak         rms
  1261.     IEEE      -10,+10     30000       1.7e-14     2.4e-16
  1262.  
  1263. =item I<catanh>: Complex inverse hyperbolic tangent
  1264.  
  1265.   SYNOPSIS:
  1266.  
  1267.   # void catanh();
  1268.   # cmplx z, w;
  1269.  
  1270.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1271.  $w = new_cmplx();
  1272.  catanh($z, $w );
  1273.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w  
  1274.  
  1275.   DESCRIPTION:
  1276.  
  1277.   Inverse tanh, equal to  -i catan (iz);
  1278.  
  1279.   ACCURACY:
  1280.  
  1281.                        Relative error:
  1282.   arithmetic   domain     # trials      peak         rms
  1283.      IEEE      -10,+10     30000       2.3e-16     6.2e-17
  1284.  
  1285. =item I<cpow>: Complex power function 
  1286.  
  1287.   SYNOPSIS:
  1288.  
  1289.   # void cpow();
  1290.   # cmplx a, z, w;
  1291.  
  1292.  $a = new_cmplx(5, 6);    # $z = 5 + 6 i
  1293.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1294.  $w = new_cmplx();
  1295.  cpow($a, $z, $w );
  1296.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w  
  1297.  
  1298.   DESCRIPTION:
  1299.  
  1300.   Raises complex A to the complex Zth power.
  1301.   Definition is per AMS55 # 4.2.8,
  1302.   analytically equivalent to cpow(a,z) = cexp(z clog(a)).
  1303.  
  1304.   ACCURACY:
  1305.  
  1306.                        Relative error:
  1307.   arithmetic   domain     # trials      peak         rms
  1308.      IEEE      -10,+10     30000       9.4e-15     1.5e-15
  1309.  
  1310. =item I<cmplx>: Complex number arithmetic
  1311.  
  1312.  SYNOPSIS:
  1313.  
  1314.  # typedef struct {
  1315.  #     double r;     real part
  1316.  #     double i;     imaginary part
  1317.  #    }cmplx;
  1318.  
  1319.  # cmplx *a, *b, *c;
  1320.  
  1321.  $a = new_cmplx(3, 5);   # $a = 3 + 5 i
  1322.  $b = new_cmplx(2, 3);   # $b = 2 + 3 i
  1323.  $c = new_cmplx();
  1324.  
  1325.  cadd( $a, $b, $c );  #   c = b + a
  1326.  csub( $a, $b, $c );  #   c = b - a
  1327.  cmul( $a, $b, $c );  #   c = b * a
  1328.  cdiv( $a, $b, $c );  #   c = b / a
  1329.  cneg( $c );          #   c = -c
  1330.  cmov( $b, $c );      #   c = b
  1331.  
  1332.  print $c->{r}, '  ', $c->{i};   # prints real and imaginary parts of $c
  1333.  
  1334.  DESCRIPTION:
  1335.  
  1336.  Addition:
  1337.     c.r  =  b.r + a.r
  1338.     c.i  =  b.i + a.i
  1339.  
  1340.  Subtraction:
  1341.     c.r  =  b.r - a.r
  1342.     c.i  =  b.i - a.i
  1343.  
  1344.  Multiplication:
  1345.     c.r  =  b.r * a.r  -  b.i * a.i
  1346.     c.i  =  b.r * a.i  +  b.i * a.r
  1347.  
  1348.  Division:
  1349.     d    =  a.r * a.r  +  a.i * a.i
  1350.     c.r  = (b.r * a.r  + b.i * a.i)/d
  1351.     c.i  = (b.i * a.r  -  b.r * a.i)/d
  1352.  ACCURACY:
  1353.  
  1354.  In DEC arithmetic, the test (1/z) * z = 1 had peak relative
  1355.  error 3.1e-17, rms 1.2e-17.  The test (y/z) * (z/y) = 1 had
  1356.  peak relative error 8.3e-17, rms 2.1e-17.
  1357.  
  1358.  Tests in the rectangle {-10,+10}:
  1359.                       Relative error:
  1360.  arithmetic   function  # trials      peak         rms
  1361.     DEC        cadd       10000       1.4e-17     3.4e-18
  1362.     IEEE       cadd      100000       1.1e-16     2.7e-17
  1363.     DEC        csub       10000       1.4e-17     4.5e-18
  1364.     IEEE       csub      100000       1.1e-16     3.4e-17
  1365.     DEC        cmul        3000       2.3e-17     8.7e-18
  1366.     IEEE       cmul      100000       2.1e-16     6.9e-17
  1367.     DEC        cdiv       18000       4.9e-17     1.3e-17
  1368.     IEEE       cdiv      100000       3.7e-16     1.1e-16
  1369.  
  1370. =item I<cabs>: Complex absolute value
  1371.  
  1372.  SYNOPSIS:
  1373.  
  1374.  # double a, cabs();
  1375.  # cmplx z;
  1376.  
  1377.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1378.  $a = cabs( $z );
  1379.  
  1380.  DESCRIPTION:
  1381.  
  1382.  If z = x + iy
  1383.  
  1384.  then
  1385.  
  1386.        a = sqrt( x**2 + y**2 ).
  1387.  
  1388.  Overflow and underflow are avoided by testing the magnitudes
  1389.  of x and y before squaring.  If either is outside half of
  1390.  the floating point full scale range, both are rescaled.
  1391.  
  1392.  ACCURACY:
  1393.  
  1394.                       Relative error:
  1395.  arithmetic   domain     # trials      peak         rms
  1396.     DEC       -30,+30     30000       3.2e-17     9.2e-18
  1397.     IEEE      -10,+10    100000       2.7e-16     6.9e-17
  1398.  
  1399. =item I<csqrt>: Complex square root
  1400.  
  1401.  SYNOPSIS:
  1402.  
  1403.  # void csqrt();
  1404.  # cmplx z, w;
  1405.  
  1406.  $z = new_cmplx(2, 3);    # $z = 2 + 3 i
  1407.  $w = new_cmplx();
  1408.  csqrt($z, $w );
  1409.  print $w->{r}, '  ', $w->{i};  # prints real and imaginary parts of $w
  1410.  
  1411.  DESCRIPTION:
  1412.  
  1413.  If z = x + iy,  r = |z|, then
  1414.  
  1415.                        1/2
  1416.  Im w  =  [ (r - x)/2 ]   ,
  1417.  
  1418.  Re w  =  y / 2 Im w.
  1419.  
  1420.  Note that -w is also a square root of z.  The root chosen
  1421.  is always in the upper half plane.
  1422.  
  1423.  Because of the potential for cancellation error in r - x,
  1424.  the result is sharpened by doing a Heron iteration
  1425.  (see sqrt.c) in complex arithmetic.
  1426.  
  1427.  ACCURACY:
  1428.  
  1429.                       Relative error:
  1430.  arithmetic   domain     # trials      peak         rms
  1431.     DEC       -10,+10     25000       3.2e-17     9.6e-18
  1432.     IEEE      -10,+10    100000       3.2e-16     7.7e-17
  1433.  
  1434.                         2
  1435.  Also tested by csqrt( z ) = z, and tested by arguments
  1436.  close to the real axis.
  1437.  
  1438. =item I<machconst>: Globally declared constants
  1439.  
  1440.  SYNOPSIS:
  1441.  
  1442.  extern double nameofconstant;
  1443.  
  1444.  DESCRIPTION:
  1445.  
  1446.  This file contains a number of mathematical constants and
  1447.  also some needed size parameters of the computer arithmetic.
  1448.  The values are supplied as arrays of hexadecimal integers
  1449.  for IEEE arithmetic; arrays of octal constants for DEC
  1450.  arithmetic; and in a normal decimal scientific notation for
  1451.  other machines.  The particular notation used is determined
  1452.  by a symbol (DEC, IBMPC, or UNK) defined in the include file
  1453.  mconf.h.
  1454.  
  1455.  The default size parameters are as follows.
  1456.  
  1457.  For DEC and UNK modes:
  1458.  MACHEP =  1.38777878078144567553E-17       2**-56
  1459.  MAXLOG =  8.8029691931113054295988E1       log(2**127)
  1460.  MINLOG = -8.872283911167299960540E1        log(2**-128)
  1461.  MAXNUM =  1.701411834604692317316873e38    2**127
  1462.  
  1463.  For IEEE arithmetic (IBMPC):
  1464.  MACHEP =  1.11022302462515654042E-16       2**-53
  1465.  MAXLOG =  7.09782712893383996843E2         log(2**1024)
  1466.  MINLOG = -7.08396418532264106224E2         log(2**-1022)
  1467.  MAXNUM =  1.7976931348623158E308           2**1024
  1468.  
  1469.  These lists are subject to change.
  1470.  
  1471. =item I<cosh>: Hyperbolic cosine
  1472.  
  1473.  SYNOPSIS:
  1474.  
  1475.  # double x, y, cosh();
  1476.  
  1477.  $y = cosh( $x );
  1478.  
  1479.  DESCRIPTION:
  1480.  
  1481.  Returns hyperbolic cosine of argument in the range MINLOG to
  1482.  MAXLOG.
  1483.  
  1484.  cosh(x)  =  ( exp(x) + exp(-x) )/2.
  1485.  
  1486.  ACCURACY:
  1487.  
  1488.                       Relative error:
  1489.  arithmetic   domain     # trials      peak         rms
  1490.     DEC       +- 88       50000       4.0e-17     7.7e-18
  1491.     IEEE     +-MAXLOG     30000       2.6e-16     5.7e-17
  1492.  
  1493.  ERROR MESSAGES:
  1494.  
  1495.    message         condition      value returned
  1496.  cosh overflow    |x| > MAXLOG       MAXNUM
  1497.  
  1498. =item I<dawsn>: Dawson's Integral
  1499.  
  1500.  SYNOPSIS:
  1501.  
  1502.  # double x, y, dawsn();
  1503.  
  1504.  $y = dawsn( $x );
  1505.  
  1506.  DESCRIPTION:
  1507.  
  1508.  Approximates the integral
  1509.  
  1510.                              x
  1511.                              -
  1512.                       2     | |        2
  1513.   dawsn(x)  =  exp( -x  )   |    exp( t  ) dt
  1514.                           | |
  1515.                            -
  1516.                            0
  1517.  
  1518.  Three different rational approximations are employed, for
  1519.  the intervals 0 to 3.25; 3.25 to 6.25; and 6.25 up.
  1520.  
  1521.  ACCURACY:
  1522.  
  1523.                       Relative error:
  1524.  arithmetic   domain     # trials      peak         rms
  1525.     IEEE      0,10        10000       6.9e-16     1.0e-16
  1526.     DEC       0,10         6000       7.4e-17     1.4e-17
  1527.  
  1528. =item I<drand>: Pseudorandom number generator
  1529.  
  1530.  SYNOPSIS:
  1531.  
  1532.  # double y, drand();
  1533.  
  1534.  ($flag, $y) = drand( );
  1535.  
  1536.  DESCRIPTION:
  1537.  
  1538.  Yields a random number 1.0 <= y < 2.0.
  1539.  
  1540.  The three-generator congruential algorithm by Brian
  1541.  Wichmann and David Hill (BYTE magazine, March, 1987,
  1542.  pp 127-8) is used. The period, given by them, is
  1543.  6953607871644.
  1544.  
  1545.  Versions invoked by the different arithmetic compile
  1546.  time options DEC, IBMPC, and MIEEE, produce
  1547.  approximately the same sequences, differing only in the
  1548.  least significant bits of the numbers. The UNK option
  1549.  implements the algorithm as recommended in the BYTE
  1550.  article.  It may be used on all computers. However,
  1551.  the low order bits of a double precision number may
  1552.  not be adequately random, and may vary due to arithmetic
  1553.  implementation details on different computers.
  1554.  
  1555.  The other compile options generate an additional random
  1556.  integer that overwrites the low order bits of the double
  1557.  precision number.  This reduces the period by a factor of
  1558.  two but tends to overcome the problems mentioned.
  1559.  
  1560. =item I<ellie>: Incomplete elliptic integral of the second kind
  1561.  
  1562.  SYNOPSIS:
  1563.  
  1564.  # double phi, m, y, ellie();
  1565.  
  1566.  $y = ellie( $phi, $m );
  1567.  
  1568.  DESCRIPTION:
  1569.  
  1570.  Approximates the integral
  1571.  
  1572.                 phi
  1573.                  -
  1574.                 | |
  1575.                 |                   2
  1576.  E(phi_\m)  =    |    sqrt( 1 - m sin t ) dt
  1577.                 |
  1578.               | |    
  1579.                -
  1580.                 0
  1581.  
  1582.  of amplitude phi and modulus m, using the arithmetic -
  1583.  geometric mean algorithm.
  1584.  
  1585.  ACCURACY:
  1586.  
  1587.  Tested at random arguments with phi in [-10, 10] and m in
  1588.  [0, 1].
  1589.                       Relative error:
  1590.  arithmetic   domain     # trials      peak         rms
  1591.     DEC        0,2         2000       1.9e-16     3.4e-17
  1592.     IEEE     -10,10      150000       3.3e-15     1.4e-16
  1593.  
  1594. =item I<ellik>: Incomplete elliptic integral of the first kind
  1595.  
  1596.  SYNOPSIS:
  1597.  
  1598.  # double phi, m, y, ellik();
  1599.  
  1600.  $y = ellik( $phi, $m );
  1601.  
  1602.  DESCRIPTION:
  1603.  
  1604.  Approximates the integral
  1605.  
  1606.                 phi
  1607.                  -
  1608.                 | |
  1609.                 |           dt
  1610.  F(phi_\m)  =    |    ------------------
  1611.                 |                   2
  1612.               | |    sqrt( 1 - m sin t )
  1613.                -
  1614.                 0
  1615.  
  1616.  of amplitude phi and modulus m, using the arithmetic -
  1617.  geometric mean algorithm.
  1618.  
  1619.  ACCURACY:
  1620.  
  1621.  Tested at random points with m in [0, 1] and phi as indicated.
  1622.  
  1623.                       Relative error:
  1624.  arithmetic   domain     # trials      peak         rms
  1625.     IEEE     -10,10       200000      7.4e-16     1.0e-16
  1626.  
  1627. =item I<ellpe>: Complete elliptic integral of the second kind
  1628.  
  1629.  SYNOPSIS:
  1630.  
  1631.  # double m1, y, ellpe();
  1632.  
  1633.  $y = ellpe( $m1 );
  1634.  
  1635.  DESCRIPTION:
  1636.  
  1637.  Approximates the integral
  1638.  
  1639.             pi/2
  1640.              -
  1641.             | |                 2
  1642.  E(m)  =    |    sqrt( 1 - m sin t ) dt
  1643.           | |    
  1644.            -
  1645.             0
  1646.  
  1647.  Where m = 1 - m1, using the approximation
  1648.  
  1649.       P(x)  -  x log x Q(x).
  1650.  
  1651.  Though there are no singularities, the argument m1 is used
  1652.  rather than m for compatibility with ellpk().
  1653.  
  1654.  E(1) = 1; E(0) = pi/2.
  1655.  
  1656.  ACCURACY:
  1657.  
  1658.                       Relative error:
  1659.  arithmetic   domain     # trials      peak         rms
  1660.     DEC        0, 1       13000       3.1e-17     9.4e-18
  1661.     IEEE       0, 1       10000       2.1e-16     7.3e-17
  1662.  
  1663.  ERROR MESSAGES:
  1664.  
  1665.    message         condition      value returned
  1666.  ellpe domain      x<0, x>1            0.0
  1667.  
  1668. =item I<ellpj>: Jacobian Elliptic Functions
  1669.  
  1670.  SYNOPSIS:
  1671.  
  1672.  # double u, m, sn, cn, dn, phi;
  1673.  # int ellpj();
  1674.  
  1675.  ($flag, $sn, $cn, $dn, $phi) = ellpj( $u, $m );
  1676.  
  1677.  DESCRIPTION:
  1678.  
  1679.  Evaluates the Jacobian elliptic functions sn(u|m), cn(u|m),
  1680.  and dn(u|m) of parameter m between 0 and 1, and real
  1681.  argument u.
  1682.  
  1683.  These functions are periodic, with quarter-period on the
  1684.  real axis equal to the complete elliptic integral
  1685.  ellpk(1.0-m).
  1686.  
  1687.  Relation to incomplete elliptic integral:
  1688.  If u = ellik(phi,m), then sn(u|m) = sin(phi),
  1689.  and cn(u|m) = cos(phi).  Phi is called the amplitude of u.
  1690.  
  1691.  Computation is by means of the arithmetic-geometric mean
  1692.  algorithm, except when m is within 1e-9 of 0 or 1.  In the
  1693.  latter case with m close to 1, the approximation applies
  1694.  only for phi < pi/2.
  1695.  
  1696.  ACCURACY:
  1697.  
  1698.  Tested at random points with u between 0 and 10, m between
  1699.  0 and 1.
  1700.  
  1701.             Absolute error (* = relative error):
  1702.  arithmetic   function   # trials      peak         rms
  1703.     DEC       sn           1800       4.5e-16     8.7e-17
  1704.     IEEE      phi         10000       9.2e-16*    1.4e-16*
  1705.     IEEE      sn          50000       4.1e-15     4.6e-16
  1706.     IEEE      cn          40000       3.6e-15     4.4e-16
  1707.     IEEE      dn          10000       1.3e-12     1.8e-14
  1708.  
  1709.   Peak error observed in consistency check using addition
  1710.  theorem for sn(u+v) was 4e-16 (absolute).  Also tested by
  1711.  the above relation to the incomplete elliptic integral.
  1712.  Accuracy deteriorates when u is large.
  1713.  
  1714. =item I<ellpk>: Complete elliptic integral of the first kind
  1715.  
  1716.  SYNOPSIS:
  1717.  
  1718.  # double m1, y, ellpk();
  1719.  
  1720.  $y = ellpk( $m1 );
  1721.  
  1722.  DESCRIPTION:
  1723.  
  1724.  Approximates the integral
  1725.  
  1726.             pi/2
  1727.              -
  1728.             | |
  1729.             |           dt
  1730.  K(m)  =    |    ------------------
  1731.             |                   2
  1732.           | |    sqrt( 1 - m sin t )
  1733.            -
  1734.             0
  1735.  
  1736.  where m = 1 - m1, using the approximation
  1737.  
  1738.      P(x)  -  log x Q(x).
  1739.  
  1740.  The argument m1 is used rather than m so that the logarithmic
  1741.  singularity at m = 1 will be shifted to the origin; this
  1742.  preserves maximum accuracy.
  1743.  
  1744.  K(0) = pi/2.
  1745.  
  1746.  ACCURACY:
  1747.  
  1748.                       Relative error:
  1749.  arithmetic   domain     # trials      peak         rms
  1750.     DEC        0,1        16000       3.5e-17     1.1e-17
  1751.     IEEE       0,1        30000       2.5e-16     6.8e-17
  1752.  
  1753.  ERROR MESSAGES:
  1754.  
  1755.    message         condition      value returned
  1756.  ellpk domain       x<0, x>1           0.0
  1757.  
  1758. =item I<euclid>: Rational arithmetic routines
  1759.  
  1760.  SYNOPSIS:
  1761.  
  1762.  
  1763.  # typedef struct
  1764.  #     {
  1765.  #     double n;  numerator
  1766.  #     double d;  denominator
  1767.  #     }fract;
  1768.  
  1769.  $a = new_fract(3, 4);    # a = 3 / 4
  1770.  $b = new_fract(2, 3);  # b = 2 / 3
  1771.  $c = new_fract();
  1772.  radd( $a, $b, $c ); #     c = b + a
  1773.  rsub( $a, $b, $c ); #     c = b - a 
  1774.  rmul( $a, $b, $c ); #     c = b * a
  1775.  rdiv( $a, $b, $c ); #     c = b / a
  1776.  print $c->{n}, ' ', $c->{d};  # prints numerator and denominator of $c
  1777.  
  1778.  ($gcd, $m_reduced, $n_reduced) = euclid($m, $n); 
  1779.  # returns the greatest common divisor of $m and $n, as well as
  1780.  # the result of reducing $m and $n by $gcd
  1781.  
  1782.  Arguments of the routines are pointers to the structures.
  1783.  The double precision numbers are assumed, without checking,
  1784.  to be integer valued.  Overflow conditions are reported.
  1785.  
  1786. =item I<exp>: Exponential function
  1787.  
  1788.  SYNOPSIS:
  1789.  
  1790.  # double x, y, exp();
  1791.  
  1792.  $y = exp( $x );
  1793.  
  1794.  DESCRIPTION:
  1795.  
  1796.  Returns e (2.71828...) raised to the x power.
  1797.  
  1798.  Range reduction is accomplished by separating the argument
  1799.  into an integer k and fraction f such that
  1800.  
  1801.      x    k  f
  1802.     e  = 2  e.
  1803.  
  1804.  A Pade' form  1 + 2x P(x**2)/( Q(x**2) - P(x**2) )
  1805.  of degree 2/3 is used to approximate exp(f) in the basic
  1806.  interval [-0.5, 0.5].
  1807.  
  1808.  ACCURACY:
  1809.  
  1810.                       Relative error:
  1811.  arithmetic   domain     # trials      peak         rms
  1812.     DEC       +- 88       50000       2.8e-17     7.0e-18
  1813.     IEEE      +- 708      40000       2.0e-16     5.6e-17
  1814.  
  1815.  Error amplification in the exponential function can be
  1816.  a serious matter.  The error propagation involves
  1817.  exp( X(1+delta) ) = exp(X) ( 1 + X*delta + ... ),
  1818.  which shows that a 1 lsb error in representing X produces
  1819.  a relative error of X times 1 lsb in the function.
  1820.  While the routine gives an accurate result for arguments
  1821.  that are exactly represented by a double precision
  1822.  computer number, the result contains amplified roundoff
  1823.  error for large arguments not exactly represented.
  1824.  
  1825.  ERROR MESSAGES:
  1826.  
  1827.    message         condition      value returned
  1828.  exp underflow    x < MINLOG         0.0
  1829.  exp overflow     x > MAXLOG         INFINITY
  1830.  
  1831. =item I<expxx>: exp(x*x)
  1832.  
  1833.  #  double x, y, expxx();
  1834.  # int sign;
  1835.  
  1836.    $y = expxx( $x, $sign );
  1837.  
  1838.  DESCRIPTION:
  1839.  
  1840.   Computes y = exp(x*x) while suppressing error amplification
  1841.   that would ordinarily arise from the inexactness of the
  1842.   exponential argument x*x.
  1843.  
  1844.   If sign < 0, exp(-x*x) is returned.
  1845.   If sign > 0, or omitted, exp(x*x) is returned.
  1846.  
  1847.  ACCURACY:
  1848.  
  1849.                        Relative error:
  1850.  arithmetic    domain     # trials      peak         rms
  1851.     IEEE      -26.6, 26.6    10^7       3.9e-16     8.9e-17
  1852.  
  1853.  
  1854.  
  1855. =item I<exp10>: Base 10 exponential function (Common antilogarithm)
  1856.  
  1857.  SYNOPSIS:
  1858.  
  1859.  # double x, y, exp10();
  1860.  
  1861.  $y = exp10( $x );
  1862.  
  1863.  DESCRIPTION:
  1864.  
  1865.  Returns 10 raised to the x power.
  1866.  
  1867.  Range reduction is accomplished by expressing the argument
  1868.  as 10**x = 2**n 10**f, with |f| < 0.5 log10(2).
  1869.  The Pade' form
  1870.  
  1871.     1 + 2x P(x**2)/( Q(x**2) - P(x**2) )
  1872.  
  1873.  is used to approximate 10**f.
  1874.  
  1875.  ACCURACY:
  1876.  
  1877.                       Relative error:
  1878.  arithmetic   domain     # trials      peak         rms
  1879.     IEEE     -307,+307    30000       2.2e-16     5.5e-17
  1880.  Test result from an earlier version (2.1):
  1881.     DEC       -38,+38     70000       3.1e-17     7.0e-18
  1882.  
  1883.  ERROR MESSAGES:
  1884.  
  1885.    message         condition      value returned
  1886.  exp10 underflow    x < -MAXL10        0.0
  1887.  exp10 overflow     x > MAXL10       MAXNUM
  1888.  
  1889.  DEC arithmetic: MAXL10 = 38.230809449325611792.
  1890.  IEEE arithmetic: MAXL10 = 308.2547155599167.
  1891.  
  1892. =item I<exp2>: Base 2 exponential function
  1893.  
  1894.  SYNOPSIS:
  1895.  
  1896.  # double x, y, exp2();
  1897.  
  1898.  $y = exp2( $x );
  1899.  
  1900.  DESCRIPTION:
  1901.  
  1902.  Returns 2 raised to the x power.
  1903.  
  1904.  Range reduction is accomplished by separating the argument
  1905.  into an integer k and fraction f such that
  1906.      x    k  f
  1907.     2  = 2  2.
  1908.  
  1909.  A Pade' form
  1910.  
  1911.    1 + 2x P(x**2) / (Q(x**2) - x P(x**2) )
  1912.  
  1913.  approximates 2**x in the basic range [-0.5, 0.5].
  1914.  
  1915.  ACCURACY:
  1916.  
  1917.                       Relative error:
  1918.  arithmetic   domain     # trials      peak         rms
  1919.     IEEE    -1022,+1024   30000       1.8e-16     5.4e-17
  1920.  
  1921.  See exp.c for comments on error amplification.
  1922.  
  1923.  ERROR MESSAGES:
  1924.  
  1925.    message         condition      value returned
  1926.  exp underflow    x < -MAXL2        0.0
  1927.  exp overflow     x > MAXL2         MAXNUM
  1928.  
  1929.  For DEC arithmetic, MAXL2 = 127.
  1930.  For IEEE arithmetic, MAXL2 = 1024.
  1931.  
  1932. =item I<ei>:     Exponential integral
  1933.  
  1934.  SYNOPSIS:
  1935.  
  1936.  #double x, y, ei();
  1937.  
  1938.  $y = ei( $x );
  1939.  
  1940.  
  1941.  DESCRIPTION:
  1942.  
  1943.                x
  1944.                 -     t
  1945.                | |   e
  1946.     Ei(x) =   -|-   ---  dt .
  1947.              | |     t
  1948.               -
  1949.              -inf
  1950.  
  1951.  Not defined for x <= 0.
  1952.  See also expn.c.
  1953.  
  1954.  ACCURACY:
  1955.  
  1956.                       Relative error:
  1957.  arithmetic   domain     # trials      peak         rms
  1958.     IEEE       0,100       50000      8.6e-16     1.3e-16
  1959.  
  1960. =item I<expn>:     Exponential integral En
  1961.  
  1962.  SYNOPSIS:
  1963.  
  1964.  # int n;
  1965.  # double x, y, expn();
  1966.  
  1967.  $y = expn( $n, $x );
  1968.  
  1969.  DESCRIPTION:
  1970.  
  1971.  Evaluates the exponential integral
  1972.  
  1973.                  inf.
  1974.                    -
  1975.                   | |   -xt
  1976.                   |    e
  1977.       E (x)  =    |    ----  dt.
  1978.        n          |      n
  1979.                 | |     t
  1980.                  -
  1981.                   1
  1982.  
  1983.  Both n and x must be nonnegative.
  1984.  
  1985.  The routine employs either a power series, a continued
  1986.  fraction, or an asymptotic formula depending on the
  1987.  relative values of n and x.
  1988.  
  1989.  ACCURACY:
  1990.  
  1991.                       Relative error:
  1992.  arithmetic   domain     # trials      peak         rms
  1993.     DEC       0, 30        5000       2.0e-16     4.6e-17
  1994.     IEEE      0, 30       10000       1.7e-15     3.6e-16
  1995.  
  1996. =item I<fabs>:     Absolute value
  1997.  
  1998.  SYNOPSIS:
  1999.  
  2000.  # double x, y;
  2001.  
  2002.  $y = fabs( $x );
  2003.  
  2004.  DESCRIPTION:
  2005.  
  2006.  Returns the absolute value of the argument.
  2007.  
  2008. =item I<fac>: Factorial function
  2009.  
  2010.  SYNOPSIS:
  2011.  
  2012.  # double y, fac();
  2013.  # int i;
  2014.  
  2015.  $y = fac( $i );
  2016.  
  2017.  DESCRIPTION:
  2018.  
  2019.  Returns factorial of i  =  1 * 2 * 3 * ... * i.
  2020.  fac(0) = 1.0.
  2021.  
  2022.  Due to machine arithmetic bounds the largest value of
  2023.  i accepted is 33 in DEC arithmetic or 170 in IEEE
  2024.  arithmetic.  Greater values, or negative ones,
  2025.  produce an error message and return MAXNUM.
  2026.  
  2027.  ACCURACY:
  2028.  
  2029.  For i < 34 the values are simply tabulated, and have
  2030.  full machine accuracy.  If i > 55, fac(i) = gamma(i+1);
  2031.  see gamma.c.
  2032.  
  2033.                       Relative error:
  2034.  arithmetic   domain      peak
  2035.     IEEE      0, 170    1.4e-15
  2036.     DEC       0, 33      1.4e-17
  2037.  
  2038. =item I<fdtr>: F distribution
  2039.  
  2040.  SYNOPSIS:
  2041.  
  2042.  # int df1, df2;
  2043.  # double x, y, fdtr();
  2044.  
  2045.  $y = fdtr( $df1, $df2, $x );
  2046.  
  2047.  DESCRIPTION:
  2048.  
  2049.  Returns the area from zero to x under the F density
  2050.  function (also known as Snedcor's density or the
  2051.  variance ratio density).  This is the density
  2052.  of x = (u1/df1)/(u2/df2), where u1 and u2 are random
  2053.  variables having Chi square distributions with df1
  2054.  and df2 degrees of freedom, respectively.
  2055.  
  2056.  The incomplete beta integral is used, according to the
  2057.  formula
  2058.  
  2059.     P(x) = incbet( df1/2, df2/2, df1*x/(df2 + df1*x) ).
  2060.  
  2061.  The arguments a and b are greater than zero, and x is
  2062.  nonnegative.
  2063.  
  2064.  ACCURACY:
  2065.  
  2066.  Tested at random points (a,b,x).
  2067.  
  2068.                 x     a,b                     Relative error:
  2069.  arithmetic  domain  domain     # trials      peak         rms
  2070.     IEEE      0,1    0,100       100000      9.8e-15     1.7e-15
  2071.     IEEE      1,5    0,100       100000      6.5e-15     3.5e-16
  2072.     IEEE      0,1    1,10000     100000      2.2e-11     3.3e-12
  2073.     IEEE      1,5    1,10000     100000      1.1e-11     1.7e-13
  2074.  See also incbet.c.
  2075.  
  2076.  ERROR MESSAGES:
  2077.  
  2078.    message         condition      value returned
  2079.  fdtr domain     a<0, b<0, x<0         0.0
  2080.  
  2081. =item I<fdtrc>: Complemented F distribution
  2082.  
  2083.  SYNOPSIS:
  2084.  
  2085.  # int df1, df2;
  2086.  # double x, y, fdtrc();
  2087.  
  2088.  $y = fdtrc( $df1, $df2, $x );
  2089.  
  2090.  DESCRIPTION:
  2091.  
  2092.  Returns the area from x to infinity under the F density
  2093.  function (also known as Snedcor's density or the
  2094.  variance ratio density).
  2095.  
  2096.                       inf.
  2097.                        -
  2098.               1       | |  a-1      b-1
  2099.  1-P(x)  =  ------    |   t    (1-t)    dt
  2100.             B(a,b)  | |
  2101.                      -
  2102.                       x
  2103.  
  2104.  The incomplete beta integral is used, according to the
  2105.  formula
  2106.  
  2107.     P(x) = incbet( df2/2, df1/2, df2/(df2 + df1*x) ).
  2108.  
  2109.  ACCURACY:
  2110.  
  2111.  Tested at random points (a,b,x) in the indicated intervals.
  2112.                 x     a,b                     Relative error:
  2113.  arithmetic  domain  domain     # trials      peak         rms
  2114.     IEEE      0,1    1,100       100000      3.7e-14     5.9e-16
  2115.     IEEE      1,5    1,100       100000      8.0e-15     1.6e-15
  2116.     IEEE      0,1    1,10000     100000      1.8e-11     3.5e-13
  2117.     IEEE      1,5    1,10000     100000      2.0e-11     3.0e-12
  2118.  See also incbet.c.
  2119.  
  2120.  ERROR MESSAGES:
  2121.  
  2122.    message         condition      value returned
  2123.  fdtrc domain    a<0, b<0, x<0         0.0
  2124.  
  2125. =item I<fdtri>: Inverse of complemented F distribution
  2126.  
  2127.  SYNOPSIS:
  2128.  
  2129.  # int df1, df2;
  2130.  # double x, p, fdtri();
  2131.  
  2132.  $x = fdtri( $df1, $df2, $p );
  2133.  
  2134.  DESCRIPTION:
  2135.  
  2136.  Finds the F density argument x such that the integral
  2137.  from x to infinity of the F density is equal to the
  2138.  given probability p.
  2139.  
  2140.  This is accomplished using the inverse beta integral
  2141.  function and the relations
  2142.  
  2143.       z = incbi( df2/2, df1/2, p )
  2144.       x = df2 (1-z) / (df1 z).
  2145.  
  2146.  Note: the following relations hold for the inverse of
  2147.  the uncomplemented F distribution:
  2148.  
  2149.       z = incbi( df1/2, df2/2, p )
  2150.       x = df2 z / (df1 (1-z)).
  2151.  
  2152.  ACCURACY:
  2153.  
  2154.  Tested at random points (a,b,p).
  2155.  
  2156.               a,b                     Relative error:
  2157.  arithmetic  domain     # trials      peak         rms
  2158.   For p between .001 and 1:
  2159.     IEEE     1,100       100000      8.3e-15     4.7e-16
  2160.     IEEE     1,10000     100000      2.1e-11     1.4e-13
  2161.   For p between 10^-6 and 10^-3:
  2162.     IEEE     1,100        50000      1.3e-12     8.4e-15
  2163.     IEEE     1,10000      50000      3.0e-12     4.8e-14
  2164.  See also fdtrc.c.
  2165.  
  2166.  ERROR MESSAGES:
  2167.  
  2168.    message         condition      value returned
  2169.  fdtri domain   p <= 0 or p > 1       0.0
  2170.                      v < 1
  2171.  
  2172. =item I<ceil>: ceil
  2173.  
  2174.  ceil() returns the smallest integer greater than or equal
  2175.  to x.  It truncates toward plus infinity.
  2176.  
  2177.  SYNOPSIS:
  2178.  
  2179.  # double x, y, ceil();
  2180.  
  2181.  $y = ceil( $x );
  2182.  
  2183. =item I<floor>: floor
  2184.  
  2185.  floor() returns the largest integer less than or equal to x.
  2186.  It truncates toward minus infinity.
  2187.  
  2188.  SYNOPSIS:
  2189.  
  2190.  # double x, y, floor();
  2191.  
  2192.  $y = floor( $x );
  2193.  
  2194. =item I<frexp>: frexp
  2195.  
  2196.  frexp() extracts the exponent from x.  It returns an integer
  2197.  power of two to expnt and the significand between 0.5 and 1
  2198.  to y.  Thus  x = y * 2**expn.
  2199.  
  2200.  SYNOPSIS:
  2201.  
  2202.  # double x, y, frexp();
  2203.  # int expnt;
  2204.  
  2205.  ($y, $expnt)  = frexp( $x );
  2206.  
  2207. =item I<ldexp>: multiplies x by 2**n.
  2208.  
  2209.  SYNOPSIS:
  2210.  
  2211.  # double x, y, ldexp();
  2212.  # int n;
  2213.  
  2214.  $y = ldexp( $x, $n );
  2215.  
  2216. =item I<fresnl>: Fresnel integral
  2217.  
  2218.  SYNOPSIS:
  2219.  
  2220.  # double x, S, C;
  2221.  # void fresnl();
  2222.  
  2223.  ($flag, $S, $C) = fresnl( $x );
  2224.  
  2225.  DESCRIPTION:
  2226.  
  2227.  Evaluates the Fresnel integrals
  2228.  
  2229.            x
  2230.            -
  2231.           | |
  2232.  C(x) =   |   cos(pi/2 t**2) dt,
  2233.         | |
  2234.          -
  2235.           0
  2236.  
  2237.            x
  2238.            -
  2239.           | |
  2240.  S(x) =   |   sin(pi/2 t**2) dt.
  2241.         | |
  2242.          -
  2243.           0
  2244.  
  2245.  The integrals are evaluated by a power series for x < 1.
  2246.  For x >= 1 auxiliary functions f(x) and g(x) are employed
  2247.  such that
  2248.  
  2249.  C(x) = 0.5 + f(x) sin( pi/2 x**2 ) - g(x) cos( pi/2 x**2 )
  2250.  S(x) = 0.5 - f(x) cos( pi/2 x**2 ) - g(x) sin( pi/2 x**2 )
  2251.  
  2252.  ACCURACY:
  2253.  
  2254.   Relative error.
  2255.  
  2256.  Arithmetic  function   domain     # trials      peak         rms
  2257.    IEEE       S(x)      0, 10       10000       2.0e-15     3.2e-16
  2258.    IEEE       C(x)      0, 10       10000       1.8e-15     3.3e-16
  2259.    DEC        S(x)      0, 10        6000       2.2e-16     3.9e-17
  2260.    DEC        C(x)      0, 10        5000       2.3e-16     3.9e-17
  2261.  
  2262. =item I<gamma>: Gamma function
  2263.  
  2264.  SYNOPSIS:
  2265.  
  2266.  # double x, y, gamma();
  2267.  # extern int sgngam;
  2268.  
  2269.  $y = gamma( $x );
  2270.  
  2271.  DESCRIPTION:
  2272.  
  2273.  Returns gamma function of the argument.  The result is
  2274.  correctly signed, and the sign (+1 or -1) is also
  2275.  returned in a global (extern) variable named sgngam.
  2276.  This variable is also filled in by the logarithmic gamma
  2277.  function lgam().
  2278.  
  2279.  Arguments |x| <= 34 are reduced by recurrence and the function
  2280.  approximated by a rational function of degree 6/7 in the
  2281.  interval (2,3).  Large arguments are handled by Stirling's
  2282.  formula. Large negative arguments are made positive using
  2283.  a reflection formula.  
  2284.  
  2285.  ACCURACY:
  2286.  
  2287.                       Relative error:
  2288.  arithmetic   domain     # trials      peak         rms
  2289.     DEC      -34, 34      10000       1.3e-16     2.5e-17
  2290.     IEEE    -170,-33      20000       2.3e-15     3.3e-16
  2291.     IEEE     -33,  33     20000       9.4e-16     2.2e-16
  2292.     IEEE      33, 171.6   20000       2.3e-15     3.2e-16
  2293.  
  2294.  Error for arguments outside the test range will be larger
  2295.  owing to error amplification by the exponential function.
  2296.  
  2297. =item I<lgam>: Natural logarithm of gamma function
  2298.  
  2299.  SYNOPSIS:
  2300.  
  2301.  # double x, y, lgam();
  2302.  # extern int sgngam;
  2303.  
  2304.  $y = lgam( $x );
  2305.  
  2306.  DESCRIPTION:
  2307.  
  2308.  Returns the base e (2.718...) logarithm of the absolute
  2309.  value of the gamma function of the argument.
  2310.  The sign (+1 or -1) of the gamma function is returned in a
  2311.  global (extern) variable named sgngam.
  2312.  
  2313.  For arguments greater than 13, the logarithm of the gamma
  2314.  function is approximated by the logarithmic version of
  2315.  Stirling's formula using a polynomial approximation of
  2316.  degree 4. Arguments between -33 and +33 are reduced by
  2317.  recurrence to the interval [2,3] of a rational approximation.
  2318.  The cosecant reflection formula is employed for arguments
  2319.  less than -33.
  2320.  
  2321.  Arguments greater than MAXLGM return MAXNUM and an error
  2322.  message.  MAXLGM = 2.035093e36 for DEC
  2323.  arithmetic or 2.556348e305 for IEEE arithmetic.
  2324.  
  2325.  ACCURACY:
  2326.  
  2327.  arithmetic      domain        # trials     peak         rms
  2328.     DEC     0, 3                  7000     5.2e-17     1.3e-17
  2329.     DEC     2.718, 2.035e36       5000     3.9e-17     9.9e-18
  2330.     IEEE    0, 3                 28000     5.4e-16     1.1e-16
  2331.     IEEE    2.718, 2.556e305     40000     3.5e-16     8.3e-17
  2332.  The error criterion was relative when the function magnitude
  2333.  was greater than one but absolute when it was less than one.
  2334.  
  2335.  The following test used the relative error criterion, though
  2336.  at certain points the relative error could be much higher than
  2337.  indicated.
  2338.     IEEE    -200, -4             10000     4.8e-16     1.3e-16
  2339.  
  2340. =item I<gdtr>: Gamma distribution function
  2341.  
  2342.  SYNOPSIS:
  2343.  
  2344.  # double a, b, x, y, gdtr();
  2345.  
  2346.  $y = gdtr( $a, $b, $x );
  2347.  
  2348.  DESCRIPTION:
  2349.  
  2350.  Returns the integral from zero to x of the gamma probability
  2351.  density function:
  2352.  
  2353.                 x
  2354.         b       -
  2355.        a       | |   b-1  -at
  2356.  y =  -----    |    t    e    dt
  2357.        -     | |
  2358.       | (b)   -
  2359.                0
  2360.  
  2361.   The incomplete gamma integral is used, according to the
  2362.  relation
  2363.  
  2364.  y = igam( b, ax ).
  2365.  
  2366.  ACCURACY:
  2367.  
  2368.  See igam().
  2369.  
  2370.  ERROR MESSAGES:
  2371.  
  2372.    message         condition      value returned
  2373.  gdtr domain         x < 0            0.0
  2374.  
  2375. =item I<gdtrc>: Complemented gamma distribution function
  2376.  
  2377.  SYNOPSIS:
  2378.  
  2379.  # double a, b, x, y, gdtrc();
  2380.  
  2381.  $y = gdtrc( $a, $b, $x );
  2382.  
  2383.  DESCRIPTION:
  2384.  
  2385.  Returns the integral from x to infinity of the gamma
  2386.  probability density function:
  2387.  
  2388.                inf.
  2389.         b       -
  2390.        a       | |   b-1  -at
  2391.  y =  -----    |    t    e    dt
  2392.        -     | |
  2393.       | (b)   -
  2394.                x
  2395.  
  2396.   The incomplete gamma integral is used, according to the
  2397.  relation
  2398.  
  2399.  y = igamc( b, ax ).
  2400.  
  2401.  ACCURACY:
  2402.  
  2403.  See igamc().
  2404.  
  2405.  ERROR MESSAGES:
  2406.  
  2407.    message         condition      value returned
  2408.  gdtrc domain         x < 0            0.0
  2409.  
  2410. =item I<hyp2f0>: Gauss hypergeometric function  2F0
  2411.  
  2412.  SYNOPSIS:
  2413.  
  2414.  # double a, b, x, value, *err;
  2415.  # int type;    /* determines what converging factor to use */
  2416.  
  2417.  ($value, $err) =  hyp2f0( $a, $b, $x, $type )
  2418.  
  2419. =item I<hyp2f1>: Gauss hypergeometric function  2F1
  2420.  
  2421.  SYNOPSIS:
  2422.  
  2423.  # double a, b, c, x, y, hyp2f1();
  2424.  
  2425.  $y = hyp2f1( $a, $b, $c, $x );
  2426.  
  2427.  DESCRIPTION:
  2428.  
  2429.   hyp2f1( a, b, c, x )  =   F ( a, b; c; x )
  2430.                            2 1
  2431.  
  2432.            inf.
  2433.             -   a(a+1)...(a+k) b(b+1)...(b+k)   k+1
  2434.    =  1 +   >   -----------------------------  x   .
  2435.             -         c(c+1)...(c+k) (k+1)!
  2436.           k = 0
  2437.  
  2438.   Cases addressed are
  2439.     Tests and escapes for negative integer a, b, or c
  2440.     Linear transformation if c - a or c - b negative integer
  2441.     Special case c = a or c = b
  2442.     Linear transformation for  x near +1
  2443.     Transformation for x < -0.5
  2444.     Psi function expansion if x > 0.5 and c - a - b integer
  2445.       Conditionally, a recurrence on c to make c-a-b > 0
  2446.  
  2447.  |x| > 1 is rejected.
  2448.  
  2449.  The parameters a, b, c are considered to be integer
  2450.  valued if they are within 1.0e-14 of the nearest integer
  2451.  (1.0e-13 for IEEE arithmetic).
  2452.  
  2453.  ACCURACY:
  2454.  
  2455.                Relative error (-1 < x < 1):
  2456.  arithmetic   domain     # trials      peak         rms
  2457.     IEEE      -1,7        230000      1.2e-11     5.2e-14
  2458.  
  2459.  Several special cases also tested with a, b, c in
  2460.  the range -7 to 7.
  2461.  
  2462.  ERROR MESSAGES:
  2463.  
  2464.  A "partial loss of precision" message is printed if
  2465.  the internally estimated relative error exceeds 1^-12.
  2466.  A "singularity" message is printed on overflow or
  2467.  in cases not addressed (such as x < -1).
  2468.  
  2469. =item I<hyperg>: Confluent hypergeometric function
  2470.  
  2471.  SYNOPSIS:
  2472.  
  2473.  # double a, b, x, y, hyperg();
  2474.  
  2475.  $y = hyperg( $a, $b, $x );
  2476.  
  2477.  DESCRIPTION:
  2478.  
  2479.  Computes the confluent hypergeometric function
  2480.  
  2481.                           1           2
  2482.                        a x    a(a+1) x
  2483.    F ( a,b;x )  =  1 + ---- + --------- + ...
  2484.   1 1                  b 1!   b(b+1) 2!
  2485.  
  2486.  Many higher transcendental functions are special cases of
  2487.  this power series.
  2488.  
  2489.  As is evident from the formula, b must not be a negative
  2490.  integer or zero unless a is an integer with 0 >= a > b.
  2491.  
  2492.  The routine attempts both a direct summation of the series
  2493.  and an asymptotic expansion.  In each case error due to
  2494.  roundoff, cancellation, and nonconvergence is estimated.
  2495.  The result with smaller estimated error is returned.
  2496.  
  2497.  ACCURACY:
  2498.  
  2499.  Tested at random points (a, b, x), all three variables
  2500.  ranging from 0 to 30.
  2501.                       Relative error:
  2502.  arithmetic   domain     # trials      peak         rms
  2503.     DEC       0,30         2000       1.2e-15     1.3e-16
  2504.     IEEE      0,30        30000       1.8e-14     1.1e-15
  2505.  
  2506.  Larger errors can be observed when b is near a negative
  2507.  integer or zero.  Certain combinations of arguments yield
  2508.  serious cancellation error in the power series summation
  2509.  and also are not in the region of near convergence of the
  2510.  asymptotic series.  An error message is printed if the
  2511.  self-estimated relative error is greater than 1.0e-12.
  2512.  
  2513. =item I<i0>: Modified Bessel function of order zero
  2514.  
  2515.  SYNOPSIS:
  2516.  
  2517.  # double x, y, i0();
  2518.  
  2519.  $y = i0( $x );
  2520.  
  2521.  DESCRIPTION:
  2522.  
  2523.  Returns modified Bessel function of order zero of the
  2524.  argument.
  2525.  
  2526.  The function is defined as i0(x) = j0( ix ).
  2527.  
  2528.  The range is partitioned into the two intervals [0,8] and
  2529.  (8, infinity).  Chebyshev polynomial expansions are employed
  2530.  in each interval.
  2531.  
  2532.  ACCURACY:
  2533.  
  2534.                       Relative error:
  2535.  arithmetic   domain     # trials      peak         rms
  2536.     DEC       0,30         6000       8.2e-17     1.9e-17
  2537.     IEEE      0,30        30000       5.8e-16     1.4e-16
  2538.  
  2539. =item I<i0e>: Modified Bessel function of order zero, exponentially scaled
  2540.  
  2541.  SYNOPSIS:
  2542.  
  2543.  # double x, y, i0e();
  2544.  
  2545.  $y = i0e( $x );
  2546.  
  2547.  DESCRIPTION:
  2548.  
  2549.  Returns exponentially scaled modified Bessel function
  2550.  of order zero of the argument.
  2551.  
  2552.  The function is defined as i0e(x) = exp(-|x|) j0( ix ).
  2553.  
  2554.  ACCURACY:
  2555.  
  2556.                       Relative error:
  2557.  arithmetic   domain     # trials      peak         rms
  2558.     IEEE      0,30        30000       5.4e-16     1.2e-16
  2559.  See i0().
  2560.  
  2561. =item I<i1>: Modified Bessel function of order one
  2562.  
  2563.  SYNOPSIS:
  2564.  
  2565.  # double x, y, i1();
  2566.  
  2567.  $y = i1( $x );
  2568.  
  2569.  DESCRIPTION:
  2570.  
  2571.  Returns modified Bessel function of order one of the
  2572.  argument.
  2573.  
  2574.  The function is defined as i1(x) = -i j1( ix ).
  2575.  
  2576.  The range is partitioned into the two intervals [0,8] and
  2577.  (8, infinity).  Chebyshev polynomial expansions are employed
  2578.  in each interval.
  2579.  
  2580.  ACCURACY:
  2581.  
  2582.                       Relative error:
  2583.  arithmetic   domain     # trials      peak         rms
  2584.     DEC       0, 30        3400       1.2e-16     2.3e-17
  2585.     IEEE      0, 30       30000       1.9e-15     2.1e-16
  2586.  
  2587. =item I<i1e>: Modified Bessel function of order one, exponentially scaled
  2588.  
  2589.  SYNOPSIS:
  2590.  
  2591.  # double x, y, i1e();
  2592.  
  2593.  $y = i1e( $x );
  2594.  
  2595.  DESCRIPTION:
  2596.  
  2597.  Returns exponentially scaled modified Bessel function
  2598.  of order one of the argument.
  2599.  
  2600.  The function is defined as i1(x) = -i exp(-|x|) j1( ix ).
  2601.  
  2602.  ACCURACY:
  2603.  
  2604.                       Relative error:
  2605.  arithmetic   domain     # trials      peak         rms
  2606.     IEEE      0, 30       30000       2.0e-15     2.0e-16
  2607.  See i1().
  2608.  
  2609. =item I<igam>: Incomplete gamma integral
  2610.  
  2611.  SYNOPSIS:
  2612.  
  2613.  # double a, x, y, igam();
  2614.  
  2615.  $y = igam( $a, $x );
  2616.  
  2617.  DESCRIPTION:
  2618.  
  2619.  The function is defined by
  2620.  
  2621.                            x
  2622.                             -
  2623.                    1       | |  -t  a-1
  2624.   igam(a,x)  =   -----     |   e   t   dt.
  2625.                   -      | |
  2626.                  | (a)    -
  2627.                            0
  2628.  
  2629.  In this implementation both arguments must be positive.
  2630.  The integral is evaluated by either a power series or
  2631.  continued fraction expansion, depending on the relative
  2632.  values of a and x.
  2633.  
  2634.  ACCURACY:
  2635.  
  2636.                       Relative error:
  2637.  arithmetic   domain     # trials      peak         rms
  2638.     IEEE      0,30       200000       3.6e-14     2.9e-15
  2639.     IEEE      0,100      300000       9.9e-14     1.5e-14
  2640.  
  2641. =item I<igamc>: Complemented incomplete gamma integral
  2642.  
  2643.  SYNOPSIS:
  2644.  
  2645.  # double a, x, y, igamc();
  2646.  
  2647.  $y = igamc( $a, $x );
  2648.  
  2649.  DESCRIPTION:
  2650.  
  2651.  The function is defined by
  2652.  
  2653.   igamc(a,x)   =   1 - igam(a,x)
  2654.  
  2655.                             inf.
  2656.                               -
  2657.                      1       | |  -t  a-1
  2658.                =   -----     |   e   t   dt.
  2659.                     -      | |
  2660.                    | (a)    -
  2661.                              x
  2662.  
  2663.  In this implementation both arguments must be positive.
  2664.  The integral is evaluated by either a power series or
  2665.  continued fraction expansion, depending on the relative
  2666.  values of a and x.
  2667.  
  2668.  ACCURACY:
  2669.  
  2670.  Tested at random a, x.
  2671.                 a         x                      Relative error:
  2672.  arithmetic   domain   domain     # trials      peak         rms
  2673.     IEEE     0.5,100   0,100      200000       1.9e-14     1.7e-15
  2674.     IEEE     0.01,0.5  0,100      200000       1.4e-13     1.6e-15
  2675.  
  2676. =item I<igami>: Inverse of complemented imcomplete gamma integral
  2677.  
  2678.  SYNOPSIS:
  2679.  
  2680.  # double a, x, p, igami();
  2681.  
  2682.  $x = igami( $a, $p );
  2683.  
  2684.  DESCRIPTION:
  2685.  
  2686.  Given p, the function finds x such that
  2687.  
  2688.   igamc( a, x ) = p.
  2689.  
  2690.  Starting with the approximate value
  2691.  
  2692.          3
  2693.   x = a t
  2694.  
  2695.   where
  2696.  
  2697.   t = 1 - d - ndtri(p) sqrt(d)
  2698.  
  2699.  and
  2700.  
  2701.   d = 1/9a,
  2702.  
  2703.  the routine performs up to 10 Newton iterations to find the
  2704.  root of igamc(a,x) - p = 0.
  2705.  
  2706.  ACCURACY:
  2707.  
  2708.  Tested at random a, p in the intervals indicated.
  2709.  
  2710.                 a        p                      Relative error:
  2711.  arithmetic   domain   domain     # trials      peak         rms
  2712.     IEEE     0.5,100   0,0.5       100000       1.0e-14     1.7e-15
  2713.     IEEE     0.01,0.5  0,0.5       100000       9.0e-14     3.4e-15
  2714.     IEEE    0.5,10000  0,0.5        20000       2.3e-13     3.8e-14
  2715.  
  2716. =item I<incbet>: Incomplete beta integral
  2717.  
  2718.  SYNOPSIS:
  2719.  
  2720.  # double a, b, x, y, incbet();
  2721.  
  2722.  $y = incbet( $a, $b, $x );
  2723.  
  2724.  DESCRIPTION:
  2725.  
  2726.  Returns incomplete beta integral of the arguments, evaluated
  2727.  from zero to x.  The function is defined as
  2728.  
  2729.                   x
  2730.      -            -
  2731.     | (a+b)      | |  a-1     b-1
  2732.   -----------    |   t   (1-t)   dt.
  2733.    -     -     | |
  2734.   | (a) | (b)   -
  2735.                  0
  2736.  
  2737.  The domain of definition is 0 <= x <= 1.  In this
  2738.  implementation a and b are restricted to positive values.
  2739.  The integral from x to 1 may be obtained by the symmetry
  2740.  relation
  2741.  
  2742.     1 - incbet( a, b, x )  =  incbet( b, a, 1-x ).
  2743.  
  2744.  The integral is evaluated by a continued fraction expansion
  2745.  or, when b*x is small, by a power series.
  2746.  
  2747.  ACCURACY:
  2748.  
  2749.  Tested at uniformly distributed random points (a,b,x) with a and b
  2750.  in "domain" and x between 0 and 1.
  2751.                                         Relative error
  2752.  arithmetic   domain     # trials      peak         rms
  2753.     IEEE      0,5         10000       6.9e-15     4.5e-16
  2754.     IEEE      0,85       250000       2.2e-13     1.7e-14
  2755.     IEEE      0,1000      30000       5.3e-12     6.3e-13
  2756.     IEEE      0,10000    250000       9.3e-11     7.1e-12
  2757.     IEEE      0,100000    10000       8.7e-10     4.8e-11
  2758.  Outputs smaller than the IEEE gradual underflow threshold
  2759.  were excluded from these statistics.
  2760.  
  2761.  ERROR MESSAGES:
  2762.    message         condition      value returned
  2763.  incbet domain      x<0, x>1          0.0
  2764.  incbet underflow                     0.0
  2765.  
  2766. =item I<incbi>: Inverse of imcomplete beta integral
  2767.  
  2768.  SYNOPSIS:
  2769.  
  2770.  # double a, b, x, y, incbi();
  2771.  
  2772.  $x = incbi( $a, $b, $y );
  2773.  
  2774.  DESCRIPTION:
  2775.  
  2776.  Given y, the function finds x such that
  2777.  
  2778.   incbet( a, b, x ) = y .
  2779.  
  2780.  The routine performs interval halving or Newton iterations to find the
  2781.  root of incbet(a,b,x) - y = 0.
  2782.  
  2783.  ACCURACY:
  2784.  
  2785.                       Relative error:
  2786.                 x     a,b
  2787.  arithmetic   domain  domain  # trials    peak       rms
  2788.     IEEE      0,1    .5,10000   50000    5.8e-12   1.3e-13
  2789.     IEEE      0,1   .25,100    100000    1.8e-13   3.9e-15
  2790.     IEEE      0,1     0,5       50000    1.1e-12   5.5e-15
  2791.     VAX       0,1    .5,100     25000    3.5e-14   1.1e-15
  2792.  With a and b constrained to half-integer or integer values:
  2793.     IEEE      0,1    .5,10000   50000    5.8e-12   1.1e-13
  2794.     IEEE      0,1    .5,100    100000    1.7e-14   7.9e-16
  2795.  With a = .5, b constrained to half-integer or integer values:
  2796.     IEEE      0,1    .5,10000   10000    8.3e-11   1.0e-11
  2797.  
  2798. =item I<iv>: Modified Bessel function of noninteger order
  2799.  
  2800.  SYNOPSIS:
  2801.  
  2802.  # double v, x, y, iv();
  2803.  
  2804.  $y = iv( $v, $x );
  2805.  
  2806.  DESCRIPTION:
  2807.  
  2808.  Returns modified Bessel function of order v of the
  2809.  argument.  If x is negative, v must be integer valued.
  2810.  
  2811.  The function is defined as Iv(x) = Jv( ix ).  It is
  2812.  here computed in terms of the confluent hypergeometric
  2813.  function, according to the formula
  2814.  
  2815.               v  -x
  2816.  Iv(x) = (x/2)  e   hyperg( v+0.5, 2v+1, 2x ) / gamma(v+1)
  2817.  
  2818.  If v is a negative integer, then v is replaced by -v.
  2819.  
  2820.  ACCURACY:
  2821.  
  2822.  Tested at random points (v, x), with v between 0 and
  2823.  30, x between 0 and 28.
  2824.                       Relative error:
  2825.  arithmetic   domain     # trials      peak         rms
  2826.     DEC       0,30          2000      3.1e-15     5.4e-16
  2827.     IEEE      0,30         10000      1.7e-14     2.7e-15
  2828.  
  2829.  Accuracy is diminished if v is near a negative integer.
  2830.  
  2831.  See also hyperg.c.
  2832.  
  2833. =item I<j0>: Bessel function of order zero
  2834.  
  2835.  SYNOPSIS:
  2836.  
  2837.  # double x, y, j0();
  2838.  
  2839.  $y = j0( $x );
  2840.  
  2841.  DESCRIPTION:
  2842.  
  2843.  Returns Bessel function of order zero of the argument.
  2844.  
  2845.  The domain is divided into the intervals [0, 5] and
  2846.  (5, infinity). In the first interval the following rational
  2847.  approximation is used:
  2848.  
  2849.         2         2
  2850.  (w - r  ) (w - r  ) P (w) / Q (w)
  2851.        1         2    3       8
  2852.  
  2853.             2
  2854.  where w = x  and the two r's are zeros of the function.
  2855.  
  2856.  In the second interval, the Hankel asymptotic expansion
  2857.  is employed with two rational functions of degree 6/6
  2858.  and 7/7.
  2859.  
  2860.  ACCURACY:
  2861.  
  2862.                       Absolute error:
  2863.  arithmetic   domain     # trials      peak         rms
  2864.     DEC       0, 30       10000       4.4e-17     6.3e-18
  2865.     IEEE      0, 30       60000       4.2e-16     1.1e-16
  2866.  
  2867. =item I<y0>: Bessel function of the second kind, order zero
  2868.  
  2869.  SYNOPSIS:
  2870.  
  2871.  # double x, y, y0();
  2872.  
  2873.  $y = y0( $x );
  2874.  
  2875.  DESCRIPTION:
  2876.  
  2877.  Returns Bessel function of the second kind, of order
  2878.  zero, of the argument.
  2879.  
  2880.  The domain is divided into the intervals [0, 5] and
  2881.  (5, infinity). In the first interval a rational approximation
  2882.  R(x) is employed to compute
  2883.    y0(x)  = R(x)  +   2 * log(x) * j0(x) / PI.
  2884.  Thus a call to j0() is required.
  2885.  
  2886.  In the second interval, the Hankel asymptotic expansion
  2887.  is employed with two rational functions of degree 6/6
  2888.  and 7/7.
  2889.  
  2890.  ACCURACY:
  2891.  
  2892.   Absolute error, when y0(x) < 1; else relative error:
  2893.  
  2894.  arithmetic   domain     # trials      peak         rms
  2895.     DEC       0, 30        9400       7.0e-17     7.9e-18
  2896.     IEEE      0, 30       30000       1.3e-15     1.6e-16
  2897.  
  2898. =item I<j1>: Bessel function of order one
  2899.  
  2900.  SYNOPSIS:
  2901.  
  2902.  # double x, y, j1();
  2903.  
  2904.  $y = j1( $x );
  2905.  
  2906.  DESCRIPTION:
  2907.  
  2908.  Returns Bessel function of order one of the argument.
  2909.  
  2910.  The domain is divided into the intervals [0, 8] and
  2911.  (8, infinity). In the first interval a 24 term Chebyshev
  2912.  expansion is used. In the second, the asymptotic
  2913.  trigonometric representation is employed using two
  2914.  rational functions of degree 5/5.
  2915.  
  2916.  ACCURACY:
  2917.  
  2918.                       Absolute error:
  2919.  arithmetic   domain      # trials      peak         rms
  2920.     DEC       0, 30       10000       4.0e-17     1.1e-17
  2921.     IEEE      0, 30       30000       2.6e-16     1.1e-16
  2922.  
  2923. =item I<y1>: Bessel function of second kind of order one
  2924.  
  2925.  SYNOPSIS:
  2926.  
  2927.  # double x, y, y1();
  2928.  
  2929.  $y = y1( $x );
  2930.  
  2931.  DESCRIPTION:
  2932.  
  2933.  Returns Bessel function of the second kind of order one
  2934.  of the argument.
  2935.  
  2936.  The domain is divided into the intervals [0, 8] and
  2937.  (8, infinity). In the first interval a 25 term Chebyshev
  2938.  expansion is used, and a call to j1() is required.
  2939.  In the second, the asymptotic trigonometric representation
  2940.  is employed using two rational functions of degree 5/5.
  2941.  
  2942.  ACCURACY:
  2943.  
  2944.                       Absolute error:
  2945.  arithmetic   domain      # trials      peak         rms
  2946.     DEC       0, 30       10000       8.6e-17     1.3e-17
  2947.     IEEE      0, 30       30000       1.0e-15     1.3e-16
  2948.  
  2949.  (error criterion relative when |y1| > 1).
  2950.  
  2951. =item I<jn>: Bessel function of integer order
  2952.  
  2953.  SYNOPSIS:
  2954.  
  2955.  # int n;
  2956.  # double x, y, jn();
  2957.  
  2958.  $y = jn( $n, $x );
  2959.  
  2960.  DESCRIPTION:
  2961.  
  2962.  Returns Bessel function of order n, where n is a
  2963.  (possibly negative) integer.
  2964.  
  2965.  The ratio of jn(x) to j0(x) is computed by backward
  2966.  recurrence.  First the ratio jn/jn-1 is found by a
  2967.  continued fraction expansion.  Then the recurrence
  2968.  relating successive orders is applied until j0 or j1 is
  2969.  reached.
  2970.  
  2971.  If n = 0 or 1 the routine for j0 or j1 is called
  2972.  directly.
  2973.  
  2974.  ACCURACY:
  2975.  
  2976.                       Absolute error:
  2977.  arithmetic   range      # trials      peak         rms
  2978.     DEC       0, 30        5500       6.9e-17     9.3e-18
  2979.     IEEE      0, 30        5000       4.4e-16     7.9e-17
  2980.  
  2981.  Not suitable for large n or x. Use jv() instead.
  2982.  
  2983. =item I<jv>: Bessel function of noninteger order
  2984.  
  2985.  SYNOPSIS:
  2986.  
  2987.  # double v, x, y, jv();
  2988.  
  2989.  $y = jv( $v, $x );
  2990.  
  2991.  DESCRIPTION:
  2992.  
  2993.  Returns Bessel function of order v of the argument,
  2994.  where v is real.  Negative x is allowed if v is an integer.
  2995.  
  2996.  Several expansions are included: the ascending power
  2997.  series, the Hankel expansion, and two transitional
  2998.  expansions for large v.  If v is not too large, it
  2999.  is reduced by recurrence to a region of best accuracy.
  3000.  The transitional expansions give 12D accuracy for v > 500.
  3001.  
  3002.  ACCURACY:
  3003.  
  3004.  Results for integer v are indicated by *, where x and v
  3005.  both vary from -125 to +125.  Otherwise,
  3006.  x ranges from 0 to 125, v ranges as indicated by "domain."
  3007.  Error criterion is absolute, except relative when |jv()| > 1.
  3008.  
  3009.  arithmetic  v domain  x domain    # trials      peak       rms
  3010.     IEEE      0,125     0,125      100000      4.6e-15    2.2e-16
  3011.     IEEE   -125,0       0,125       40000      5.4e-11    3.7e-13
  3012.     IEEE      0,500     0,500       20000      4.4e-15    4.0e-16
  3013.  Integer v:
  3014.     IEEE   -125,125   -125,125      50000      3.5e-15*   1.9e-16*
  3015.  
  3016. =item I<k0>: Modified Bessel function, third kind, order zero
  3017.  
  3018.  SYNOPSIS:
  3019.  
  3020.  # double x, y, k0();
  3021.  
  3022.  $y = k0( $x );
  3023.  
  3024.  DESCRIPTION:
  3025.  
  3026.  Returns modified Bessel function of the third kind
  3027.  of order zero of the argument.
  3028.  
  3029.  The range is partitioned into the two intervals [0,8] and
  3030.  (8, infinity).  Chebyshev polynomial expansions are employed
  3031.  in each interval.
  3032.  
  3033.  ACCURACY:
  3034.  
  3035.  Tested at 2000 random points between 0 and 8.  Peak absolute
  3036.  error (relative when K0 > 1) was 1.46e-14; rms, 4.26e-15.
  3037.                       Relative error:
  3038.  arithmetic   domain     # trials      peak         rms
  3039.     DEC       0, 30        3100       1.3e-16     2.1e-17
  3040.     IEEE      0, 30       30000       1.2e-15     1.6e-16
  3041.  
  3042.  ERROR MESSAGES:
  3043.  
  3044.    message         condition      value returned
  3045.   K0 domain          x <= 0          MAXNUM
  3046.  
  3047. =item I<k0e>: Modified Bessel function, third kind, order zero, exponentially scaled
  3048.  
  3049.  SYNOPSIS:
  3050.  
  3051.  # double x, y, k0e();
  3052.  
  3053.  $y = k0e( $x );
  3054.  
  3055.  DESCRIPTION:
  3056.  
  3057.  Returns exponentially scaled modified Bessel function
  3058.  of the third kind of order zero of the argument.
  3059.  
  3060.       k0e(x) = exp(x) * k0(x).
  3061.  
  3062.  ACCURACY:
  3063.  
  3064.                       Relative error:
  3065.  arithmetic   domain     # trials      peak         rms
  3066.     IEEE      0, 30       30000       1.4e-15     1.4e-16
  3067.  See k0().
  3068.  
  3069. =item I<k1>: Modified Bessel function, third kind, order one
  3070.  
  3071.  SYNOPSIS:
  3072.  
  3073.  # double x, y, k1();
  3074.  
  3075.  $y = k1( $x );
  3076.  
  3077.  DESCRIPTION:
  3078.  
  3079.  Computes the modified Bessel function of the third kind
  3080.  of order one of the argument.
  3081.  
  3082.  The range is partitioned into the two intervals [0,2] and
  3083.  (2, infinity).  Chebyshev polynomial expansions are employed
  3084.  in each interval.
  3085.  
  3086.  ACCURACY:
  3087.  
  3088.                       Relative error:
  3089.  arithmetic   domain     # trials      peak         rms
  3090.     DEC       0, 30        3300       8.9e-17     2.2e-17
  3091.     IEEE      0, 30       30000       1.2e-15     1.6e-16
  3092.  
  3093.  ERROR MESSAGES:
  3094.  
  3095.    message         condition      value returned
  3096.  k1 domain          x <= 0          MAXNUM
  3097.  
  3098. =item I<k1e>: Modified Bessel function, third kind, order one, exponentially scaled
  3099.  
  3100.  SYNOPSIS:
  3101.  
  3102.  # double x, y, k1e();
  3103.  
  3104.  $y = k1e( $x );
  3105.  
  3106.  DESCRIPTION:
  3107.  
  3108.  Returns exponentially scaled modified Bessel function
  3109.  of the third kind of order one of the argument:
  3110.  
  3111.       k1e(x) = exp(x) * k1(x).
  3112.  
  3113.  ACCURACY:
  3114.  
  3115.                       Relative error:
  3116.  arithmetic   domain     # trials      peak         rms
  3117.     IEEE      0, 30       30000       7.8e-16     1.2e-16
  3118.  See k1().
  3119.  
  3120. =item I<kn>: Modified Bessel function, third kind, integer order
  3121.  
  3122.  SYNOPSIS:
  3123.  
  3124.  # double x, y, kn();
  3125.  # int n;
  3126.  
  3127.  $y = kn( $n, $x );
  3128.  
  3129.  DESCRIPTION:
  3130.  
  3131.  Returns modified Bessel function of the third kind
  3132.  of order n of the argument.
  3133.  
  3134.  The range is partitioned into the two intervals [0,9.55] and
  3135.  (9.55, infinity).  An ascending power series is used in the
  3136.  low range, and an asymptotic expansion in the high range.
  3137.  
  3138.  ACCURACY:
  3139.  
  3140.                       Relative error:
  3141.  arithmetic   domain     # trials      peak         rms
  3142.     DEC       0,30         3000       1.3e-9      5.8e-11
  3143.     IEEE      0,30        90000       1.8e-8      3.0e-10
  3144.  
  3145.   Error is high only near the crossover point x = 9.55
  3146.  between the two expansions used.
  3147.  
  3148. =item I<log>: Natural logarithm
  3149.  
  3150.  SYNOPSIS:
  3151.  
  3152.  # double x, y, log();
  3153.  
  3154.  $y = log( $x );
  3155.  
  3156.  DESCRIPTION:
  3157.  
  3158.  Returns the base e (2.718...) logarithm of x.
  3159.  
  3160.  The argument is separated into its exponent and fractional
  3161.  parts.  If the exponent is between -1 and +1, the logarithm
  3162.  of the fraction is approximated by
  3163.  
  3164.      log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
  3165.  
  3166.  Otherwise, setting  z = 2(x-1)/x+1),
  3167.  
  3168.      log(x) = z + z**3 P(z)/Q(z).
  3169.  
  3170.  ACCURACY:
  3171.  
  3172.                       Relative error:
  3173.  arithmetic   domain     # trials      peak         rms
  3174.     IEEE      0.5, 2.0    150000      1.44e-16    5.06e-17
  3175.     IEEE      +-MAXNUM    30000       1.20e-16    4.78e-17
  3176.     DEC       0, 10       170000      1.8e-17     6.3e-18
  3177.  
  3178.  In the tests over the interval [+-MAXNUM], the logarithms
  3179.  of the random arguments were uniformly distributed over
  3180.  [0, MAXLOG].
  3181.  
  3182.  ERROR MESSAGES:
  3183.  
  3184.  log singularity:  x = 0; returns -INFINITY
  3185.  log domain:       x < 0; returns NAN
  3186.  
  3187. =item I<log10>: Common logarithm
  3188.  
  3189.  SYNOPSIS:
  3190.  
  3191.  # double x, y, log10();
  3192.  
  3193.  $y = log10( $x );
  3194.  
  3195.  DESCRIPTION:
  3196.  
  3197.  Returns logarithm to the base 10 of x.
  3198.  
  3199.  The argument is separated into its exponent and fractional
  3200.  parts.  The logarithm of the fraction is approximated by
  3201.  
  3202.      log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
  3203.  
  3204.  ACCURACY:
  3205.  
  3206.                       Relative error:
  3207.  arithmetic   domain     # trials      peak         rms
  3208.     IEEE      0.5, 2.0     30000      1.5e-16     5.0e-17
  3209.     IEEE      0, MAXNUM    30000      1.4e-16     4.8e-17
  3210.     DEC       1, MAXNUM    50000      2.5e-17     6.0e-18
  3211.  
  3212.  In the tests over the interval [1, MAXNUM], the logarithms
  3213.  of the random arguments were uniformly distributed over
  3214.  [0, MAXLOG].
  3215.  
  3216.  ERROR MESSAGES:
  3217.  
  3218.  log10 singularity:  x = 0; returns -INFINITY
  3219.  log10 domain:       x < 0; returns NAN
  3220.  
  3221. =item I<log2>: Base 2 logarithm
  3222.  
  3223.  SYNOPSIS:
  3224.  
  3225.  # double x, y, log2();
  3226.  
  3227.  $y = log2( $x );
  3228.  
  3229.  DESCRIPTION:
  3230.  
  3231.  Returns the base 2 logarithm of x.
  3232.  
  3233.  The argument is separated into its exponent and fractional
  3234.  parts.  If the exponent is between -1 and +1, the base e
  3235.  logarithm of the fraction is approximated by
  3236.  
  3237.      log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
  3238.  
  3239.  Otherwise, setting  z = 2(x-1)/x+1),
  3240.  
  3241.      log(x) = z + z**3 P(z)/Q(z).
  3242.  
  3243.  ACCURACY:
  3244.  
  3245.                       Relative error:
  3246.  arithmetic   domain     # trials      peak         rms
  3247.     IEEE      0.5, 2.0    30000       2.0e-16     5.5e-17
  3248.     IEEE      exp(+-700)  40000       1.3e-16     4.6e-17
  3249.  
  3250.  In the tests over the interval [exp(+-700)], the logarithms
  3251.  of the random arguments were uniformly distributed.
  3252.  
  3253.  ERROR MESSAGES:
  3254.  
  3255.  log2 singularity:  x = 0; returns -INFINITY
  3256.  log2 domain:       x < 0; returns NAN
  3257.  
  3258. =item I<lrand>: Pseudorandom number generator
  3259.  
  3260.  SYNOPSIS:
  3261.  
  3262.  long y, lrand();
  3263.  
  3264.  $y = lrand( );
  3265.  
  3266.  DESCRIPTION:
  3267.  
  3268.  Yields a long integer random number.
  3269.  
  3270.  The three-generator congruential algorithm by Brian
  3271.  Wichmann and David Hill (BYTE magazine, March, 1987,
  3272.  pp 127-8) is used. The period, given by them, is
  3273.  6953607871644.
  3274.  
  3275. =item I<lsqrt>: Integer square root
  3276.  
  3277.  SYNOPSIS:
  3278.  
  3279.  long x, y;
  3280.  long lsqrt();
  3281.  
  3282.  $y = lsqrt( $x );
  3283.  
  3284.  DESCRIPTION:
  3285.  
  3286.  Returns a long integer square root of the long integer
  3287.  argument.  The computation is by binary long division.
  3288.  
  3289.  The largest possible result is lsqrt(2,147,483,647)
  3290.  = 46341.
  3291.  
  3292.  If x < 0, the square root of |x| is returned, and an
  3293.  error message is printed.
  3294.  
  3295.  ACCURACY:
  3296.  
  3297.  An extra, roundoff, bit is computed; hence the result
  3298.  is the nearest integer to the actual square root.
  3299.  NOTE: only DEC arithmetic is currently supported.
  3300.  
  3301. =item I<mtherr>: Library common error handling routine
  3302.  
  3303.  SYNOPSIS:
  3304.  
  3305.  char *fctnam;
  3306.  # int code;
  3307.  # int mtherr();
  3308.  
  3309.  mtherr( $fctnam, $code );
  3310.  
  3311.  DESCRIPTION:
  3312.  
  3313.  This routine may be called to report one of the following
  3314.  error conditions (in the include file mconf.h).
  3315.   
  3316.    Mnemonic        Value          Significance
  3317.  
  3318.     DOMAIN            1       argument domain error
  3319.     SING              2       function singularity
  3320.     OVERFLOW          3       overflow range error
  3321.     UNDERFLOW         4       underflow range error
  3322.     TLOSS             5       total loss of precision
  3323.     PLOSS             6       partial loss of precision
  3324.     EDOM             33       Unix domain error code
  3325.     ERANGE           34       Unix range error code
  3326.  
  3327.  The default version of the file prints the function name,
  3328.  passed to it by the pointer fctnam, followed by the
  3329.  error condition.  The display is directed to the standard
  3330.  output device.  The routine then returns to the calling
  3331.  program.  Users may wish to modify the program to abort by
  3332.  calling exit() under severe error conditions such as domain
  3333.  errors.
  3334.  
  3335.  Since all error conditions pass control to this function,
  3336.  the display may be easily changed, eliminated, or directed
  3337.  to an error logging device.
  3338.  
  3339.  SEE ALSO: mconf.h
  3340.  
  3341. =item I<nbdtr>: Negative binomial distribution
  3342.  
  3343.  SYNOPSIS:
  3344.  
  3345.  # int k, n;
  3346.  # double p, y, nbdtr();
  3347.  
  3348.  $y = nbdtr( $k, $n, $p );
  3349.  
  3350.  DESCRIPTION:
  3351.  
  3352.  Returns the sum of the terms 0 through k of the negative
  3353.  binomial distribution:
  3354.  
  3355.    k
  3356.    --  ( n+j-1 )   n      j
  3357.    >   (       )  p  (1-p)
  3358.    --  (   j   )
  3359.   j=0
  3360.  
  3361.  In a sequence of Bernoulli trials, this is the probability
  3362.  that k or fewer failures precede the nth success.
  3363.  
  3364.  The terms are not computed individually; instead the incomplete
  3365.  beta integral is employed, according to the formula
  3366.  
  3367.  y = nbdtr( k, n, p ) = incbet( n, k+1, p ).
  3368.  
  3369.  The arguments must be positive, with p ranging from 0 to 1.
  3370.  
  3371.  ACCURACY:
  3372.  
  3373.  Tested at random points (a,b,p), with p between 0 and 1.
  3374.  
  3375.                a,b                     Relative error:
  3376.  arithmetic  domain     # trials      peak         rms
  3377.     IEEE     0,100       100000      1.7e-13     8.8e-15
  3378.  See also incbet.c.
  3379.  
  3380. =item I<nbdtrc>: Complemented negative binomial distribution
  3381.  
  3382.  SYNOPSIS:
  3383.  
  3384.  # int k, n;
  3385.  # double p, y, nbdtrc();
  3386.  
  3387.  $y = nbdtrc( $k, $n, $p );
  3388.  
  3389.  DESCRIPTION:
  3390.  
  3391.  Returns the sum of the terms k+1 to infinity of the negative
  3392.  binomial distribution:
  3393.  
  3394.    inf
  3395.    --  ( n+j-1 )   n      j
  3396.    >   (       )  p  (1-p)
  3397.    --  (   j   )
  3398.   j=k+1
  3399.  
  3400.  The terms are not computed individually; instead the incomplete
  3401.  beta integral is employed, according to the formula
  3402.  
  3403.  y = nbdtrc( k, n, p ) = incbet( k+1, n, 1-p ).
  3404.  
  3405.  The arguments must be positive, with p ranging from 0 to 1.
  3406.  
  3407.  ACCURACY:
  3408.  
  3409.  Tested at random points (a,b,p), with p between 0 and 1.
  3410.  
  3411.                a,b                     Relative error:
  3412.  arithmetic  domain     # trials      peak         rms
  3413.     IEEE     0,100       100000      1.7e-13     8.8e-15
  3414.  See also incbet.c.
  3415.  
  3416. =item I<nbdtrc>: Complemented negative binomial distribution
  3417.  
  3418.  SYNOPSIS:
  3419.  
  3420.  # int k, n;
  3421.  # double p, y, nbdtrc();
  3422.  
  3423.  $y = nbdtrc( $k, $n, $p );
  3424.  
  3425.  DESCRIPTION:
  3426.  
  3427.  Returns the sum of the terms k+1 to infinity of the negative
  3428.  binomial distribution:
  3429.  
  3430.    inf
  3431.    --  ( n+j-1 )   n      j
  3432.    >   (       )  p  (1-p)
  3433.    --  (   j   )
  3434.   j=k+1
  3435.  
  3436.  The terms are not computed individually; instead the incomplete
  3437.  beta integral is employed, according to the formula
  3438.  
  3439.  y = nbdtrc( k, n, p ) = incbet( k+1, n, 1-p ).
  3440.  
  3441.  The arguments must be positive, with p ranging from 0 to 1.
  3442.  
  3443.  ACCURACY:
  3444.  
  3445.  See incbet.c.
  3446.  
  3447. =item I<nbdtri>: Functional inverse of negative binomial distribution
  3448.  
  3449.  SYNOPSIS:
  3450.  
  3451.  # int k, n;
  3452.  # double p, y, nbdtri();
  3453.  
  3454.  $p = nbdtri( $k, $n, $y );
  3455.  
  3456.  DESCRIPTION:
  3457.  
  3458.  Finds the argument p such that nbdtr(k,n,p) is equal to y.
  3459.  
  3460.  ACCURACY:
  3461.  
  3462.  Tested at random points (a,b,y), with y between 0 and 1.
  3463.  
  3464.                a,b                     Relative error:
  3465.  arithmetic  domain     # trials      peak         rms
  3466.     IEEE     0,100       100000      1.5e-14     8.5e-16
  3467.  See also incbi.c.
  3468.  
  3469. =item I<ndtr>: Normal distribution function
  3470.  
  3471.  SYNOPSIS:
  3472.  
  3473.  # double x, y, ndtr();
  3474.  
  3475.  $y = ndtr( $x );
  3476.  
  3477.  DESCRIPTION:
  3478.  
  3479.  Returns the area under the Gaussian probability density
  3480.  function, integrated from minus infinity to x:
  3481.  
  3482.                             x
  3483.                              -
  3484.                    1        | |          2
  3485.     ndtr(x)  = ---------    |    exp( - t /2 ) dt
  3486.                sqrt(2pi)  | |
  3487.                            -
  3488.                           -inf.
  3489.  
  3490.              =  ( 1 + erf(z) ) / 2
  3491.  
  3492.  where z = x/sqrt(2). Computation is via the functions
  3493.  erf and erfc.
  3494.  
  3495.  ACCURACY:
  3496.  
  3497.                       Relative error:
  3498.  arithmetic   domain     # trials      peak         rms
  3499.     DEC      -13,0         8000       2.1e-15     4.8e-16
  3500.     IEEE     -13,0        30000       3.4e-14     6.7e-15
  3501.  
  3502.  ERROR MESSAGES:
  3503.  
  3504.    message         condition         value returned
  3505.  erfc underflow    x > 37.519379347       0.0
  3506.  
  3507. =item I<erf>: Error function
  3508.  
  3509.  SYNOPSIS:
  3510.  
  3511.  # double x, y, erf();
  3512.  
  3513.  $y = erf( $x );
  3514.  
  3515.  DESCRIPTION:
  3516.  
  3517.  The integral is
  3518.  
  3519.                            x 
  3520.                             -
  3521.                  2         | |          2
  3522.    erf(x)  =  --------     |    exp( - t  ) dt.
  3523.               sqrt(pi)   | |
  3524.                           -
  3525.                            0
  3526.  
  3527.  The magnitude of x is limited to 9.231948545 for DEC
  3528.  arithmetic; 1 or -1 is returned outside this range.
  3529.  
  3530.  For 0 <= |x| < 1, erf(x) = x * P4(x**2)/Q5(x**2); otherwise
  3531.  erf(x) = 1 - erfc(x).
  3532.  
  3533.  ACCURACY:
  3534.  
  3535.                       Relative error:
  3536.  arithmetic   domain     # trials      peak         rms
  3537.     DEC       0,1         14000       4.7e-17     1.5e-17
  3538.     IEEE      0,1         30000       3.7e-16     1.0e-16
  3539.  
  3540. =item I<erfc>: Complementary error function
  3541.  
  3542.  SYNOPSIS:
  3543.  
  3544.  # double x, y, erfc();
  3545.  
  3546.  $y = erfc( $x );
  3547.  
  3548.  DESCRIPTION:
  3549.  
  3550.   1 - erf(x) =
  3551.  
  3552.                            inf. 
  3553.                              -
  3554.                   2         | |          2
  3555.    erfc(x)  =  --------     |    exp( - t  ) dt
  3556.                sqrt(pi)   | |
  3557.                            -
  3558.                             x
  3559.  
  3560.  For small x, erfc(x) = 1 - erf(x); otherwise rational
  3561.  approximations are computed.
  3562.  
  3563.  ACCURACY:
  3564.  
  3565.                       Relative error:
  3566.  arithmetic   domain     # trials      peak         rms
  3567.     DEC       0, 9.2319   12000       5.1e-16     1.2e-16
  3568.     IEEE      0,26.6417   30000       5.7e-14     1.5e-14
  3569.  
  3570.  ERROR MESSAGES:
  3571.  
  3572.    message         condition              value returned
  3573.  erfc underflow    x > 9.231948545 (DEC)       0.0
  3574.  
  3575. =item I<ndtri>: Inverse of Normal distribution function
  3576.  
  3577.  SYNOPSIS:
  3578.  
  3579.  # double x, y, ndtri();
  3580.  
  3581.  $x = ndtri( $y );
  3582.  
  3583.  DESCRIPTION:
  3584.  
  3585.  Returns the argument, x, for which the area under the
  3586.  Gaussian probability density function (integrated from
  3587.  minus infinity to x) is equal to y.
  3588.  
  3589.  For small arguments 0 < y < exp(-2), the program computes
  3590.  z = sqrt( -2.0 * log(y) );  then the approximation is
  3591.  x = z - log(z)/z  - (1/z) P(1/z) / Q(1/z).
  3592.  There are two rational functions P/Q, one for 0 < y < exp(-32)
  3593.  and the other for y up to exp(-2).  For larger arguments,
  3594.  w = y - 0.5, and  x/sqrt(2pi) = w + w**3 R(w**2)/S(w**2)).
  3595.  
  3596.  ACCURACY:
  3597.  
  3598.                       Relative error:
  3599.  arithmetic   domain        # trials      peak         rms
  3600.     DEC      0.125, 1         5500       9.5e-17     2.1e-17
  3601.     DEC      6e-39, 0.135     3500       5.7e-17     1.3e-17
  3602.     IEEE     0.125, 1        20000       7.2e-16     1.3e-16
  3603.     IEEE     3e-308, 0.135   50000       4.6e-16     9.8e-17
  3604.  
  3605.  ERROR MESSAGES:
  3606.  
  3607.    message         condition    value returned
  3608.  ndtri domain       x <= 0        -MAXNUM
  3609.  ndtri domain       x >= 1         MAXNUM
  3610.  
  3611. =item I<pdtr>: Poisson distribution
  3612.  
  3613.  SYNOPSIS:
  3614.  
  3615.  # int k;
  3616.  # double m, y, pdtr();
  3617.  
  3618.  $y = pdtr( $k, $m );
  3619.  
  3620.  DESCRIPTION:
  3621.  
  3622.  Returns the sum of the first k terms of the Poisson
  3623.  distribution:
  3624.  
  3625.    k         j
  3626.    --   -m  m
  3627.    >   e    --
  3628.    --       j!
  3629.   j=0
  3630.  
  3631.  The terms are not summed directly; instead the incomplete
  3632.  gamma integral is employed, according to the relation
  3633.  
  3634.  y = pdtr( k, m ) = igamc( k+1, m ).
  3635.  
  3636.  The arguments must both be positive.
  3637.  
  3638.  ACCURACY:
  3639.  
  3640.  See igamc().
  3641.  
  3642. =item I<pdtrc>: Complemented poisson distribution
  3643.  
  3644.  SYNOPSIS:
  3645.  
  3646.  # int k;
  3647.  # double m, y, pdtrc();
  3648.  
  3649.  $y = pdtrc( $k, $m );
  3650.  
  3651.  DESCRIPTION:
  3652.  
  3653.  Returns the sum of the terms k+1 to infinity of the Poisson
  3654.  distribution:
  3655.  
  3656.   inf.       j
  3657.    --   -m  m
  3658.    >   e    --
  3659.    --       j!
  3660.   j=k+1
  3661.  
  3662.  The terms are not summed directly; instead the incomplete
  3663.  gamma integral is employed, according to the formula
  3664.  
  3665.  y = pdtrc( k, m ) = igam( k+1, m ).
  3666.  
  3667.  The arguments must both be positive.
  3668.  
  3669.  ACCURACY:
  3670.  
  3671.  See igam.c.
  3672.  
  3673. =item I<pdtri>: Inverse Poisson distribution
  3674.  
  3675.  SYNOPSIS:
  3676.  
  3677.  # int k;
  3678.  # double m, y, pdtr();
  3679.  
  3680.  $m = pdtri( $k, $y );
  3681.  
  3682.  DESCRIPTION:
  3683.  
  3684.  Finds the Poisson variable x such that the integral
  3685.  from 0 to x of the Poisson density is equal to the
  3686.  given probability y.
  3687.  
  3688.  This is accomplished using the inverse gamma integral
  3689.  function and the relation
  3690.  
  3691.     m = igami( k+1, y ).
  3692.  
  3693.  ACCURACY:
  3694.  
  3695.  See igami.c.
  3696.  
  3697.  ERROR MESSAGES:
  3698.  
  3699.    message         condition      value returned
  3700.  pdtri domain    y < 0 or y >= 1       0.0
  3701.                      k < 0
  3702.  
  3703. =item I<pow>: Power function
  3704.  
  3705.  SYNOPSIS:
  3706.  
  3707.  # double x, y, z, pow();
  3708.  
  3709.  $z = pow( $x, $y );
  3710.  
  3711.  DESCRIPTION:
  3712.  
  3713.  Computes x raised to the yth power.  Analytically,
  3714.  
  3715.       x**y  =  exp( y log(x) ).
  3716.  
  3717.  Following Cody and Waite, this program uses a lookup table
  3718.  of 2**-i/16 and pseudo extended precision arithmetic to
  3719.  obtain an extra three bits of accuracy in both the logarithm
  3720.  and the exponential.
  3721.  
  3722.  ACCURACY:
  3723.  
  3724.                       Relative error:
  3725.  arithmetic   domain     # trials      peak         rms
  3726.     IEEE     -26,26       30000      4.2e-16      7.7e-17
  3727.     DEC      -26,26       60000      4.8e-17      9.1e-18
  3728.  1/26 < x < 26, with log(x) uniformly distributed.
  3729.  -26 < y < 26, y uniformly distributed.
  3730.     IEEE     0,8700       30000      1.5e-14      2.1e-15
  3731.  0.99 < x < 1.01, 0 < y < 8700, uniformly distributed.
  3732.  
  3733.  ERROR MESSAGES:
  3734.  
  3735.    message         condition      value returned
  3736.  pow overflow     x**y > MAXNUM      INFINITY
  3737.  pow underflow   x**y < 1/MAXNUM       0.0
  3738.  pow domain      x<0 and y noninteger  0.0
  3739.  
  3740. =item I<powi>: Real raised to integer power
  3741.  
  3742.  SYNOPSIS:
  3743.  
  3744.  # double x, y, powi();
  3745.  # int n;
  3746.  
  3747.  $y = powi( $x, $n );
  3748.  
  3749.  DESCRIPTION:
  3750.  
  3751.  Returns argument x raised to the nth power.
  3752.  The routine efficiently decomposes n as a sum of powers of
  3753.  two. The desired power is a product of two-to-the-kth
  3754.  powers of x.  Thus to compute the 32767 power of x requires
  3755.  28 multiplications instead of 32767 multiplications.
  3756.  
  3757.  ACCURACY:
  3758.  
  3759.                       Relative error:
  3760.  arithmetic   x domain   n domain  # trials      peak         rms
  3761.     DEC       .04,26     -26,26    100000       2.7e-16     4.3e-17
  3762.     IEEE      .04,26     -26,26     50000       2.0e-15     3.8e-16
  3763.     IEEE        1,2    -1022,1023   50000       8.6e-14     1.6e-14
  3764.  
  3765.  Returns MAXNUM on overflow, zero on underflow.
  3766.  
  3767. =item I<psi>: Psi (digamma) function
  3768.  
  3769.  SYNOPSIS:
  3770.  
  3771.  # double x, y, psi();
  3772.  
  3773.  $y = psi( $x );
  3774.  
  3775.  DESCRIPTION:
  3776.  
  3777.               d      -
  3778.    psi(x)  =  -- ln | (x)
  3779.               dx
  3780.  
  3781.  is the logarithmic derivative of the gamma function.
  3782.  For integer x,
  3783.                    n-1
  3784.                     -
  3785.  psi(n) = -EUL  +   >  1/k.
  3786.                     -
  3787.                    k=1
  3788.  
  3789.  This formula is used for 0 < n <= 10.  If x is negative, it
  3790.  is transformed to a positive argument by the reflection
  3791.  formula  psi(1-x) = psi(x) + pi cot(pi x).
  3792.  For general positive x, the argument is made greater than 10
  3793.  using the recurrence  psi(x+1) = psi(x) + 1/x.
  3794.  Then the following asymptotic expansion is applied:
  3795.  
  3796.                            inf.   B
  3797.                             -      2k
  3798.  psi(x) = log(x) - 1/2x -   >   -------
  3799.                             -        2k
  3800.                            k=1   2k x
  3801.  
  3802.  where the B2k are Bernoulli numbers.
  3803.  
  3804.  ACCURACY:
  3805.     Relative error (except absolute when |psi| < 1):
  3806.  arithmetic   domain     # trials      peak         rms
  3807.     DEC       0,30         2500       1.7e-16     2.0e-17
  3808.     IEEE      0,30        30000       1.3e-15     1.4e-16
  3809.     IEEE      -30,0       40000       1.5e-15     2.2e-16
  3810.  
  3811.  ERROR MESSAGES:
  3812.      message         condition      value returned
  3813.  psi singularity    x integer <=0      MAXNUM
  3814.  
  3815. =item I<rgamma>: Reciprocal gamma function
  3816.  
  3817.  SYNOPSIS:
  3818.  
  3819.  # double x, y, rgamma();
  3820.  
  3821.  $y = rgamma( $x );
  3822.  
  3823.  DESCRIPTION:
  3824.  
  3825.  Returns one divided by the gamma function of the argument.
  3826.  
  3827.  The function is approximated by a Chebyshev expansion in
  3828.  the interval [0,1].  Range reduction is by recurrence
  3829.  for arguments between -34.034 and +34.84425627277176174.
  3830.  1/MAXNUM is returned for positive arguments outside this
  3831.  range.  For arguments less than -34.034 the cosecant
  3832.  reflection formula is applied; lograrithms are employed
  3833.  to avoid unnecessary overflow.
  3834.  
  3835.  The reciprocal gamma function has no singularities,
  3836.  but overflow and underflow may occur for large arguments.
  3837.  These conditions return either MAXNUM or 1/MAXNUM with
  3838.  appropriate sign.
  3839.  
  3840.  ACCURACY:
  3841.  
  3842.                       Relative error:
  3843.  arithmetic   domain     # trials      peak         rms
  3844.     DEC      -30,+30       4000       1.2e-16     1.8e-17
  3845.     IEEE     -30,+30      30000       1.1e-15     2.0e-16
  3846.  For arguments less than -34.034 the peak error is on the
  3847.  order of 5e-15 (DEC), excepting overflow or underflow.
  3848.  
  3849. =item I<round>: Round double to nearest or even integer valued double
  3850.  
  3851.  SYNOPSIS:
  3852.  
  3853.  # double x, y, round();
  3854.  
  3855.  $y = round( $x );
  3856.  
  3857.  DESCRIPTION:
  3858.  
  3859.  Returns the nearest integer to x as a double precision
  3860.  floating point result.  If x ends in 0.5 exactly, the
  3861.  nearest even integer is chosen.
  3862.  
  3863.  ACCURACY:
  3864.  
  3865.  If x is greater than 1/(2*MACHEP), its closest machine
  3866.  representation is already an integer, so rounding does
  3867.  not change it.
  3868.  
  3869. =item I<shichi>: Hyperbolic sine and cosine integrals
  3870.  
  3871.  SYNOPSIS:
  3872.  
  3873.  # double x, Chi, Shi, shichi();
  3874.  
  3875.  ($flag, $Shi, $Chi) = shichi( $x );
  3876.  
  3877.  DESCRIPTION:
  3878.  
  3879.  Approximates the integrals
  3880.  
  3881.                             x
  3882.                             -
  3883.                            | |   cosh t - 1
  3884.    Chi(x) = eul + ln x +   |    -----------  dt,
  3885.                          | |          t
  3886.                           -
  3887.                           0
  3888.  
  3889.                x
  3890.                -
  3891.               | |  sinh t
  3892.    Shi(x) =   |    ------  dt
  3893.             | |       t
  3894.              -
  3895.              0
  3896.  
  3897.  where eul = 0.57721566490153286061 is Euler's constant.
  3898.  The integrals are evaluated by power series for x < 8
  3899.  and by Chebyshev expansions for x between 8 and 88.
  3900.  For large x, both functions approach exp(x)/2x.
  3901.  Arguments greater than 88 in magnitude return MAXNUM.
  3902.  
  3903.  ACCURACY:
  3904.  
  3905.  Test interval 0 to 88.
  3906.                       Relative error:
  3907.  arithmetic   function  # trials      peak         rms
  3908.     DEC          Shi       3000       9.1e-17
  3909.     IEEE         Shi      30000       6.9e-16     1.6e-16
  3910.         Absolute error, except relative when |Chi| > 1:
  3911.     DEC          Chi       2500       9.3e-17
  3912.     IEEE         Chi      30000       8.4e-16     1.4e-16
  3913.  
  3914. =item I<sici>: Sine and cosine integrals
  3915.  
  3916.  SYNOPSIS:
  3917.  
  3918.  # double x, Ci, Si, sici();
  3919.  
  3920.  ($flag, $Si, $Ci) = sici( $x );
  3921.  
  3922.  DESCRIPTION:
  3923.  
  3924.  Evaluates the integrals
  3925.  
  3926.                           x
  3927.                           -
  3928.                          |  cos t - 1
  3929.    Ci(x) = eul + ln x +  |  --------- dt,
  3930.                          |      t
  3931.                         -
  3932.                          0
  3933.              x
  3934.              -
  3935.             |  sin t
  3936.    Si(x) =  |  ----- dt
  3937.             |    t
  3938.            -
  3939.             0
  3940.  
  3941.  where eul = 0.57721566490153286061 is Euler's constant.
  3942.  The integrals are approximated by rational functions.
  3943.  For x > 8 auxiliary functions f(x) and g(x) are employed
  3944.  such that
  3945.  
  3946.  Ci(x) = f(x) sin(x) - g(x) cos(x)
  3947.  Si(x) = pi/2 - f(x) cos(x) - g(x) sin(x)
  3948.  
  3949.  ACCURACY:
  3950.     Test interval = [0,50].
  3951.  Absolute error, except relative when > 1:
  3952.  arithmetic   function   # trials      peak         rms
  3953.     IEEE        Si        30000       4.4e-16     7.3e-17
  3954.     IEEE        Ci        30000       6.9e-16     5.1e-17
  3955.     DEC         Si         5000       4.4e-17     9.0e-18
  3956.     DEC         Ci         5300       7.9e-17     5.2e-18
  3957.  
  3958. =item I<sin>: Circular sine
  3959.  
  3960.  SYNOPSIS:
  3961.  
  3962.  # double x, y, sin();
  3963.  
  3964.  $y = sin( $x );
  3965.  
  3966.  DESCRIPTION:
  3967.  
  3968.  Range reduction is into intervals of pi/4.  The reduction
  3969.  error is nearly eliminated by contriving an extended precision
  3970.  modular arithmetic.
  3971.  
  3972.  Two polynomial approximating functions are employed.
  3973.  Between 0 and pi/4 the sine is approximated by
  3974.       x  +  x**3 P(x**2).
  3975.  Between pi/4 and pi/2 the cosine is represented as
  3976.       1  -  x**2 Q(x**2).
  3977.  
  3978.  ACCURACY:
  3979.  
  3980.                       Relative error:
  3981.  arithmetic   domain      # trials      peak         rms
  3982.     DEC       0, 10       150000       3.0e-17     7.8e-18
  3983.     IEEE -1.07e9,+1.07e9  130000       2.1e-16     5.4e-17
  3984.  
  3985.  ERROR MESSAGES:
  3986.  
  3987.    message           condition        value returned
  3988.  sin total loss   x > 1.073741824e9      0.0
  3989.  
  3990.  Partial loss of accuracy begins to occur at x = 2**30
  3991.  = 1.074e9.  The loss is not gradual, but jumps suddenly to
  3992.  about 1 part in 10e7.  Results may be meaningless for
  3993.  x > 2**49 = 5.6e14.  The routine as implemented flags a
  3994.  TLOSS error for x > 2**30 and returns 0.0.
  3995.  
  3996. =item I<cos>: Circular cosine
  3997.  
  3998.  SYNOPSIS:
  3999.  
  4000.  # double x, y, cos();
  4001.  
  4002.  $y = cos( $x );
  4003.  
  4004.  DESCRIPTION:
  4005.  
  4006.  Range reduction is into intervals of pi/4.  The reduction
  4007.  error is nearly eliminated by contriving an extended precision
  4008.  modular arithmetic.
  4009.  
  4010.  Two polynomial approximating functions are employed.
  4011.  Between 0 and pi/4 the cosine is approximated by
  4012.       1  -  x**2 Q(x**2).
  4013.  Between pi/4 and pi/2 the sine is represented as
  4014.       x  +  x**3 P(x**2).
  4015.  
  4016.  ACCURACY:
  4017.  
  4018.                       Relative error:
  4019.  arithmetic   domain      # trials      peak         rms
  4020.     IEEE -1.07e9,+1.07e9  130000       2.1e-16     5.4e-17
  4021.     DEC        0,+1.07e9   17000       3.0e-17     7.2e-18
  4022.  
  4023. =item I<sindg>: Circular sine of angle in degrees
  4024.  
  4025.  SYNOPSIS:
  4026.  
  4027.  # double x, y, sindg();
  4028.  
  4029.  $y = sindg( $x );
  4030.  
  4031.  DESCRIPTION:
  4032.  
  4033.  Range reduction is into intervals of 45 degrees.
  4034.  
  4035.  Two polynomial approximating functions are employed.
  4036.  Between 0 and pi/4 the sine is approximated by
  4037.       x  +  x**3 P(x**2).
  4038.  Between pi/4 and pi/2 the cosine is represented as
  4039.       1  -  x**2 P(x**2).
  4040.  
  4041.  ACCURACY:
  4042.  
  4043.                       Relative error:
  4044.  arithmetic   domain      # trials      peak         rms
  4045.     DEC       +-1000        3100      3.3e-17      9.0e-18
  4046.     IEEE      +-1000       30000      2.3e-16      5.6e-17
  4047.  
  4048.  ERROR MESSAGES:
  4049.  
  4050.    message           condition        value returned
  4051.  sindg total loss   x > 8.0e14 (DEC)      0.0
  4052.                     x > 1.0e14 (IEEE)
  4053.  
  4054. =item I<cosdg>: Circular cosine of angle in degrees
  4055.  
  4056.  SYNOPSIS:
  4057.  
  4058.  # double x, y, cosdg();
  4059.  
  4060.  $y = cosdg( $x );
  4061.  
  4062.  DESCRIPTION:
  4063.  
  4064.  Range reduction is into intervals of 45 degrees.
  4065.  
  4066.  Two polynomial approximating functions are employed.
  4067.  Between 0 and pi/4 the cosine is approximated by
  4068.       1  -  x**2 P(x**2).
  4069.  Between pi/4 and pi/2 the sine is represented as
  4070.       x  +  x**3 P(x**2).
  4071.  
  4072.  ACCURACY:
  4073.  
  4074.                       Relative error:
  4075.  arithmetic   domain      # trials      peak         rms
  4076.     DEC      +-1000         3400       3.5e-17     9.1e-18
  4077.     IEEE     +-1000        30000       2.1e-16     5.7e-17
  4078.   See also sin().
  4079.  
  4080. =item I<sinh>: Hyperbolic sine
  4081.  
  4082.  SYNOPSIS:
  4083.  
  4084.  # double x, y, sinh();
  4085.  
  4086.  $y = sinh( $x );
  4087.  
  4088.  DESCRIPTION:
  4089.  
  4090.  Returns hyperbolic sine of argument in the range MINLOG to
  4091.  MAXLOG.
  4092.  
  4093.  The range is partitioned into two segments.  If |x| <= 1, a
  4094.  rational function of the form x + x**3 P(x)/Q(x) is employed.
  4095.  Otherwise the calculation is sinh(x) = ( exp(x) - exp(-x) )/2.
  4096.  
  4097.  ACCURACY:
  4098.  
  4099.                       Relative error:
  4100.  arithmetic   domain     # trials      peak         rms
  4101.     DEC      +- 88        50000       4.0e-17     7.7e-18
  4102.     IEEE     +-MAXLOG     30000       2.6e-16     5.7e-17
  4103.  
  4104. =item I<spence>: Dilogarithm
  4105.  
  4106.  SYNOPSIS:
  4107.  
  4108.  # double x, y, spence();
  4109.  
  4110.  $y = spence( $x );
  4111.  
  4112.  DESCRIPTION:
  4113.  
  4114.  Computes the integral
  4115.  
  4116.                     x
  4117.                     -
  4118.                    | | log t
  4119.  spence(x)  =  -   |   ----- dt
  4120.                  | |   t - 1
  4121.                   -
  4122.                   1
  4123.  
  4124.  for x >= 0.  A rational approximation gives the integral in
  4125.  the interval (0.5, 1.5).  Transformation formulas for 1/x
  4126.  and 1-x are employed outside the basic expansion range.
  4127.  
  4128.  ACCURACY:
  4129.  
  4130.                       Relative error:
  4131.  arithmetic   domain     # trials      peak         rms
  4132.     IEEE      0,4         30000       3.9e-15     5.4e-16
  4133.     DEC       0,4          3000       2.5e-16     4.5e-17
  4134.  
  4135. =item I<sqrt>: Square root
  4136.  
  4137.  SYNOPSIS:
  4138.  
  4139.  # double x, y, sqrt();
  4140.  
  4141.  $y = sqrt( $x );
  4142.  
  4143.  DESCRIPTION:
  4144.  
  4145.  Returns the square root of x.
  4146.  
  4147.  Range reduction involves isolating the power of two of the
  4148.  argument and using a polynomial approximation to obtain
  4149.  a rough value for the square root.  Then Heron's iteration
  4150.  is used three times to converge to an accurate value.
  4151.  
  4152.  ACCURACY:
  4153.  
  4154.                       Relative error:
  4155.  arithmetic   domain     # trials      peak         rms
  4156.     DEC       0, 10       60000       2.1e-17     7.9e-18
  4157.     IEEE      0,1.7e308   30000       1.7e-16     6.3e-17
  4158.  
  4159.  ERROR MESSAGES:
  4160.  
  4161.    message         condition      value returned
  4162.  sqrt domain        x < 0            0.0
  4163.  
  4164. =item I<stdtr>: Student's t distribution
  4165.  
  4166.  SYNOPSIS:
  4167.  
  4168.  # double t, stdtr();
  4169.  short k;
  4170.  
  4171.  $y = stdtr( $k, $t );
  4172.  
  4173.  DESCRIPTION:
  4174.  
  4175.  Computes the integral from minus infinity to t of the Student
  4176.  t distribution with integer k > 0 degrees of freedom:
  4177.  
  4178.                                       t
  4179.                                       -
  4180.                                      | |
  4181.               -                      |         2   -(k+1)/2
  4182.              | ( (k+1)/2 )           |  (     x   )
  4183.        ----------------------        |  ( 1 + --- )        dx
  4184.                      -               |  (      k  )
  4185.        sqrt( k pi ) | ( k/2 )        |
  4186.                                    | |
  4187.                                     -
  4188.                                    -inf.
  4189.  
  4190.  Relation to incomplete beta integral:
  4191.  
  4192.         1 - stdtr(k,t) = 0.5 * incbet( k/2, 1/2, z )
  4193.  where
  4194.         z = k/(k + t**2).
  4195.  
  4196.  For t < -2, this is the method of computation.  For higher t,
  4197.  a direct method is derived from integration by parts.
  4198.  Since the function is symmetric about t=0, the area under the
  4199.  right tail of the density is found by calling the function
  4200.  with -t instead of t.
  4201.  
  4202.  ACCURACY:
  4203.  
  4204.  Tested at random 1 <= k <= 25.  The "domain" refers to t.
  4205.                       Relative error:
  4206.  arithmetic   domain     # trials      peak         rms
  4207.     IEEE     -100,-2      50000       5.9e-15     1.4e-15
  4208.     IEEE     -2,100      500000       2.7e-15     4.9e-17
  4209.  
  4210. =item I<stdtri>: Functional inverse of Student's t distribution
  4211.  
  4212.  SYNOPSIS:
  4213.  
  4214.  # double p, t, stdtri();
  4215.  # int k;
  4216.  
  4217.  $t = stdtri( $k, $p );
  4218.  
  4219.  DESCRIPTION:
  4220.  
  4221.  Given probability p, finds the argument t such that stdtr(k,t)
  4222.  is equal to p.
  4223.  
  4224.  ACCURACY:
  4225.  
  4226.  Tested at random 1 <= k <= 100.  The "domain" refers to p:
  4227.                       Relative error:
  4228.  arithmetic   domain     # trials      peak         rms
  4229.     IEEE    .001,.999     25000       5.7e-15     8.0e-16
  4230.     IEEE    10^-6,.001    25000       2.0e-12     2.9e-14
  4231.  
  4232. =item I<struve>: Struve function
  4233.  
  4234.  SYNOPSIS:
  4235.  
  4236.  # double v, x, y, struve();
  4237.  
  4238.  $y = struve( $v, $x );
  4239.  
  4240.  DESCRIPTION:
  4241.  
  4242.  Computes the Struve function Hv(x) of order v, argument x.
  4243.  Negative x is rejected unless v is an integer.
  4244.  
  4245.  ACCURACY:
  4246.  
  4247.  Not accurately characterized, but spot checked against tables.
  4248.  
  4249. =item I<plancki>: Integral of Planck's black body radiation formula
  4250.  
  4251.  SYNOPSIS:
  4252.  
  4253.  # double lambda, T, y, plancki()
  4254.  
  4255.  $y = plancki( $lambda, $T );
  4256.  
  4257.  DESCRIPTION:
  4258.  
  4259.  Evaluates the definite integral, from wavelength 0 to lambda,
  4260.  of Planck's radiation formula
  4261.                        -5
  4262.              c1  lambda
  4263.       E =  ------------------
  4264.              c2/(lambda T)
  4265.             e             - 1
  4266.  
  4267.  Physical constants c1 = 3.7417749e-16 and c2 = 0.01438769 are built in
  4268.  to the function program.  They are scaled to provide a result
  4269.  in watts per square meter.  Argument T represents temperature in degrees
  4270.  Kelvin; lambda is wavelength in meters.
  4271.  
  4272.  The integral is expressed in closed form, in terms of polylogarithms
  4273.  (see polylog.c).
  4274.  
  4275.  The total area under the curve is
  4276.       (-1/8) (42 zeta(4) - 12 pi^2 zeta(2) + pi^4 ) c1 (T/c2)^4
  4277.        = (pi^4 / 15)  c1 (T/c2)^4
  4278.        =  5.6705032e-8 T^4
  4279.  where sigma = 5.6705032e-8 W m^2 K^-4 is the Stefan-Boltzmann constant.
  4280.  
  4281.  
  4282.  ACCURACY:
  4283.  
  4284.  The left tail of the function experiences some relative error
  4285.  amplification in computing the dominant term exp(-c2/(lambda T)).
  4286.  For the right-hand tail see planckc, below.
  4287.  
  4288.                       Relative error.
  4289.    The domain refers to lambda T / c2.
  4290.  arithmetic   domain     # trials      peak         rms
  4291.     IEEE      0.1, 10      50000      7.1e-15     5.4e-16
  4292.  
  4293. =item I<polylog>: polylogarithm function
  4294.  SYNOPSIS:
  4295.  
  4296.  # double x, y, polylog();
  4297.  # int n;
  4298.  
  4299.      $y = polylog( $n, $x );
  4300.  
  4301.  The polylogarithm of order n is defined by the series
  4302.  
  4303.                inf   k
  4304.                 -   x
  4305.    Li (x)  =    >   ---  .
  4306.      n          -     n
  4307.                k=1   k
  4308.  
  4309.    For x = 1,
  4310.  
  4311.                 inf
  4312.                  -    1
  4313.     Li (1)  =    >   ---   =  Riemann zeta function (n)  .
  4314.       n          -     n
  4315.                 k=1   k
  4316.  
  4317.   When n = 2, the function is the dilogarithm, related to Spence's integral:
  4318.  
  4319.                   x                      1-x
  4320.                   -                        -
  4321.                  | |  -ln(1-t)            | |  ln t
  4322.     Li (x)  =    |    -------- dt    =    |    ------ dt    =   spence(1-x) .
  4323.       2        | |       t              | |    1 - t
  4324.                 -                        -
  4325.                  0                        1
  4326.  
  4327.   ACCURACY:
  4328.  
  4329.                        Relative error:
  4330.   arithmetic   domain   n   # trials      peak         rms
  4331.      IEEE      0, 1     2     50000      6.2e-16     8.0e-17
  4332.      IEEE      0, 1     3    100000      2.5e-16     6.6e-17
  4333.      IEEE      0, 1     4     30000      1.7e-16     4.9e-17
  4334.      IEEE      0, 1     5     30000      5.1e-16     7.8e-17
  4335.  
  4336. =item I<bernum>: Bernoulli numbers
  4337.  
  4338.  SYNOPSIS:
  4339.  
  4340.     ($num, $den) = bernum( $n);
  4341.     ($num_array, $den_array) = bernum();
  4342.  
  4343.  DESCRIPTION:
  4344.  
  4345.  This calculates the Bernoulli numbers, up to 30th order.
  4346.  If called with an integer argument, the numerator and denominator
  4347.  of that Bernoulli number is returned; if called with no argument,
  4348.  two array references representing the numerator and denominators
  4349.  of the first 30 Bernoulli numbers are returned.
  4350.  
  4351. =item I<simpson>: Simpson's rule to find an integral
  4352.  
  4353.  SYNOPSIS:
  4354.  
  4355.     $result = simpson(\&fun, $a, $b, $abs_err, $rel_err, $nmax);
  4356.     
  4357.     sub fun {
  4358.        my $x = shift;
  4359.        return cos($x)*exp($x);
  4360.     }
  4361.  
  4362.  DESCRIPTION:
  4363.  
  4364.  This evaluates the area under the graph of a function,
  4365.  represented in a subroutine, from $a to $b, using an 8-point
  4366.  Newton-Cotes formula. The routine divides up the interval into
  4367.  equal segments, evaluates the integral, then compares that
  4368.  to the result with double the number of segments. If the two
  4369.  results agree, to within an absolute error $abs_err or a
  4370.  relative error $rel_err, the result is returned; otherwise,
  4371.  the number of segments is doubled again, and the results 
  4372.  compared. This continues until the desired accuracy is attained,
  4373.  or until the maximum number of iterations $nmax is reached.
  4374.  
  4375. =item I<vecang>: angle between two vectors
  4376.  
  4377.  SYNOPSIS:
  4378.  
  4379.  # double p[3], q[3], vecang();
  4380.  
  4381.     $y = vecang( $p, $q );
  4382.  
  4383.  DESCRIPTION:
  4384.  
  4385.  For two vectors p, q, the angle A between them is given by
  4386.  
  4387.       p.q / (|p| |q|)  = cos A  .
  4388.  
  4389.  where "." represents inner product, "|x|" the length of vector x.
  4390.  If the angle is small, an expression in sin A is preferred.
  4391.  Set r = q - p.  Then
  4392.  
  4393.      p.q = p.p + p.r ,
  4394.  
  4395.      |p|^2 = p.p ,
  4396.  
  4397.      |q|^2 = p.p + 2 p.r + r.r ,
  4398.  
  4399.                   p.p^2 + 2 p.p p.r + p.r^2
  4400.      cos^2 A  =  ----------------------------
  4401.                     p.p (p.p + 2 p.r + r.r)
  4402.  
  4403.                   p.p + 2 p.r + p.r^2 / p.p
  4404.               =  --------------------------- ,
  4405.                      p.p + 2 p.r + r.r
  4406.  
  4407.      sin^2 A  =  1 - cos^2 A
  4408.  
  4409.                    r.r - p.r^2 / p.p
  4410.               =  --------------------
  4411.                   p.p + 2 p.r + r.r
  4412.  
  4413.               =   (r.r - p.r^2 / p.p) / q.q  .
  4414.  
  4415.  ACCURACY:
  4416.  
  4417.                       Relative error:
  4418.  arithmetic   domain     # trials      peak         rms
  4419.     IEEE      -1, 1        10^6       1.7e-16     4.2e-17
  4420.  
  4421.  
  4422. =item I<onef2>: Hypergeometric function 1F2
  4423.  
  4424.  SYNOPSIS:
  4425.  
  4426.  # double a, b, c, x, value;
  4427.  
  4428.  # double *err;
  4429.  
  4430.  ($value, $err) = onef2( $a, $b, $c, $x)
  4431.  
  4432.  ACCURACY:
  4433.  
  4434.  Not accurately characterized, but spot checked against tables.
  4435.  
  4436. =item I<threef0>: Hypergeometric function 3F0
  4437.  
  4438.  SYNOPSIS:
  4439.  
  4440.  # double a, b, c, x, value;
  4441.  
  4442.  # double *err;
  4443.  
  4444.  ($value, $err) = threef0( $a, $b, $c, $x )
  4445.  
  4446.  ACCURACY:
  4447.  
  4448.  Not accurately characterized, but spot checked against tables.
  4449.  
  4450. =item I<yv>: Bessel function Yv with noninteger v
  4451.  
  4452.  SYNOPSIS:
  4453.  
  4454.  # double v, x;
  4455.  
  4456.  # double yv( v, x );
  4457.  
  4458.  $y = yv( $v, $x );
  4459.  
  4460.  ACCURACY:
  4461.  
  4462.  Not accurately characterized, but spot checked against tables.
  4463.  
  4464. =item I<tan>: Circular tangent
  4465.  
  4466.  SYNOPSIS:
  4467.  
  4468.  # double x, y, tan();
  4469.  
  4470.  $y = tan( $x );
  4471.  
  4472.  DESCRIPTION:
  4473.  
  4474.  Returns the circular tangent of the radian argument x.
  4475.  
  4476.  Range reduction is modulo pi/4.  A rational function
  4477.        x + x**3 P(x**2)/Q(x**2)
  4478.  is employed in the basic interval [0, pi/4].
  4479.  
  4480.  ACCURACY:
  4481.  
  4482.                       Relative error:
  4483.  arithmetic   domain     # trials      peak         rms
  4484.     DEC      +-1.07e9      44000      4.1e-17     1.0e-17
  4485.     IEEE     +-1.07e9      30000      2.9e-16     8.1e-17
  4486.  
  4487.  ERROR MESSAGES:
  4488.  
  4489.    message         condition          value returned
  4490.  tan total loss   x > 1.073741824e9     0.0
  4491.  
  4492. =item I<cot>: Circular cotangent
  4493.  
  4494.  SYNOPSIS:
  4495.  
  4496.  # double x, y, cot();
  4497.  
  4498.  $y = cot( $x );
  4499.  
  4500.  DESCRIPTION:
  4501.  
  4502.  Returns the circular cotangent of the radian argument x.
  4503.  
  4504.  Range reduction is modulo pi/4.  A rational function
  4505.        x + x**3 P(x**2)/Q(x**2)
  4506.  is employed in the basic interval [0, pi/4].
  4507.  
  4508.  ACCURACY:
  4509.  
  4510.                       Relative error:
  4511.  arithmetic   domain     # trials      peak         rms
  4512.     IEEE     +-1.07e9      30000      2.9e-16     8.2e-17
  4513.  
  4514.  ERROR MESSAGES:
  4515.  
  4516.    message         condition          value returned
  4517.  cot total loss   x > 1.073741824e9       0.0
  4518.  cot singularity  x = 0                  INFINITY
  4519.  
  4520. =item I<tandg>: Circular tangent of argument in degrees
  4521.  
  4522.  SYNOPSIS:
  4523.  
  4524.  # double x, y, tandg();
  4525.  
  4526.  $y = tandg( $x );
  4527.  
  4528.  DESCRIPTION:
  4529.  
  4530.  Returns the circular tangent of the argument x in degrees.
  4531.  
  4532.  Range reduction is modulo pi/4.  A rational function
  4533.        x + x**3 P(x**2)/Q(x**2)
  4534.  is employed in the basic interval [0, pi/4].
  4535.  
  4536.  ACCURACY:
  4537.  
  4538.                       Relative error:
  4539.  arithmetic   domain     # trials      peak         rms
  4540.     DEC      0,10          8000      3.4e-17      1.2e-17
  4541.     IEEE     0,10         30000      3.2e-16      8.4e-17
  4542.  
  4543.  ERROR MESSAGES:
  4544.  
  4545.    message         condition          value returned
  4546.  tandg total loss   x > 8.0e14 (DEC)      0.0
  4547.                     x > 1.0e14 (IEEE)
  4548.  tandg singularity  x = 180 k  +  90     MAXNUM
  4549.  
  4550. =item I<cotdg>: Circular cotangent of argument in degrees
  4551.  
  4552.  SYNOPSIS:
  4553.  
  4554.  # double x, y, cotdg();
  4555.  
  4556.  $y = cotdg( $x );
  4557.  
  4558.  DESCRIPTION:
  4559.  
  4560.  Returns the circular cotangent of the argument x in degrees.
  4561.  
  4562.  Range reduction is modulo pi/4.  A rational function
  4563.        x + x**3 P(x**2)/Q(x**2)
  4564.  is employed in the basic interval [0, pi/4].
  4565.  
  4566.  ERROR MESSAGES:
  4567.  
  4568.    message         condition          value returned
  4569.  cotdg total loss   x > 8.0e14 (DEC)      0.0
  4570.                     x > 1.0e14 (IEEE)
  4571.  cotdg singularity  x = 180 k            MAXNUM
  4572.  
  4573. =item I<tanh>: Hyperbolic tangent
  4574.  
  4575.  SYNOPSIS:
  4576.  
  4577.  # double x, y, tanh();
  4578.  
  4579.  $y = tanh( $x );
  4580.  
  4581.  DESCRIPTION:
  4582.  
  4583.  Returns hyperbolic tangent of argument in the range MINLOG to
  4584.  MAXLOG.
  4585.  
  4586.  A rational function is used for |x| < 0.625.  The form
  4587.  x + x**3 P(x)/Q(x) of Cody _& Waite is employed.
  4588.  Otherwise,
  4589.     tanh(x) = sinh(x)/cosh(x) = 1  -  2/(exp(2x) + 1).
  4590.  
  4591.  ACCURACY:
  4592.  
  4593.                       Relative error:
  4594.  arithmetic   domain     # trials      peak         rms
  4595.     DEC       -2,2        50000       3.3e-17     6.4e-18
  4596.     IEEE      -2,2        30000       2.5e-16     5.8e-17
  4597.  
  4598. =item I<unity>: Relative error approximations for function arguments near unity.
  4599.  
  4600.  SYNOPSIS:
  4601.  
  4602. #    log1p(x) = log(1+x)
  4603.     
  4604.  $y = log1p( $x );
  4605.  
  4606. #    expm1(x) = exp(x) - 1
  4607.  
  4608.  $y = expm1( $x );
  4609.  
  4610. #    cosm1(x) = cos(x) - 1
  4611.  
  4612.  $y = cosm1( $x );
  4613.  
  4614. =item I<yn>: Bessel function of second kind of integer order
  4615.  
  4616.  SYNOPSIS:
  4617.  
  4618.  # double x, y, yn();
  4619.  # int n;
  4620.  
  4621.  $y = yn( $n, $x );
  4622.  
  4623.  DESCRIPTION:
  4624.  
  4625.  Returns Bessel function of order n, where n is a
  4626.  (possibly negative) integer.
  4627.  
  4628.  The function is evaluated by forward recurrence on
  4629.  n, starting with values computed by the routines
  4630.  y0() and y1().
  4631.  
  4632.  If n = 0 or 1 the routine for y0 or y1 is called
  4633.  directly.
  4634.  
  4635.  ACCURACY:
  4636.  
  4637.                       Absolute error, except relative
  4638.                       when y > 1:
  4639.  arithmetic   domain     # trials      peak         rms
  4640.     DEC       0, 30        2200       2.9e-16     5.3e-17
  4641.     IEEE      0, 30       30000       3.4e-15     4.3e-16
  4642.  
  4643.  ERROR MESSAGES:
  4644.  
  4645.    message         condition      value returned
  4646.  yn singularity   x = 0              MAXNUM
  4647.  yn overflow                         MAXNUM
  4648.  
  4649.  Spot checked against tables for x, n between 0 and 100.
  4650.  
  4651. =item I<zeta>: Riemann zeta function of two arguments
  4652.  
  4653.  SYNOPSIS:
  4654.  
  4655.  # double x, q, y, zeta();
  4656.  
  4657.  $y = zeta( $x, $q );
  4658.  
  4659.  DESCRIPTION:
  4660.  
  4661.                  inf.
  4662.                   -        -x
  4663.    zeta(x,q)  =   >   (k+q)  
  4664.                   -
  4665.                  k=0
  4666.  
  4667.  where x > 1 and q is not a negative integer or zero.
  4668.  The Euler-Maclaurin summation formula is used to obtain
  4669.  the expansion
  4670.  
  4671.                 n         
  4672.                 -       -x
  4673.  zeta(x,q)  =   >  (k+q)  
  4674.                 -         
  4675.                k=1        
  4676.  
  4677.            1-x                 inf.  B   x(x+1)...(x+2j)
  4678.       (n+q)           1         -     2j
  4679.   +  ---------  -  -------  +   >    --------------------
  4680.         x-1              x      -                   x+2j+1
  4681.                    2(n+q)      j=1       (2j)! (n+q)
  4682.  
  4683.  where the B2j are Bernoulli numbers.  Note that (see zetac.c)
  4684.  zeta(x,1) = zetac(x) + 1.
  4685.  
  4686.  ACCURACY:
  4687.  
  4688.  REFERENCE:
  4689.  
  4690.  Gradshteyn, I. S., and I. M. Ryzhik, Tables of Integrals,
  4691.  Series, and Products, p. 1073; Academic Press, 1980.
  4692.  
  4693. =item I<zetac>: Riemann zeta function
  4694.  
  4695.  SYNOPSIS:
  4696.  
  4697.  # double x, y, zetac();
  4698.  
  4699.  $y = zetac( $x );
  4700.  
  4701.  DESCRIPTION:
  4702.  
  4703.                 inf.
  4704.                  -    -x
  4705.    zetac(x)  =   >   k   ,   x > 1,
  4706.                  -
  4707.                 k=2
  4708.  
  4709.  is related to the Riemann zeta function by
  4710.  
  4711.     Riemann zeta(x) = zetac(x) + 1.
  4712.  
  4713.  Extension of the function definition for x < 1 is implemented.
  4714.  Zero is returned for x > log2(MAXNUM).
  4715.  
  4716.  An overflow error may occur for large negative x, due to the
  4717.  gamma function in the reflection formula.
  4718.  
  4719.  ACCURACY:
  4720.  
  4721.  Tabulated values have full machine accuracy.
  4722.  
  4723.                       Relative error:
  4724.  arithmetic   domain     # trials      peak         rms
  4725.     IEEE      1,50        10000       9.8e-16        1.3e-16
  4726.     DEC       1,50         2000       1.1e-16     1.9e-17
  4727.  
  4728. =back
  4729.  
  4730. =head1 TODO
  4731.  
  4732. =over 4
  4733.  
  4734. =item * Make the configuration of mconf.h automatic.
  4735.  
  4736. =item * Include the rest of the routines in the cephes library, such as
  4737.  polynomial and matrix manipulation functions; this will involve
  4738.  writing typemaps for arrays.
  4739.  
  4740. =back
  4741.  
  4742. =head1 BUGS
  4743.  
  4744.  Please report any to Randy Kobes <randy@theoryx5.uwinnipeg.ca>
  4745.  
  4746. =head1 SEE ALSO
  4747.  
  4748. For interfaces to programs which can do symbolic manipulation,
  4749. see L<PDL>, L<Math::Pari>, and L<Math::ematica>.
  4750. For a command line interface to the routines of I<Math::Cephes>,
  4751. see the included C<pmath> script. For a
  4752. different interface to the fraction and complex number routines,
  4753. see L<Math::Cephes::Fraction> and L<Math::Cephes::Complex>.
  4754. For an interface to some polynomial routines, see
  4755. L<Math::Cephes::Polynomial>, and for some matrix routines,
  4756. see L<Math::Cephes::Matrix>.
  4757.  
  4758. =head1 COPYRIGHT
  4759.  
  4760. The C code for the Cephes Math Library is
  4761. Copyright 1984, 1987, 1989, 2002 by Stephen L. Moshier, 
  4762. and is available at http://www.netlib.org/cephes/.
  4763. Direct inquiries to 30 Frost Street, Cambridge, MA 02140.
  4764.  
  4765. The file arrays.c included here to handle passing arrays
  4766. into and out of C routines comes from the PGPLOT module
  4767. of Karl Glazebrook <kgb@zzoepp.aao.gov.au>.
  4768.  
  4769. The perl interface is copyright 2000, 2002 by Randy Kobes.
  4770. This library is free software; you can redistribute it and/or
  4771. modify it under the same terms as Perl itself.
  4772.  
  4773. =cut
  4774.  
  4775.  
  4776.