|
Location : Home > Languages > Perl > Package Title : Math::Cephes |
![]() |
Math::Cephes - Cephes math library へのインタフェース
use Math::Cephes qw(:all);
use Math::Cephes qw(sin cos);
関数のインポートグループで定義されたエクスポートタグを使うこともできる。
use Math::Cephes qw(:constants);
| $PI: | 3.14159265358979323846 | # pi |
| $PIO2: | 1.57079632679489661923 | # pi/2 |
| $PIO4: | 0.785398163397448309616 | # pi/4 |
| $SQRT2: | 1.41421356237309504880 | # sqrt(2) |
| $SQRTH: | 0.707106781186547524401 | # sqrt(2)/2 |
| $LOG2E: | 1.4426950408889634073599 | # 1/log(2) |
| $SQ2OPI: | 0.79788456080286535587989 | # sqrt( 2/pi ) |
| $LOGE2: | 0.693147180559945309417 | # log(2) |
| $LOGSQ2: | 0.346573590279972654709 | # log(2)/2 |
| $THPIO4: | 2.35619449019234492885 | # 3*pi/4 |
| $TWOOPI: | 0.636619772367581343075535 | # 2/pi |
同様に4つのマシン依存の数も利用可能である。
| $MACHEP : | マシンの丸め誤差 |
| $MAXLOG : | マシンの最大対数 |
| $MINLOG : | マシンの最小対数 |
| $MAXNUM : | 表示可能な最大数 |
をインポートする。
use Math::Cephes qw(:trigs);
| acos: | アークコサイン |
| asin: | アークサイン |
| atan: | アークタンジェント |
| atan2: | 4象限アークタンジェント |
| cos: | コサイン |
| cosdg: | コサイン(度) |
| cot: | コタンジェント |
| cotdg: | コタンジェント(度) |
| hypot: | 直角三角形の斜辺 |
| radian: | 度をラジアンに変換 |
| sin: | サイン |
| sindg: | サイン(度) |
| tan: | タンジェント |
| tandg: | タンジェント(度) |
| cosm1: | 単位付近の関数引数に対する相対誤差 |
をインポートする。
use Math::Cephes qw(:hypers);
| acosh: | 逆ハイパボリックコサイン |
| asinh: | 逆ハイパボリックサイン |
| atanh: | 逆ハイパボリックタンジェント |
| cosh: | ハイパボリックコサイン |
| sinh: | ハイパボリックサイン |
| tanh: | ハイパボリックタンジェント |
をインポートする。
use Math::Cephes qw(:explog);
| exp: | 指数関数 |
| expxx: | exp(x*x) |
| exp10: | 基が 10 の指数関数 |
| exp2: | 基が 2 の指数関数 |
| log: | 自然対数 |
| log10: | 常用対数 |
| log2: | 基が 2 の対数 |
| log1p,expm1: | Relative error approximations for function arguments near unity. |
をインポートする。
use Math::Cephes qw(:cmplx);
| new_cmplx: | create a new complex number object |
| cabs: | Complex absolute value |
| cacos: | Complex circular arc cosine |
| cacosh: | Complex inverse hyperbolic cosine |
| casin: | Complex circular arc sine |
| casinh: | Complex inverse hyperbolic sine |
| catan: | Complex circular arc tangent |
| catanh: | Complex inverse hyperbolic tangent |
| ccos: | Complex circular cosine |
| ccosh: | Complex hyperbolic cosine |
| ccot: | Complex circular cotangent |
| cexp: | Complex exponential function |
| clog: | Complex natural logarithm |
| cadd: | add two complex numbers |
| csub: | subtract two complex numbers |
| cmul: | multiply two complex numbers |
| cdiv: | divide two complex numbers |
| cmov: | copy one complex number to another |
| cneg: | negate a complex number |
| cpow: | Complex power function |
| csin: | Complex circular sine |
| csinh: | Complex hyperbolic sine |
| csqrt: | Complex square root |
| ctan: | Complex circular tangent |
| ctanh: | Complex hyperbolic tangent |
をインポートする。
use Math::Cephes qw(:utils);
| cbrt: | 立方根 |
| ceil: | ceil |
| drand: | Pseudorandom number generator |
| fabs: | Absolute value |
| fac: | Factorial function |
| floor: | floor |
| frexp: | frexp |
| ldexp: | multiplies x by 2**n. |
| lrand: | Pseudorandom number generator |
| lsqrt: | Integer square root |
| pow: | Power function |
| powi: | Real raised to integer power |
| round: | Round double to nearest or even integer valued double |
| sqrt: | 平方根 |
をインポートする。
use Math::Cephes qw(:bessels);
| i0: | 修正ベッセル関数 of order zero |
| i0e: | 修正ベッセル関数 of order zero, exponentially scaled |
| i1: | 修正ベッセル関数 of order one |
| i1e: | 修正ベッセル関数 of order one, exponentially scaled |
| iv: | 修正ベッセル関数 of noninteger order |
| j0: | ベッセル関数 of order zero |
| j1: | ベッセル関数 of order one |
| jn: | ベッセル関数 of integer order |
| jv: | ベッセル関数 of noninteger order |
| k0: | 修正ベッセル関数, third kind, order zero |
| k0e: | 修正ベッセル関数, third kind, order zero, exponentially scaled |
| k1: | 修正ベッセル関数, third kind, order one |
| k1e: | 修正ベッセル関数, third kind, order one, exponentially scaled |
| kn: | 修正ベッセル関数, third kind, integer order |
| y0: | ベッセル関数 of the second kind, order zero |
| y1: | ベッセル関数 of second kind of order one |
| yn: | ベッセル関数 of second kind of integer order |
| yv: | ベッセル関数 Yv with noninteger v |
をインポートする。
use Math::Cephes qw(:dists);
| bdtr: | 二項分布 |
| bdtrc: | Complemented binomial 分布 |
| bdtri: | Inverse binomial 分布 |
| btdtr: | Beta 分布 |
| chdtr: | Chi-square 分布 |
| chdtrc: | Complemented Chi-square 分布 |
| chdtri: | Inverse of complemented Chi-square 分布 |
| fdtr: | F 分布 |
| fdtrc: | Complemented F 分布 |
| fdtri: | Inverse of complemented F 分布 |
| gdtr: | Gamma 分布 function |
| gdtrc: | Complemented gamma 分布 function |
| nbdtr: | Negative binomial 分布 |
| nbdtrc: | Complemented negative binomial 分布 |
| nbdtri: | Functional inverse of negative binomial 分布 |
| ndtr: | Normal 分布 function |
| ndtri: | Inverse of Normal 分布 function |
| pdtr: | Poisson 分布 |
| pdtrc: | Complemented poisson 分布 |
| pdtri: | Inverse Poisson 分布 |
| stdtr: | Student's t 分布 |
| stdtri: | Functional inverse of Student's t 分布 |
をインポートする。
use Math::Cephes qw(:gammas);
| fac: | 階乗 |
| gamma: | ガンマ関数 |
| igam: | 不完全ガンマ積分 |
| igamc: | Complemented 不完全ガンマ積分 |
| igami: | Inverse of complemented 不完全ガンマ積分 |
| psi: | Psi (digamma) function |
| rgamma: | Reciprocal ガンマ関数 |
をインポートする。
use Math::Cephes qw(:betas);
| beta: | ベータ関数 |
| incbet: | 不完全ベータ積分 |
| incbi: | 不完全ベータ積分の逆関数 |
| lbeta: | |beta| の自然対数 |
をインポートする。
use Math::Cephes qw(:elliptics);
| ellie: | 第2種不完全楕円積分 |
| ellik: | 第1種不完全楕円積分 |
| ellpe: | 第2種完全楕円積分 |
| ellpj: | Jacobian 楕円関数 |
| ellpk: | 第1種完全楕円積分 |
をインポートする。
use Math::Cephes qw(:hypergeometrics);
| hyp2f0: | Gauss 超幾何関数 F |
| hyp2f1: | Gauss 超幾何関数 F |
| hyperg: | Confluent 超幾何関数 |
| onef2: | 超幾何関数 1F2 |
| threef0: | 超幾何関数 3F0 |
をインポートする。
use Math::Cephes qw(:misc);
| airy: | エアリ関数(Airy function) |
| bernum: | ベルヌーイ数 |
| dawsn: | Dawson 積分 |
| ei: | 指数積分 |
| erf: | 誤差関数 |
| erfc: | Complementary error function |
| expn: | 指数積分 En |
| fresnl: | フレネル積分 |
| plancki: | プランクの黒体放射公式の積分 |
| polylog: | Polylogarithm function |
| shichi: | Hyperbolic sine and cosine 積分 |
| sici: | Sine and cosine 積分 |
| simpson: | Simpson's rule to find an 積分 |
| spence: | Dilogarithm |
| struve: | シュトルーベ関数(Struve function) |
| vecang: | angle between two vectors |
| zeta: | Riemann zeta function of two arguments |
| zetac: | リーマンのゼータ関数 |
をインポートする。
use Math::Cephes qw(:fract);
| new_fract: | 新しい fraction オブジェクトを生成 |
| radd: | 2つの分数を足す |
| rmul: | 2つの分数をかける |
| rsub: | 一方の分数から他方の分数を引く |
| rdiv: | 一方の分数を他方の分数で割る |
| euclid: | 最大公約数を求める |
をインポートする。
利用可能な関数の説明は以下のようなものである。
acosh: Inverse hyperbolic cosine
概要
# double x, y, acosh(); $y = acosh( $x );
説明
where z = x-1, is used. Otherwise,sqrt(z) * P(z)/Q(z)
acosh(x) = log( x + sqrt( (x-1)(x+1) ).
精度
Relative error:
arithmetic domain # trials peak rms
DEC 1,3 30000 4.2e-17 1.1e-17
IEEE 1,3 30000 4.6e-16 8.7e-17
エラーメッセージ
message condition value returned acosh domain |x| < 1 NAN
airy: Airy function
概要
# double x, ai, aiprime, bi, biprime; # int airy(); ($flag, $ai, $aiprime, $bi, $biprime) = airy( $x );
説明
y"(x) = xy.
The function returns the two independent solutions Ai, Bi and their first derivatives Ai'(x), Bi'(x).
Evaluation is by power series summation for small x,
by rational minimax approximations for large x.
精度
Arithmetic domain function # trials peak rms IEEE -10, 0 Ai 10000 1.6e-15 2.7e-16 IEEE 0, 10 Ai 10000 2.3e-14* 1.8e-15* IEEE -10, 0 Ai' 10000 4.6e-15 7.6e-16 IEEE 0, 10 Ai' 10000 1.8e-14* 1.5e-15* IEEE -10, 10 Bi 30000 4.2e-15 5.3e-16 IEEE -10, 10 Bi' 30000 4.9e-15 7.3e-16 DEC -10, 0 Ai 5000 1.7e-16 2.8e-17 DEC 0, 10 Ai 5000 2.1e-15* 1.7e-16* DEC -10, 0 Ai' 5000 4.7e-16 7.8e-17 DEC 0, 10 Ai' 12000 1.8e-15* 1.5e-16* DEC -10, 10 Bi 10000 5.5e-16 6.8e-17 DEC -10, 10 Bi' 7000 5.3e-16 8.7e-17
radian: Degrees, minutes, seconds to radians
概要
# double d, m, s, radian(); $r = radian( $d, $m, $s );
説明
hypot: returns the hypotenuse associated with the sides of a right triangle
概要
# double a, b, c, hypot(); $c = hypot( $a, $b );
説明
c = sqrt( a**2 + b**2)
asin: Inverse circular sine
概要
# double x, y, asin(); $y = asin( $x );
説明
asin(x) = pi/2 - 2 asin( sqrt( (1-x)/2 ) ).
精度
Relative error:
arithmetic domain # trials peak rms
DEC -1, 1 40000 2.6e-17 7.1e-18
IEEE -1, 1 10^6 1.9e-16 5.4e-17
エラーメッセージ
message condition value returned asin domain |x| > 1 NAN
acos: Inverse circular cosine
概要
# double x, y, acos(); $y = acos( $x );
説明
or if x > +0.5,acos(x) = pi - 2.0 * asin( sqrt((1+x)/2) );
acos(x) = 2.0 * asin( sqrt((1-x)/2) ).
精度
Relative error:
arithmetic domain # trials peak rms
DEC -1, 1 50000 3.3e-17 8.2e-18
IEEE -1, 1 10^6 2.2e-16 6.5e-17
エラーメッセージ
message condition value returned asin domain |x| > 1 NAN
asinh: Inverse hyperbolic sine
概要
# double x, y, asinh(); $y = asinh( $x );
説明
asinh(x) = log( x + sqrt(1 + x*x) ).
精度
Relative error:
arithmetic domain # trials peak rms
DEC -3,3 75000 4.6e-17 1.1e-17
IEEE -1,1 30000 3.7e-16 7.8e-17
IEEE 1,3 30000 2.5e-16 6.7e-17
atan: Inverse circular tangent (arctangent)
概要
# double x, y, atan(); $y = atan( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10, 10 50000 2.4e-17 8.3e-18
IEEE -10, 10 10^6 1.8e-16 5.0e-17
atan2: Quadrant correct inverse circular tangent
概要
# double x, y, z, atan2(); $z = atan2( $y, $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -10, 10 10^6 2.5e-16 6.9e-17
See atan.c.
atanh: Inverse hyperbolic tangent
概要
# double x, y, atanh(); $y = atanh( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC -1,1 50000 2.4e-17 6.4e-18
IEEE -1,1 30000 1.9e-16 5.2e-17
bdtr: Binomial 分布
概要
# int k, n; # double p, y, bdtr(); $y = bdtr( $k, $n, $p );
説明
The terms are not summed directly; instead the 不完全 beta 積分 is employed, according to the formulak -- ( n ) j n-j > ( ) p (1-p) -- ( j ) j=0
The arguments must be positive, with p ranging from 0 to 1.y = bdtr( k, n, p ) = incbet( n-k, k+1, 1-p ).
精度
a,b Relative error:
arithmetic domain # trials peak rms
For p between 0.001 and 1:
IEEE 0,100 100000 4.3e-15 2.6e-16
See also incbet.c.
エラーメッセージ
message condition value returned
bdtr domain k < 0 0.0
n < k
x < 0, x > 1
bdtrc: Complemented binomial 分布
概要
# int k, n; # double p, y, bdtrc(); $y = bdtrc( $k, $n, $p );
説明
The terms are not summed directly; instead the 不完全 beta 積分 is employed, according to the formulan -- ( n ) j n-j > ( ) p (1-p) -- ( j ) j=k+1
The arguments must be positive, with p ranging from 0 to 1.y = bdtrc( k, n, p ) = incbet( k+1, n-k, p ).
精度
a,b Relative error:
arithmetic domain # trials peak rms
For p between 0.001 and 1:
IEEE 0,100 100000 6.7e-15 8.2e-16
For p between 0 and .001:
IEEE 0,100 100000 1.5e-13 2.7e-15
エラーメッセージ
message condition value returned bdtrc domain x<0, x>1, n
bdtri: Inverse binomial 分布
概要
# int k, n; # double p, y, bdtri(); $p = bdtr( $k, $n, $y );
説明
1 - p = incbi( n-k, k+1, y ).
精度
a,b Relative error:
arithmetic domain # trials peak rms
For p between 0.001 and 1:
IEEE 0,100 100000 2.3e-14 6.4e-16
IEEE 0,10000 100000 6.6e-12 1.2e-13
For p between 10^-6 and 0.001:
IEEE 0,100 100000 2.0e-12 1.3e-14
IEEE 0,10000 100000 1.5e-12 3.2e-14
See also incbi.c.
エラーメッセージ
message condition value returned
bdtri domain k < 0, n <= k 0.0
x < 0, x > 1
beta: Beta function
概要
# double a, b, y, beta(); $y = beta( $a, $b );
説明
- -
| (a) | (b)
beta( a, b ) = -----------.
-
| (a+b)
For large arguments the logarithm of the function is
evaluated using lgam(), then exponentiated.
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0,30 1700 7.7e-15 1.5e-15
IEEE 0,30 30000 8.1e-14 1.1e-14
エラーメッセージ
message condition value returned
beta overflow log(beta) > MAXLOG 0.0
a or b <0 integer 0.0
lbeta: Natural logarithm of |beta|
概要
# double a, b; # double lbeta( a, b ); $y = lbeta( $a, $b);
btdtr: Beta 分布
概要
# double a, b, x, y, btdtr(); $y = btdtr( $a, $b, $x );
説明
x
- -
| (a+b) | | a-1 b-1
P(x) = ---------- | t (1-t) dt
- - | |
| (a) | (b) -
0
This function is identical to the 不完全 beta
積分 function incbet(a, b, x).
The complemented function is
1 - P(1-x) = incbet( b, a, x );
精度
cbrt: Cube root
概要
# double x, y, cbrt(); $y = cbrt( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,10 200000 1.8e-17 6.2e-18
IEEE 0,1e308 30000 1.5e-16 5.0e-17
chdtr: Chi-square 分布
概要
# double v, x, y, chdtr(); $y = chdtr( $v, $x );
説明
inf.
-
1 | | v/2-1 -t/2
P( x | v ) = ----------- | t e dt
v/2 - | |
2 | (v/2) -
x
where x is the Chi-square variable.
The 不完全 gamma 積分 is used, according to the
formula
The arguments must both be positive.y = chdtr( v, x ) = igam( v/2.0, x/2.0 ).
精度
エラーメッセージ
message condition value returned chdtr domain x < 0 or v < 1 0.0
chdtrc: Complemented Chi-square 分布
概要
# double v, x, y, chdtrc(); $y = chdtrc( $v, $x );
説明
inf.
-
1 | | v/2-1 -t/2
P( x | v ) = ----------- | t e dt
v/2 - | |
2 | (v/2) -
x
where x is the Chi-square variable.
The 不完全 gamma 積分 is used, according to the
formula
The arguments must both be positive.y = chdtrc( v, x ) = igamc( v/2.0, x/2.0 ).
精度
エラーメッセージ
message condition value returned chdtrc domain x < 0 or v < 1 0.0
chdtri: Inverse of complemented Chi-square 分布
概要
# double df, x, y, chdtri(); $x = chdtri( $df, $y );
説明
x/2 = igami( df/2, y );
精度
エラーメッセージ
message condition value returned
chdtri domain y < 0 or y > 1 0.0
v < 1
clog: Complex natural logarithm SYNOPSIS:
# void clog();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
clog($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
The arctangent ranges from -PI to +PI.w = log(r) + i arctan(y/x).
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 7000 8.5e-17 1.9e-17
IEEE -10,+10 30000 5.0e-15 1.1e-16
Larger relative error can be observed for z near 1 +i0.
In IEEE arithmetic the peak absolute error is 5.2e-16, rms
absolute error 1.0e-16.
cexp: Complex exponential function
概要
# void cexp();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
cexp($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
thenz = x + iy, r = exp(x),
w = r cos y + i r sin y.
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 8700 3.7e-17 1.1e-17
IEEE -10,+10 30000 3.0e-16 8.7e-17
csin: Complex circular sine
概要
# void csin();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
csin($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
thenz = x + iy,
w = sin x cosh y + i cos x sinh y.
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 8400 5.3e-17 1.3e-17
IEEE -10,+10 30000 3.8e-16 1.0e-16
Also tested by csin(casin(z)) = z.
ccos: Complex circular cosine
概要
# void ccos();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
ccos($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
thenz = x + iy,
w = cos x cosh y - i sin x sinh y.
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 8400 4.5e-17 1.3e-17
IEEE -10,+10 30000 3.8e-16 1.0e-16
ctan: Complex circular tangent
概要
# void ctan();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
ctan($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
thenz = x + iy,
sin 2x + i sinh 2y
w = --------------------.
cos 2x + cosh 2y
On the real axis the denominator is zero at odd multiples
of PI/2. The denominator is evaluated by its Taylor
series near these points.
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 5200 7.1e-17 1.6e-17
IEEE -10,+10 30000 7.2e-16 1.2e-16
Also tested by ctan * ccot = 1 and catan(ctan(z)) = z.
ccot: Complex circular cotangent
概要
# void ccot();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
ccot($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
thenz = x + iy,
sin 2x - i sinh 2y
w = --------------------.
cosh 2y - cos 2x
On the real axis, the denominator has zeros at even
multiples of PI/2. Near these points it is evaluated
by a Taylor series.
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 3000 6.5e-17 1.6e-17
IEEE -10,+10 30000 9.2e-16 1.2e-16
Also tested by ctan * ccot = 1 + i0.
casin: Complex circular arc sine
概要
# void casin();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
casin($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
2
w = -i clog( iz + csqrt( 1 - z ) ).
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 10100 2.1e-15 3.4e-16
IEEE -10,+10 30000 2.2e-14 2.7e-15
Larger relative error can be observed for z near zero.
Also tested by csin(casin(z)) = z.
cacos: Complex circular arc cosine
概要
# void cacos();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
cacos($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
w = arccos z = PI/2 - arcsin z.
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 5200 1.6e-15 2.8e-16
IEEE -10,+10 30000 1.8e-14 2.2e-15
catan: Complex circular arc tangent
概要
# void catan();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
catan($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
thenz = x + iy,
1 ( 2x )
Re w = - arctan(-----------) + k PI
2 ( 2 2)
(1 - x - y )
( 2 2)
1 (x + (y+1) )
Im w = - log(------------)
4 ( 2 2)
(x + (y-1) )
Where k is an arbitrary integer.
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 5900 1.3e-16 7.8e-18
IEEE -10,+10 30000 2.3e-15 8.5e-17
The check catan( ctan(z) ) = z, with |x| and |y| < PI/2,
had peak relative error 1.5e-16, rms relative error
2.9e-17. See also clog().
csinh: Complex hyperbolic sine
概要
# void csinh();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
csinh($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
csinh z = (cexp(z) - cexp(-z))/2
= sinh x * cos y + i cosh x * sin y .
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -10,+10 30000 3.1e-16 8.2e-17
casinh: Complex inverse hyperbolic sine
概要
# void casinh();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
casinh($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
print_new_cmplx($w); # prints $w as Re($w) + i Im($w)
説明
casinh z = -i casin iz .
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -10,+10 30000 1.8e-14 2.6e-15
ccosh: Complex hyperbolic cosine
概要
# void ccosh();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
ccosh($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
ccosh(z) = cosh x cos y + i sinh x sin y .
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -10,+10 30000 2.9e-16 8.1e-17
cacosh: Complex inverse hyperbolic cosine
概要
# void cacosh();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
cacosh($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
acosh z = i acos z .
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -10,+10 30000 1.6e-14 2.1e-15
ctanh: Complex hyperbolic tangent
概要
# void ctanh();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
ctanh($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
tanh z = (sinh 2x + i sin 2y) / (cosh 2x + cos 2y) .
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -10,+10 30000 1.7e-14 2.4e-16
catanh: Complex inverse hyperbolic tangent
概要
# void catanh();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
catanh($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -10,+10 30000 2.3e-16 6.2e-17
cpow: Complex power function
概要
# void cpow();
# cmplx a, z, w;
$a = new_cmplx(5, 6); # $z = 5 + 6 i
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
cpow($a, $z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -10,+10 30000 9.4e-15 1.5e-15
cmplx: Complex number arithmetic
概要
# typedef struct {
# double r; real part
# double i; imaginary part
# }cmplx;
# cmplx *a, *b, *c;
$a = new_cmplx(3, 5); # $a = 3 + 5 i
$b = new_cmplx(2, 3); # $b = 2 + 3 i
$c = new_cmplx();
cadd( $a, $b, $c ); # c = b + a
csub( $a, $b, $c ); # c = b - a
cmul( $a, $b, $c ); # c = b * a
cdiv( $a, $b, $c ); # c = b / a
cneg( $c ); # c = -c
cmov( $b, $c ); # c = b
print $c->{r}, ' ', $c->{i}; # prints real and imaginary parts of $c
説明
c.r = b.r + a.r
c.i = b.i + a.i
Subtraction:
c.r = b.r - a.r
c.i = b.i - a.i
Multiplication:
c.r = b.r * a.r - b.i * a.i
c.i = b.r * a.i + b.i * a.r
Division:
d = a.r * a.r + a.i * a.i
c.r = (b.r * a.r + b.i * a.i)/d
c.i = (b.i * a.r - b.r * a.i)/d
精度
Relative error:
arithmetic function # trials peak rms
DEC cadd 10000 1.4e-17 3.4e-18
IEEE cadd 100000 1.1e-16 2.7e-17
DEC csub 10000 1.4e-17 4.5e-18
IEEE csub 100000 1.1e-16 3.4e-17
DEC cmul 3000 2.3e-17 8.7e-18
IEEE cmul 100000 2.1e-16 6.9e-17
DEC cdiv 18000 4.9e-17 1.3e-17
IEEE cdiv 100000 3.7e-16 1.1e-16
cabs: Complex absolute value
概要
# double a, cabs(); # cmplx z; $z = new_cmplx(2, 3); # $z = 2 + 3 i $a = cabs( $z );
説明
Overflow and underflow are avoided by testing the magnitudes of x and y before squaring. If either is outside half of the floating point full scale range, both are rescaled.a = sqrt( x**2 + y**2 ).
精度
Relative error:
arithmetic domain # trials peak rms
DEC -30,+30 30000 3.2e-17 9.2e-18
IEEE -10,+10 100000 2.7e-16 6.9e-17
csqrt: Complex square root
概要
# void csqrt();
# cmplx z, w;
$z = new_cmplx(2, 3); # $z = 2 + 3 i
$w = new_cmplx();
csqrt($z, $w );
print $w->{r}, ' ', $w->{i}; # prints real and imaginary parts of $w
説明
1/2
Im w = [ (r - x)/2 ] ,
Re w = y / 2 Im w.
Note that -w is also a square root of z. The root chosen
is always in the upper half plane.
Because of the potential for cancellation error in r - x,
the result is sharpened by doing a Heron iteration
(see sqrt.c) in complex arithmetic.
精度
Relative error:
arithmetic domain # trials peak rms
DEC -10,+10 25000 3.2e-17 9.6e-18
IEEE -10,+10 100000 3.2e-16 7.7e-17
2
Also tested by csqrt( z ) = z, and tested by arguments
close to the real axis.
machconst: Globally declared constants
概要
説明
For IEEE arithmetic (IBMPC):MACHEP = 1.38777878078144567553E-17 2**-56 MAXLOG = 8.8029691931113054295988E1 log(2**127) MINLOG = -8.872283911167299960540E1 log(2**-128) MAXNUM = 1.701411834604692317316873e38 2**127
These lists are subject to change.MACHEP = 1.11022302462515654042E-16 2**-53 MAXLOG = 7.09782712893383996843E2 log(2**1024) MINLOG = -7.08396418532264106224E2 log(2**-1022) MAXNUM = 1.7976931348623158E308 2**1024
cosh: Hyperbolic cosine
概要
# double x, y, cosh(); $y = cosh( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC +- 88 50000 4.0e-17 7.7e-18
IEEE +-MAXLOG 30000 2.6e-16 5.7e-17
エラーメッセージ
message condition value returned cosh overflow |x| > MAXLOG MAXNUM
dawsn: Dawson's 積分
概要
# double x, y, dawsn(); $y = dawsn( $x );
説明
x
-
2 | | 2
dawsn(x) = exp( -x ) | exp( t ) dt
| |
-
0
Three different rational approximations are employed, for
the intervals 0 to 3.25; 3.25 to 6.25; and 6.25 up.
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0,10 10000 6.9e-16 1.0e-16
DEC 0,10 6000 7.4e-17 1.4e-17
drand: Pseudorandom number generator
概要
# double y, drand(); ($flag, $y) = drand( );
説明
ellie: 不完全 elliptic 積分 of the second kind
概要
# double phi, m, y, ellie(); $y = ellie( $phi, $m );
説明
phi
-
| |
| 2
E(phi_\m) = | sqrt( 1 - m sin t ) dt
|
| |
-
0
of amplitude phi and modulus m, using the arithmetic -
geometric mean algorithm.
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0,2 2000 1.9e-16 3.4e-17
IEEE -10,10 150000 3.3e-15 1.4e-16
ellik: 不完全 elliptic 積分 of the first kind
概要
# double phi, m, y, ellik(); $y = ellik( $phi, $m );
説明
phi
-
| |
| dt
F(phi_\m) = | ------------------
| 2
| | sqrt( 1 - m sin t )
-
0
of amplitude phi and modulus m, using the arithmetic -
geometric mean algorithm.
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -10,10 200000 7.4e-16 1.0e-16
ellpe: Complete elliptic 積分 of the second kind
概要
# double m1, y, ellpe(); $y = ellpe( $m1 );
説明
pi/2
-
| | 2
E(m) = | sqrt( 1 - m sin t ) dt
| |
-
0
Where m = 1 - m1, using the approximation
Though there are no singularities, the argument m1 is used rather than m for compatibility with ellpk().P(x) - x log x Q(x).
E(1) = 1; E(0) = pi/2.
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0, 1 13000 3.1e-17 9.4e-18
IEEE 0, 1 10000 2.1e-16 7.3e-17
エラーメッセージ
message condition value returned ellpe domain x<0, x>1 0.0
ellpj: Jacobian Elliptic Functions
概要
# double u, m, sn, cn, dn, phi; # int ellpj(); ($flag, $sn, $cn, $dn, $phi) = ellpj( $u, $m );
説明
精度
Absolute error (* = relative error):
arithmetic function # trials peak rms
DEC sn 1800 4.5e-16 8.7e-17
IEEE phi 10000 9.2e-16* 1.4e-16*
IEEE sn 50000 4.1e-15 4.6e-16
IEEE cn 40000 3.6e-15 4.4e-16
IEEE dn 10000 1.3e-12 1.8e-14
Peak error observed in consistency check using addition
theorem for sn(u+v) was 4e-16 (absolute). Also tested by
the above relation to the 不完全 elliptic 積分.
Accuracy deteriorates when u is large.
ellpk: Complete elliptic 積分 of the first kind
概要
# double m1, y, ellpk(); $y = ellpk( $m1 );
説明
pi/2
-
| |
| dt
K(m) = | ------------------
| 2
| | sqrt( 1 - m sin t )
-
0
where m = 1 - m1, using the approximation
The argument m1 is used rather than m so that the logarithmic singularity at m = 1 will be shifted to the origin; this preserves maximum accuracy.P(x) - log x Q(x).
K(0) = pi/2.
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0,1 16000 3.5e-17 1.1e-17
IEEE 0,1 30000 2.5e-16 6.8e-17
エラーメッセージ
message condition value returned ellpk domain x<0, x>1 0.0
euclid: Rational arithmetic routines
概要
# typedef struct
# {
# double n; numerator
# double d; denominator
# }fract;
$a = new_fract(3, 4); # a = 3 / 4
$b = new_fract(2, 3); # b = 2 / 3
$c = new_fract();
radd( $a, $b, $c ); # c = b + a
rsub( $a, $b, $c ); # c = b - a
rmul( $a, $b, $c ); # c = b * a
rdiv( $a, $b, $c ); # c = b / a
print $c->{n}, ' ', $c->{d}; # prints numerator and denominator of $c
($gcd, $m_reduced, $n_reduced) = euclid($m, $n);
# returns the greatest common divisor of $m and $n, as well as
# the result of reducing $m and $n by $gcd
Arguments of the routines are pointers to the structures.
The double precision numbers are assumed, without checking,
to be integer valued. Overflow conditions are reported.
exp: Exponential function
概要
# double x, y, exp(); $y = exp( $x );
説明
x k f
e = 2 e.
A Pade' form 1 + 2x P(x**2)/( Q(x**2) - P(x**2) )
of degree 2/3 is used to approximate exp(f) in the basic
interval [-0.5, 0.5].
精度
Relative error:
arithmetic domain # trials peak rms
DEC +- 88 50000 2.8e-17 7.0e-18
IEEE +- 708 40000 2.0e-16 5.6e-17
Error amplification in the exponential function can be
a serious matter. The error propagation involves
exp( X(1+delta) ) = exp(X) ( 1 + X*delta + ... ),
which shows that a 1 lsb error in representing X produces
a relative error of X times 1 lsb in the function.
While the routine gives an accurate result for arguments
that are exactly represented by a double precision
computer number, the result contains amplified roundoff
error for large arguments not exactly represented.
エラーメッセージ
message condition value returned exp underflow x < MINLOG 0.0 exp overflow x > MAXLOG INFINITY
expxx: exp(x*x)
# double x, y, expxx(); # int sign; $y = expxx( $x, $sign );
説明
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -26.6, 26.6 10^7 3.9e-16 8.9e-17
exp10: Base 10 exponential function (Common antilogarithm)
概要
# double x, y, exp10(); $y = exp10( $x );
説明
is used to approximate 10**f.1 + 2x P(x**2)/( Q(x**2) - P(x**2) )
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -307,+307 30000 2.2e-16 5.5e-17
Test result from an earlier version (2.1):
DEC -38,+38 70000 3.1e-17 7.0e-18
エラーメッセージ
DEC arithmetic: MAXL10 = 38.230809449325611792. IEEE arithmetic: MAXL10 = 308.2547155599167.message condition value returned exp10 underflow x < -MAXL10 0.0 exp10 overflow x > MAXL10 MAXNUM
exp2: Base 2 exponential function
概要
# double x, y, exp2(); $y = exp2( $x );
説明
approximates 2**x in the basic range [-0.5, 0.5].1 + 2x P(x**2) / (Q(x**2) - x P(x**2) )
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -1022,+1024 30000 1.8e-16 5.4e-17
See exp.c for comments on error amplification.
エラーメッセージ
For DEC arithmetic, MAXL2 = 127. For IEEE arithmetic, MAXL2 = 1024.message condition value returned exp underflow x < -MAXL2 0.0 exp overflow x > MAXL2 MAXNUM
ei: Exponential 積分
概要
#double x, y, ei(); $y = ei( $x );
説明
x
- t
| | e
Ei(x) = -|- --- dt .
| | t
-
-inf
Not defined for x <= 0.
See also expn.c.
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0,100 50000 8.6e-16 1.3e-16
expn: Exponential 積分 En
概要
# int n; # double x, y, expn(); $y = expn( $n, $x );
説明
inf.
-
| | -xt
| e
E (x) = | ---- dt.
n | n
| | t
-
1
Both n and x must be nonnegative.
The routine employs either a power series, a continued
fraction, or an asymptotic formula depending on the
relative values of n and x.
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0, 30 5000 2.0e-16 4.6e-17
IEEE 0, 30 10000 1.7e-15 3.6e-16
fabs: Absolute value
概要
# double x, y; $y = fabs( $x );
説明
fac: Factorial function
概要
# double y, fac(); # int i; $y = fac( $i );
説明
精度
Relative error:
arithmetic domain peak
IEEE 0, 170 1.4e-15
DEC 0, 33 1.4e-17
fdtr: F 分布
概要
# int df1, df2; # double x, y, fdtr(); $y = fdtr( $df1, $df2, $x );
説明
The arguments a and b are greater than zero, and x is nonnegative.P(x) = incbet( df1/2, df2/2, df1*x/(df2 + df1*x) ).
精度
x a,b Relative error:
arithmetic domain domain # trials peak rms
IEEE 0,1 0,100 100000 9.8e-15 1.7e-15
IEEE 1,5 0,100 100000 6.5e-15 3.5e-16
IEEE 0,1 1,10000 100000 2.2e-11 3.3e-12
IEEE 1,5 1,10000 100000 1.1e-11 1.7e-13
See also incbet.c.
エラーメッセージ
message condition value returned fdtr domain a<0, b<0, x<0 0.0
fdtrc: Complemented F 分布
概要
# int df1, df2; # double x, y, fdtrc(); $y = fdtrc( $df1, $df2, $x );
説明
inf.
-
1 | | a-1 b-1
1-P(x) = ------ | t (1-t) dt
B(a,b) | |
-
x
The 不完全 beta 積分 is used, according to the
formula
P(x) = incbet( df2/2, df1/2, df2/(df2 + df1*x) ).
精度
x a,b Relative error:
arithmetic domain domain # trials peak rms
IEEE 0,1 1,100 100000 3.7e-14 5.9e-16
IEEE 1,5 1,100 100000 8.0e-15 1.6e-15
IEEE 0,1 1,10000 100000 1.8e-11 3.5e-13
IEEE 1,5 1,10000 100000 2.0e-11 3.0e-12
See also incbet.c.
エラーメッセージ
message condition value returned fdtrc domain a<0, b<0, x<0 0.0
fdtri: Inverse of complemented F 分布
概要
# int df1, df2; # double x, p, fdtri(); $x = fdtri( $df1, $df2, $p );
説明
Note: the following relations hold for the inverse of the uncomplemented F 分布:z = incbi( df2/2, df1/2, p ) x = df2 (1-z) / (df1 z).
z = incbi( df1/2, df2/2, p ) x = df2 z / (df1 (1-z)).
精度
a,b Relative error:
arithmetic domain # trials peak rms
For p between .001 and 1:
IEEE 1,100 100000 8.3e-15 4.7e-16
IEEE 1,10000 100000 2.1e-11 1.4e-13
For p between 10^-6 and 10^-3:
IEEE 1,100 50000 1.3e-12 8.4e-15
IEEE 1,10000 50000 3.0e-12 4.8e-14
See also fdtrc.c.
エラーメッセージ
message condition value returned
fdtri domain p <= 0 or p > 1 0.0
v < 1
ceil: ceil
概要
# double x, y, ceil(); $y = ceil( $x );
floor: floor
概要
# double x, y, floor(); $y = floor( $x );
frexp: frexp
概要
# double x, y, frexp(); # int expnt; ($y, $expnt) = frexp( $x );
ldexp: multiplies x by 2**n.
概要
# double x, y, ldexp(); # int n; $y = ldexp( $x, $n );
fresnl: Fresnel 積分
概要
# double x, S, C; # void fresnl(); ($flag, $S, $C) = fresnl( $x );
説明
x
-
| |
C(x) = | cos(pi/2 t**2) dt,
| |
-
0
x
-
| |
S(x) = | sin(pi/2 t**2) dt.
| |
-
0
The 積分s are evaluated by a power series for x < 1.
For x >= 1 auxiliary functions f(x) and g(x) are employed
such that
C(x) = 0.5 + f(x) sin( pi/2 x**2 ) - g(x) cos( pi/2 x**2 ) S(x) = 0.5 - f(x) cos( pi/2 x**2 ) - g(x) sin( pi/2 x**2 )
精度
Arithmetic function domain # trials peak rms IEEE S(x) 0, 10 10000 2.0e-15 3.2e-16 IEEE C(x) 0, 10 10000 1.8e-15 3.3e-16 DEC S(x) 0, 10 6000 2.2e-16 3.9e-17 DEC C(x) 0, 10 5000 2.3e-16 3.9e-17
gamma: Gamma function
概要
# double x, y, gamma(); # extern int sgngam; $y = gamma( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC -34, 34 10000 1.3e-16 2.5e-17
IEEE -170,-33 20000 2.3e-15 3.3e-16
IEEE -33, 33 20000 9.4e-16 2.2e-16
IEEE 33, 171.6 20000 2.3e-15 3.2e-16
Error for arguments outside the test range will be larger
owing to error amplification by the exponential function.
lgam: Natural logarithm of gamma function
概要
# double x, y, lgam(); # extern int sgngam; $y = lgam( $x );
説明
精度
arithmetic domain # trials peak rms
DEC 0, 3 7000 5.2e-17 1.3e-17
DEC 2.718, 2.035e36 5000 3.9e-17 9.9e-18
IEEE 0, 3 28000 5.4e-16 1.1e-16
IEEE 2.718, 2.556e305 40000 3.5e-16 8.3e-17
The error criterion was relative when the function magnitude
was greater than one but absolute when it was less than one.
The following test used the relative error criterion, though
at certain points the relative error could be much higher than
indicated.
IEEE -200, -4 10000 4.8e-16 1.3e-16
gdtr: Gamma 分布 function
概要
# double a, b, x, y, gdtr(); $y = gdtr( $a, $b, $x );
説明
x
b -
a | | b-1 -at
y = ----- | t e dt
- | |
| (b) -
0
The 不完全 gamma 積分 is used, according to the
relation
y = igam( b, ax ).
精度
エラーメッセージ
message condition value returned gdtr domain x < 0 0.0
gdtrc: Complemented gamma 分布 function
概要
# double a, b, x, y, gdtrc(); $y = gdtrc( $a, $b, $x );
説明
inf.
b -
a | | b-1 -at
y = ----- | t e dt
- | |
| (b) -
x
The 不完全 gamma 積分 is used, according to the
relation
y = igamc( b, ax ).
精度
エラーメッセージ
message condition value returned gdtrc domain x < 0 0.0
hyp2f0: Gauss hypergeometric function 2F0
概要
# double a, b, x, value, *err; # int type; /* determines what converging factor to use */ ($value, $err) = hyp2f0( $a, $b, $x, $type )
hyp2f1: Gauss hypergeometric function 2F1
概要
# double a, b, c, x, y, hyp2f1(); $y = hyp2f1( $a, $b, $c, $x );
説明
hyp2f1( a, b, c, x ) = F ( a, b; c; x )
2 1
inf.
- a(a+1)...(a+k) b(b+1)...(b+k) k+1
= 1 + > ----------------------------- x .
- c(c+1)...(c+k) (k+1)!
k = 0
Cases addressed are
Tests and escapes for negative integer a, b, or c
Linear transformation if c - a or c - b negative integer
Special case c = a or c = b
Linear transformation for x near +1
Transformation for x < -0.5
Psi function expansion if x > 0.5 and c - a - b integer
Conditionally, a recurrence on c to make c-a-b > 0
|x| > 1 is rejected.
The parameters a, b, c are considered to be integer
valued if they are within 1.0e-14 of the nearest integer
(1.0e-13 for IEEE arithmetic).
精度
Relative error (-1 < x < 1):
arithmetic domain # trials peak rms
IEEE -1,7 230000 1.2e-11 5.2e-14
Several special cases also tested with a, b, c in
the range -7 to 7.
エラーメッセージ
hyperg: Confluent hypergeometric function
概要
# double a, b, x, y, hyperg(); $y = hyperg( $a, $b, $x );
説明
1 2
a x a(a+1) x
F ( a,b;x ) = 1 + ---- + --------- + ...
1 1 b 1! b(b+1) 2!
Many higher transcendental functions are special cases of
this power series.
As is evident from the formula, b must not be a negative
integer or zero unless a is an integer with 0 >= a > b.
The routine attempts both a direct summation of the series
and an asymptotic expansion. In each case error due to
roundoff, cancellation, and nonconvergence is estimated.
The result with smaller estimated error is returned.
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0,30 2000 1.2e-15 1.3e-16
IEEE 0,30 30000 1.8e-14 1.1e-15
Larger errors can be observed when b is near a negative
integer or zero. Certain combinations of arguments yield
serious cancellation error in the power series summation
and also are not in the region of near convergence of the
asymptotic series. An error message is printed if the
self-estimated relative error is greater than 1.0e-12.
i0: Modified ベッセル関数 of order zero
概要
# double x, y, i0(); $y = i0( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0,30 6000 8.2e-17 1.9e-17
IEEE 0,30 30000 5.8e-16 1.4e-16
i0e: Modified ベッセル関数 of order zero, exponentially scaled
概要
# double x, y, i0e(); $y = i0e( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0,30 30000 5.4e-16 1.2e-16
See i0().
i1: Modified ベッセル関数 of order one
概要
# double x, y, i1(); $y = i1( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0, 30 3400 1.2e-16 2.3e-17
IEEE 0, 30 30000 1.9e-15 2.1e-16
i1e: Modified ベッセル関数 of order one, exponentially scaled
概要
# double x, y, i1e(); $y = i1e( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0, 30 30000 2.0e-15 2.0e-16
See i1().
igam: 不完全 gamma 積分
概要
# double a, x, y, igam(); $y = igam( $a, $x );
説明
x
-
1 | | -t a-1
igam(a,x) = ----- | e t dt.
- | |
| (a) -
0
In this implementation both arguments must be positive.
The 積分 is evaluated by either a power series or
continued fraction expansion, depending on the relative
values of a and x.
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0,30 200000 3.6e-14 2.9e-15
IEEE 0,100 300000 9.9e-14 1.5e-14
igamc: Complemented 不完全 gamma 積分
概要
# double a, x, y, igamc(); $y = igamc( $a, $x );
説明
igamc(a,x) = 1 - igam(a,x)
inf.
-
1 | | -t a-1
= ----- | e t dt.
- | |
| (a) -
x
In this implementation both arguments must be positive.
The 積分 is evaluated by either a power series or
continued fraction expansion, depending on the relative
values of a and x.
精度
a x Relative error:
arithmetic domain domain # trials peak rms
IEEE 0.5,100 0,100 200000 1.9e-14 1.7e-15
IEEE 0.01,0.5 0,100 200000 1.4e-13 1.6e-15
igami: Inverse of complemented imcomplete gamma 積分
概要
# double a, x, p, igami(); $x = igami( $a, $p );
説明
Starting with the approximate valueigamc( a, x ) = p.
3
x = a t
where
andt = 1 - d - ndtri(p) sqrt(d)
the routine performs up to 10 Newton iterations to find the root of igamc(a,x) - p = 0.d = 1/9a,
精度
a p Relative error:
arithmetic domain domain # trials peak rms
IEEE 0.5,100 0,0.5 100000 1.0e-14 1.7e-15
IEEE 0.01,0.5 0,0.5 100000 9.0e-14 3.4e-15
IEEE 0.5,10000 0,0.5 20000 2.3e-13 3.8e-14
incbet: 不完全 beta 積分
概要
# double a, b, x, y, incbet(); $y = incbet( $a, $b, $x );
説明
x
- -
| (a+b) | | a-1 b-1
----------- | t (1-t) dt.
- - | |
| (a) | (b) -
0
The domain of definition is 0 <= x <= 1. In this
implementation a and b are restricted to positive values.
The 積分 from x to 1 may be obtained by the symmetry
relation
The 積分 is evaluated by a continued fraction expansion or, when b*x is small, by a power series.1 - incbet( a, b, x ) = incbet( b, a, 1-x ).
精度
Relative error
arithmetic domain # trials peak rms
IEEE 0,5 10000 6.9e-15 4.5e-16
IEEE 0,85 250000 2.2e-13 1.7e-14
IEEE 0,1000 30000 5.3e-12 6.3e-13
IEEE 0,10000 250000 9.3e-11 7.1e-12
IEEE 0,100000 10000 8.7e-10 4.8e-11
Outputs smaller than the IEEE gradual underflow threshold
were excluded from these statistics.
エラーメッセージ
message condition value returned incbet domain x<0, x>1 0.0 incbet underflow 0.0
incbi: Inverse of imcomplete beta 積分
概要
# double a, b, x, y, incbi(); $x = incbi( $a, $b, $y );
説明
The routine performs interval halving or Newton iterations to find the root of incbet(a,b,x) - y = 0.incbet( a, b, x ) = y .
精度
Relative error:
x a,b
arithmetic domain domain # trials peak rms
IEEE 0,1 .5,10000 50000 5.8e-12 1.3e-13
IEEE 0,1 .25,100 100000 1.8e-13 3.9e-15
IEEE 0,1 0,5 50000 1.1e-12 5.5e-15
VAX 0,1 .5,100 25000 3.5e-14 1.1e-15
With a and b constrained to half-integer or integer values:
IEEE 0,1 .5,10000 50000 5.8e-12 1.1e-13
IEEE 0,1 .5,100 100000 1.7e-14 7.9e-16
With a = .5, b constrained to half-integer or integer values:
IEEE 0,1 .5,10000 10000 8.3e-11 1.0e-11
iv: Modified ベッセル関数 of noninteger order
概要
# double v, x, y, iv(); $y = iv( $v, $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0,30 2000 3.1e-15 5.4e-16
IEEE 0,30 10000 1.7e-14 2.7e-15
Accuracy is diminished if v is near a negative integer.
See also hyperg.c.
j0: ベッセル関数 of order zero
概要
# double x, y, j0(); $y = j0( $x );
説明
2 2
(w - r ) (w - r ) P (w) / Q (w)
1 2 3 8
2
where w = x and the two r's are zeros of the function.
In the second interval, the Hankel asymptotic expansion
is employed with two rational functions of degree 6/6
and 7/7.
精度
Absolute error:
arithmetic domain # trials peak rms
DEC 0, 30 10000 4.4e-17 6.3e-18
IEEE 0, 30 60000 4.2e-16 1.1e-16
y0: ベッセル関数 of the second kind, order zero
概要
# double x, y, y0(); $y = y0( $x );
説明
Thus a call to j0() is required. In the second interval, the Hankel asymptotic expansion is employed with two rational functions of degree 6/6 and 7/7.y0(x) = R(x) + 2 * log(x) * j0(x) / PI.
精度
arithmetic domain # trials peak rms
DEC 0, 30 9400 7.0e-17 7.9e-18
IEEE 0, 30 30000 1.3e-15 1.6e-16
j1: ベッセル関数 of order one
概要
# double x, y, j1(); $y = j1( $x );
説明
精度
Absolute error:
arithmetic domain # trials peak rms
DEC 0, 30 10000 4.0e-17 1.1e-17
IEEE 0, 30 30000 2.6e-16 1.1e-16
y1: ベッセル関数 of second kind of order one
概要
# double x, y, y1(); $y = y1( $x );
説明
精度
Absolute error:
arithmetic domain # trials peak rms
DEC 0, 30 10000 8.6e-17 1.3e-17
IEEE 0, 30 30000 1.0e-15 1.3e-16
(error criterion relative when |y1| > 1).
jn: ベッセル関数 of integer order
概要
# int n; # double x, y, jn(); $y = jn( $n, $x );
説明
精度
Absolute error:
arithmetic range # trials peak rms
DEC 0, 30 5500 6.9e-17 9.3e-18
IEEE 0, 30 5000 4.4e-16 7.9e-17
Not suitable for large n or x. Use jv() instead.
jv: ベッセル関数 of noninteger order
概要
# double v, x, y, jv(); $y = jv( $v, $x );
説明
精度
arithmetic v domain x domain # trials peak rms
IEEE 0,125 0,125 100000 4.6e-15 2.2e-16
IEEE -125,0 0,125 40000 5.4e-11 3.7e-13
IEEE 0,500 0,500 20000 4.4e-15 4.0e-16
Integer v:
IEEE -125,125 -125,125 50000 3.5e-15* 1.9e-16*
k0: Modified ベッセル関数, third kind, order zero
概要
# double x, y, k0(); $y = k0( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0, 30 3100 1.3e-16 2.1e-17
IEEE 0, 30 30000 1.2e-15 1.6e-16
エラーメッセージ
message condition value returned K0 domain x <= 0 MAXNUM
k0e: Modified ベッセル関数, third kind, order zero, exponentially scaled
概要
# double x, y, k0e(); $y = k0e( $x );
説明
k0e(x) = exp(x) * k0(x).
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0, 30 30000 1.4e-15 1.4e-16
See k0().
k1: Modified ベッセル関数, third kind, order one
概要
# double x, y, k1(); $y = k1( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0, 30 3300 8.9e-17 2.2e-17
IEEE 0, 30 30000 1.2e-15 1.6e-16
エラーメッセージ
message condition value returned k1 domain x <= 0 MAXNUM
k1e: Modified ベッセル関数, third kind, order one, exponentially scaled
概要
# double x, y, k1e(); $y = k1e( $x );
説明
k1e(x) = exp(x) * k1(x).
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0, 30 30000 7.8e-16 1.2e-16
See k1().
kn: Modified ベッセル関数, third kind, integer order
概要
# double x, y, kn(); # int n; $y = kn( $n, $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0,30 3000 1.3e-9 5.8e-11
IEEE 0,30 90000 1.8e-8 3.0e-10
Error is high only near the crossover point x = 9.55
between the two expansions used.
log: Natural logarithm
概要
# double x, y, log(); $y = log( $x );
説明
Otherwise, setting z = 2(x-1)/x+1),log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
log(x) = z + z**3 P(z)/Q(z).
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0.5, 2.0 150000 1.44e-16 5.06e-17
IEEE +-MAXNUM 30000 1.20e-16 4.78e-17
DEC 0, 10 170000 1.8e-17 6.3e-18
In the tests over the interval [+-MAXNUM], the logarithms
of the random arguments were uniformly distributed over
[0, MAXLOG].
エラーメッセージ
log singularity: x = 0; returns -INFINITY log domain: x < 0; returns NAN
log10: Common logarithm
概要
# double x, y, log10(); $y = log10( $x );
説明
log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0.5, 2.0 30000 1.5e-16 5.0e-17
IEEE 0, MAXNUM 30000 1.4e-16 4.8e-17
DEC 1, MAXNUM 50000 2.5e-17 6.0e-18
In the tests over the interval [1, MAXNUM], the logarithms
of the random arguments were uniformly distributed over
[0, MAXLOG].
エラーメッセージ
log10 singularity: x = 0; returns -INFINITY log10 domain: x < 0; returns NAN
log2: Base 2 logarithm
概要
# double x, y, log2(); $y = log2( $x );
説明
Otherwise, setting z = 2(x-1)/x+1), log(x) = z + z**3 P(z)/Q(z).log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0.5, 2.0 30000 2.0e-16 5.5e-17
IEEE exp(+-700) 40000 1.3e-16 4.6e-17
In the tests over the interval [exp(+-700)], the logarithms
of the random arguments were uniformly distributed.
エラーメッセージ
log2 singularity: x = 0; returns -INFINITY log2 domain: x < 0; returns NAN
lrand: Pseudorandom number generator
概要
long y, lrand(); $y = lrand( );
説明
lsqrt: Integer square root
概要
long x, y; long lsqrt(); $y = lsqrt( $x );
説明
精度
mtherr: Library common error handling routine
概要
char *fctnam; # int code; # int mtherr(); mtherr( $fctnam, $code );
説明
Mnemonic Value Significance
DOMAIN 1 argument domain error
SING 2 function singularity
OVERFLOW 3 overflow range error
UNDERFLOW 4 underflow range error
TLOSS 5 total loss of precision
PLOSS 6 partial loss of precision
EDOM 33 Unix domain error code
ERANGE 34 Unix range error code
The default version of the file prints the function name,
passed to it by the pointer fctnam, followed by the
error condition. The display is directed to the standard
output device. The routine then returns to the calling
program. Users may wish to modify the program to abort by
calling exit() under severe error conditions such as domain
errors.
Since all error conditions pass control to this function,
the display may be easily changed, eliminated, or directed
to an error logging device.
SEE ALSO: mconf.h
nbdtr: Negative binomial 分布
概要
# int k, n; # double p, y, nbdtr(); $y = nbdtr( $k, $n, $p );
説明
In a sequence of Bernoulli trials, this is the probability that k or fewer failures precede the nth success. The terms are not computed individually; instead the 不完全 beta 積分 is employed, according to the formulak -- ( n+j-1 ) n j > ( ) p (1-p) -- ( j ) j=0
The arguments must be positive, with p ranging from 0 to 1.y = nbdtr( k, n, p ) = incbet( n, k+1, p ).
精度
a,b Relative error:
arithmetic domain # trials peak rms
IEEE 0,100 100000 1.7e-13 8.8e-15
See also incbet.c.
nbdtrc: Complemented negative binomial 分布
概要
# int k, n; # double p, y, nbdtrc(); $y = nbdtrc( $k, $n, $p );
説明
The terms are not computed individually; instead the 不完全 beta 積分 is employed, according to the formulainf -- ( n+j-1 ) n j > ( ) p (1-p) -- ( j ) j=k+1
The arguments must be positive, with p ranging from 0 to 1.y = nbdtrc( k, n, p ) = incbet( k+1, n, 1-p ).
精度
a,b Relative error:
arithmetic domain # trials peak rms
IEEE 0,100 100000 1.7e-13 8.8e-15
See also incbet.c.
nbdtrc: Complemented negative binomial 分布
概要
# int k, n; # double p, y, nbdtrc(); $y = nbdtrc( $k, $n, $p );
説明
The terms are not computed individually; instead the 不完全 beta 積分 is employed, according to the formulainf -- ( n+j-1 ) n j > ( ) p (1-p) -- ( j ) j=k+1
The arguments must be positive, with p ranging from 0 to 1.y = nbdtrc( k, n, p ) = incbet( k+1, n, 1-p ).
精度
nbdtri: Functional inverse of negative binomial 分布
概要
# int k, n; # double p, y, nbdtri(); $p = nbdtri( $k, $n, $y );
説明
精度
a,b Relative error:
arithmetic domain # trials peak rms
IEEE 0,100 100000 1.5e-14 8.5e-16
See also incbi.c.
ndtr: Normal 分布 function
概要
# double x, y, ndtr(); $y = ndtr( $x );
説明
x
-
1 | | 2
ndtr(x) = --------- | exp( - t /2 ) dt
sqrt(2pi) | |
-
-inf.
= ( 1 + erf(z) ) / 2
where z = x/sqrt(2). Computation is via the functions
erf and erfc.
精度
エラーメッセージ
message condition value returned erfc underflow x > 37.519379347 0.0
erf: Error function
概要
# double x, y, erf(); $y = erf( $x );
説明
x
-
2 | | 2
erf(x) = -------- | exp( - t ) dt.
sqrt(pi) | |
-
0
The magnitude of x is limited to 9.231948545 for DEC
arithmetic; 1 or -1 is returned outside this range.
For 0 <= |x| < 1, erf(x) = x * P4(x**2)/Q5(x**2); otherwise
erf(x) = 1 - erfc(x).
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0,1 14000 4.7e-17 1.5e-17
IEEE 0,1 30000 3.7e-16 1.0e-16
erfc: Complementary error function
概要
説明
1 - erf(x) =
inf.
-
2 | | 2
erfc(x) = -------- | exp( - t ) dt
sqrt(pi) | |
-
x
For small x, erfc(x) = 1 - erf(x); otherwise rational
approximations are computed.
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0, 9.2319 12000 5.1e-16 1.2e-16
IEEE 0,26.6417 30000 5.7e-14 1.5e-14
エラーメッセージ
message condition value returned erfc underflow x > 9.231948545 (DEC) 0.0
ndtri: Inverse of Normal 分布 function
概要
# double x, y, ndtri(); $x = ndtri( $y );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0.125, 1 5500 9.5e-17 2.1e-17
DEC 6e-39, 0.135 3500 5.7e-17 1.3e-17
IEEE 0.125, 1 20000 7.2e-16 1.3e-16
IEEE 3e-308, 0.135 50000 4.6e-16 9.8e-17
エラーメッセージ
message condition value returned ndtri domain x <= 0 -MAXNUM ndtri domain x >= 1 MAXNUM
pdtr: Poisson 分布
概要
# int k; # double m, y, pdtr(); $y = pdtr( $k, $m );
説明
The terms are not summed directly; instead the 不完全 gamma 積分 is employed, according to the relationk j -- -m m > e -- -- j! j=0
The arguments must both be positive.y = pdtr( k, m ) = igamc( k+1, m ).
精度
pdtrc: Complemented poisson 分布
概要
# int k; # double m, y, pdtrc(); $y = pdtrc( $k, $m );
説明
The terms are not summed directly; instead the 不完全 gamma 積分 is employed, according to the formulainf. j -- -m m > e -- -- j! j=k+1
The arguments must both be positive.y = pdtrc( k, m ) = igam( k+1, m ).
精度
pdtri: Inverse Poisson 分布
概要
# int k; # double m, y, pdtr(); $m = pdtri( $k, $y );
説明
m = igami( k+1, y ).
精度
エラーメッセージ
message condition value returned
pdtri domain y < 0 or y >= 1 0.0
k < 0
pow: Power function
概要
# double x, y, z, pow(); $z = pow( $x, $y );
説明
Following Cody and Waite, this program uses a lookup table of 2**-i/16 and pseudo extended precision arithmetic to obtain an extra three bits of accuracy in both the logarithm and the exponential.x**y = exp( y log(x) ).
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -26,26 30000 4.2e-16 7.7e-17
DEC -26,26 60000 4.8e-17 9.1e-18
1/26 < x < 26, with log(x) uniformly distributed.
-26 < y < 26, y uniformly distributed.
IEEE 0,8700 30000 1.5e-14 2.1e-15
0.99 < x < 1.01, 0 < y < 8700, uniformly distributed.
エラーメッセージ
message condition value returned pow overflow x**y > MAXNUM INFINITY pow underflow x**y < 1/MAXNUM 0.0 pow domain x<0 and y noninteger 0.0
powi: Real raised to integer power
概要
# double x, y, powi(); # int n; $y = powi( $x, $n );
説明
精度
Relative error:
arithmetic x domain n domain # trials peak rms
DEC .04,26 -26,26 100000 2.7e-16 4.3e-17
IEEE .04,26 -26,26 50000 2.0e-15 3.8e-16
IEEE 1,2 -1022,1023 50000 8.6e-14 1.6e-14
Returns MAXNUM on overflow, zero on underflow.
psi: Psi (digamma) function
概要
# double x, y, psi(); $y = psi( $x );
説明
d -
psi(x) = -- ln | (x)
dx
is the logarithmic derivative of the gamma function.
For integer x,
n-1
-
psi(n) = -EUL + > 1/k.
-
k=1
This formula is used for 0 < n <= 10. If x is negative, it
is transformed to a positive argument by the reflection
formula psi(1-x) = psi(x) + pi cot(pi x).
For general positive x, the argument is made greater than 10
using the recurrence psi(x+1) = psi(x) + 1/x.
Then the following asymptotic expansion is applied:
inf. B
- 2k
psi(x) = log(x) - 1/2x - > -------
- 2k
k=1 2k x
where the B2k are Bernoulli numbers.
精度
arithmetic domain # trials peak rms
DEC 0,30 2500 1.7e-16 2.0e-17
IEEE 0,30 30000 1.3e-15 1.4e-16
IEEE -30,0 40000 1.5e-15 2.2e-16
エラーメッセージ
message condition value returned
psi singularity x integer <=0 MAXNUM
rgamma: Reciprocal gamma function
概要
# double x, y, rgamma(); $y = rgamma( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC -30,+30 4000 1.2e-16 1.8e-17
IEEE -30,+30 30000 1.1e-15 2.0e-16
For arguments less than -34.034 the peak error is on the
order of 5e-15 (DEC), excepting overflow or underflow.
round: Round double to nearest or even integer valued double
概要
# double x, y, round(); $y = round( $x );
説明
精度
shichi: Hyperbolic sine and cosine 積分s
概要
# double x, Chi, Shi, shichi(); ($flag, $Shi, $Chi) = shichi( $x );
説明
x
-
| | cosh t - 1
Chi(x) = eul + ln x + | ----------- dt,
| | t
-
0
x
-
| | sinh t
Shi(x) = | ------ dt
| | t
-
0
where eul = 0.57721566490153286061 is Euler's constant.
The 積分s are evaluated by power series for x < 8
and by Chebyshev expansions for x between 8 and 88.
For large x, both functions approach exp(x)/2x.
Arguments greater than 88 in magnitude return MAXNUM.
精度
Relative error:
arithmetic function # trials peak rms
DEC Shi 3000 9.1e-17
IEEE Shi 30000 6.9e-16 1.6e-16
Absolute error, except relative when |Chi| > 1:
DEC Chi 2500 9.3e-17
IEEE Chi 30000 8.4e-16 1.4e-16
sici: Sine and cosine 積分s
概要
# double x, Ci, Si, sici(); ($flag, $Si, $Ci) = sici( $x );
説明
x
-
| cos t - 1
Ci(x) = eul + ln x + | --------- dt,
| t
-
0
x
-
| sin t
Si(x) = | ----- dt
| t
-
0
where eul = 0.57721566490153286061 is Euler's constant.
The 積分s are approximated by rational functions.
For x > 8 auxiliary functions f(x) and g(x) are employed
such that
Ci(x) = f(x) sin(x) - g(x) cos(x) Si(x) = pi/2 - f(x) cos(x) - g(x) sin(x)
精度
Absolute error, except relative when > 1:Test interval = [0,50].
arithmetic function # trials peak rms
IEEE Si 30000 4.4e-16 7.3e-17
IEEE Ci 30000 6.9e-16 5.1e-17
DEC Si 5000 4.4e-17 9.0e-18
DEC Ci 5300 7.9e-17 5.2e-18
sin: Circular sine
概要
# double x, y, sin(); $y = sin( $x );
説明
Between pi/4 and pi/2 the cosine is represented asx + x**3 P(x**2).
1 - x**2 Q(x**2).
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0, 10 150000 3.0e-17 7.8e-18
IEEE -1.07e9,+1.07e9 130000 2.1e-16 5.4e-17
エラーメッセージ
Partial loss of accuracy begins to occur at x = 2**30 = 1.074e9. The loss is not gradual, but jumps suddenly to about 1 part in 10e7. Results may be meaningless for x > 2**49 = 5.6e14. The routine as implemented flags a TLOSS error for x > 2**30 and returns 0.0.message condition value returned sin total loss x > 1.073741824e9 0.0
cos: Circular cosine
概要
# double x, y, cos(); $y = cos( $x );
説明
Between pi/4 and pi/2 the sine is represented as1 - x**2 Q(x**2).
x + x**3 P(x**2).
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -1.07e9,+1.07e9 130000 2.1e-16 5.4e-17
DEC 0,+1.07e9 17000 3.0e-17 7.2e-18
sindg: Circular sine of angle in degrees
概要
# double x, y, sindg(); $y = sindg( $x );
説明
Between pi/4 and pi/2 the cosine is represented asx + x**3 P(x**2).
1 - x**2 P(x**2).
精度
Relative error:
arithmetic domain # trials peak rms
DEC +-1000 3100 3.3e-17 9.0e-18
IEEE +-1000 30000 2.3e-16 5.6e-17
エラーメッセージ
message condition value returned
sindg total loss x > 8.0e14 (DEC) 0.0
x > 1.0e14 (IEEE)
cosdg: Circular cosine of angle in degrees
概要
# double x, y, cosdg(); $y = cosdg( $x );
説明
Between pi/4 and pi/2 the sine is represented as1 - x**2 P(x**2).
x + x**3 P(x**2).
精度
Relative error:
arithmetic domain # trials peak rms
DEC +-1000 3400 3.5e-17 9.1e-18
IEEE +-1000 30000 2.1e-16 5.7e-17
See also sin().
sinh: Hyperbolic sine
概要
# double x, y, sinh(); $y = sinh( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC +- 88 50000 4.0e-17 7.7e-18
IEEE +-MAXLOG 30000 2.6e-16 5.7e-17
spence: Dilogarithm
概要
# double x, y, spence(); $y = spence( $x );
説明
x
-
| | log t
spence(x) = - | ----- dt
| | t - 1
-
1
for x >= 0. A rational approximation gives the 積分 in
the interval (0.5, 1.5). Transformation formulas for 1/x
and 1-x are employed outside the basic expansion range.
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 0,4 30000 3.9e-15 5.4e-16
DEC 0,4 3000 2.5e-16 4.5e-17
sqrt: Square root
概要
# double x, y, sqrt(); $y = sqrt( $x );
説明
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0, 10 60000 2.1e-17 7.9e-18
IEEE 0,1.7e308 30000 1.7e-16 6.3e-17
エラーメッセージ
message condition value returned sqrt domain x < 0 0.0
stdtr: Student's t 分布
概要
# double t, stdtr(); short k; $y = stdtr( $k, $t );
説明
t
-
| |
- | 2 -(k+1)/2
| ( (k+1)/2 ) | ( x )
---------------------- | ( 1 + --- ) dx
- | ( k )
sqrt( k pi ) | ( k/2 ) |
| |
-
-inf.
Relation to 不完全 beta 積分:
where1 - stdtr(k,t) = 0.5 * incbet( k/2, 1/2, z )
For t < -2, this is the method of computation. For higher t, a direct method is derived from integration by parts. Since the function is symmetric about t=0, the area under the right tail of the density is found by calling the function with -t instead of t.z = k/(k + t**2).
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -100,-2 50000 5.9e-15 1.4e-15
IEEE -2,100 500000 2.7e-15 4.9e-17
stdtri: Functional inverse of Student's t 分布
概要
# double p, t, stdtri(); # int k; $t = stdtri( $k, $p );
説明
精度
Relative error:
arithmetic domain # trials peak rms
IEEE .001,.999 25000 5.7e-15 8.0e-16
IEEE 10^-6,.001 25000 2.0e-12 2.9e-14
struve: Struve function
概要
# double v, x, y, struve(); $y = struve( $v, $x );
説明
精度
plancki: 積分 of Planck's black body radiation formula
概要
# double lambda, T, y, plancki() $y = plancki( $lambda, $T );
説明
-5
c1 lambda
E = ------------------
c2/(lambda T)
e - 1
Physical constants c1 = 3.7417749e-16 and c2 = 0.01438769 are built in
to the function program. They are scaled to provide a result
in watts per square meter. Argument T represents temperature in degrees
Kelvin; lambda is wavelength in meters.
The 積分 is expressed in closed form, in terms of polylogarithms
(see polylog.c).
The total area under the curve is
(-1/8) (42 zeta(4) - 12 pi^2 zeta(2) + pi^4 ) c1 (T/c2)^4
= (pi^4 / 15) c1 (T/c2)^4
= 5.6705032e-8 T^4
where sigma = 5.6705032e-8 W m^2 K^-4 is the Stefan-Boltzmann constant.
精度
Relative error.
The domain refers to lambda T / c2.
arithmetic domain # trials peak rms
IEEE 0.1, 10 50000 7.1e-15 5.4e-16
polylog: polylogarithm function
概要
The polylogarithm of order n is defined by the series# double x, y, polylog(); # int n; $y = polylog( $n, $x );
inf k
- x
Li (x) = > --- .
n - n
k=1 k
For x = 1,
inf
- 1
Li (1) = > --- = Riemann zeta function (n) .
n - n
k=1 k
When n = 2, the function is the dilogarithm, related to Spence's 積分:
x 1-x
- -
| | -ln(1-t) | | ln t
Li (x) = | -------- dt = | ------ dt = spence(1-x) .
2 | | t | | 1 - t
- -
0 1
精度
Relative error:
arithmetic domain n # trials peak rms
IEEE 0, 1 2 50000 6.2e-16 8.0e-17
IEEE 0, 1 3 100000 2.5e-16 6.6e-17
IEEE 0, 1 4 30000 1.7e-16 4.9e-17
IEEE 0, 1 5 30000 5.1e-16 7.8e-17
bernum: Bernoulli numbers
概要
($num, $den) = bernum( $n); ($num_array, $den_array) = bernum();
説明
simpson: Simpson's rule to find an 積分
概要
$result = simpson(\&fun, $a, $b, $abs_err, $rel_err, $nmax);
sub fun {
my $x = shift;
return cos($x)*exp($x);
}
説明
vecang: angle between two vectors
概要
# double p[3], q[3], vecang(); $y = vecang( $p, $q );
説明
p.q / (|p| |q|) = cos A .
where "." represents inner product, "|x|" the length of vector x.
If the angle is small, an expression in sin A is preferred.
Set r = q - p. Then
p.q = p.p + p.r ,
|p|^2 = p.p ,
|q|^2 = p.p + 2 p.r + r.r ,
p.p^2 + 2 p.p p.r + p.r^2
cos^2 A = ----------------------------
p.p (p.p + 2 p.r + r.r)
p.p + 2 p.r + p.r^2 / p.p
= --------------------------- ,
p.p + 2 p.r + r.r
sin^2 A = 1 - cos^2 A
r.r - p.r^2 / p.p
= --------------------
p.p + 2 p.r + r.r
= (r.r - p.r^2 / p.p) / q.q .
精度
Relative error:
arithmetic domain # trials peak rms
IEEE -1, 1 10^6 1.7e-16 4.2e-17
onef2: Hypergeometric function 1F2
概要
# double a, b, c, x, value; # double *err; ($value, $err) = onef2( $a, $b, $c, $x)
精度
threef0: Hypergeometric function 3F0
概要
# double a, b, c, x, value; # double *err; ($value, $err) = threef0( $a, $b, $c, $x )
精度
yv: ベッセル関数 Yv with noninteger v
概要
# double v, x; # double yv( v, x ); $y = yv( $v, $x );
精度
tan: Circular tangent
概要
# double x, y, tan(); $y = tan( $x );
説明
is employed in the basic interval [0, pi/4].x + x**3 P(x**2)/Q(x**2)
精度
Relative error:
arithmetic domain # trials peak rms
DEC +-1.07e9 44000 4.1e-17 1.0e-17
IEEE +-1.07e9 30000 2.9e-16 8.1e-17
エラーメッセージ
message condition value returned tan total loss x > 1.073741824e9 0.0
cot: Circular cotangent
概要
# double x, y, cot(); $y = cot( $x );
説明
is employed in the basic interval [0, pi/4].x + x**3 P(x**2)/Q(x**2)
精度
Relative error:
arithmetic domain # trials peak rms
IEEE +-1.07e9 30000 2.9e-16 8.2e-17
エラーメッセージ
message condition value returned cot total loss x > 1.073741824e9 0.0 cot singularity x = 0 INFINITY
tandg: Circular tangent of argument in degrees
概要
# double x, y, tandg(); $y = tandg( $x );
説明
is employed in the basic interval [0, pi/4].x + x**3 P(x**2)/Q(x**2)
精度
Relative error:
arithmetic domain # trials peak rms
DEC 0,10 8000 3.4e-17 1.2e-17
IEEE 0,10 30000 3.2e-16 8.4e-17
エラーメッセージ
message condition value returned
tandg total loss x > 8.0e14 (DEC) 0.0
x > 1.0e14 (IEEE)
tandg singularity x = 180 k + 90 MAXNUM
cotdg: Circular cotangent of argument in degrees
概要
# double x, y, cotdg(); $y = cotdg( $x );
説明
is employed in the basic interval [0, pi/4].x + x**3 P(x**2)/Q(x**2)
エラーメッセージ
message condition value returned
cotdg total loss x > 8.0e14 (DEC) 0.0
x > 1.0e14 (IEEE)
cotdg singularity x = 180 k MAXNUM
tanh: Hyperbolic tangent
概要
# double x, y, tanh(); $y = tanh( $x );
説明
tanh(x) = sinh(x)/cosh(x) = 1 - 2/(exp(2x) + 1).
精度
Relative error:
arithmetic domain # trials peak rms
DEC -2,2 50000 3.3e-17 6.4e-18
IEEE -2,2 30000 2.5e-16 5.8e-17
unity: Relative error approximations for function arguments near unity.
概要
# log1p(x) = log(1+x) $y = log1p( $x ); # expm1(x) = exp(x) - 1 $y = expm1( $x ); # cosm1(x) = cos(x) - 1 $y = cosm1( $x );
yn: ベッセル関数 of second kind of integer order
概要
# double x, y, yn(); # int n; $y = yn( $n, $x );
説明
精度
arithmetic domain # trials peak rms
DEC 0, 30 2200 2.9e-16 5.3e-17
IEEE 0, 30 30000 3.4e-15 4.3e-16
エラーメッセージ
Spot checked against tables for x, n between 0 and 100.message condition value returned yn singularity x = 0 MAXNUM yn overflow MAXNUM
zeta: Riemann zeta function of two arguments
概要
# double x, q, y, zeta(); $y = zeta( $x, $q );
説明
inf.
- -x
zeta(x,q) = > (k+q)
-
k=0
where x > 1 and q is not a negative integer or zero.
The Euler-Maclaurin summation formula is used to obtain
the expansion
n
- -x
zeta(x,q) = > (k+q)
-
k=1
1-x inf. B x(x+1)...(x+2j)
(n+q) 1 - 2j
+ --------- - ------- + > --------------------
x-1 x - x+2j+1
2(n+q) j=1 (2j)! (n+q)
where the B2j are Bernoulli numbers. Note that (see zetac.c)
zeta(x,1) = zetac(x) + 1.
精度
zetac: リーマンのζ関数
概要
# double x, y, zetac(); $y = zetac( $x );
説明
inf.
- -x
zetac(x) = > k , x > 1,
-
k=2
is related to the Riemann zeta function by
Extension of the function definition for x < 1 is implemented. Zero is returned for x > log2(MAXNUM). An overflow error may occur for large negative x, due to the gamma function in the reflection formula.Riemann zeta(x) = zetac(x) + 1.
精度
Relative error:
arithmetic domain # trials peak rms
IEEE 1,50 10000 9.8e-16 1.3e-16
DEC 1,50 2000 1.1e-16 1.9e-17
Randy Kobes <randy@theoryx5.uwinnipeg.ca> に知らせてほしい。
数式操作へのプログラムへのインタフェースについては PDL, Math::Pari, Math::ematica を見よ。
Math::Cephes ルーティンへのコマンドラインインタフェースについては pmath スクリプトを見よ。
複素数や分数とのインタフェースについては Math::Cephes::Fraction , Math::Cephes::Complex を見よ。
多項式ルーティンとのインタフェースについては Math::Cephes::Polynomial を、行列ルーティンについては Math::Cephes::Matrix を見よ。
Cephes Math Library の C Code の著作権は Stephen L. Moshier に帰属し、http://www.netlib.org/cephes/ で入手可能である。 (Copyright 1984, 1987, 1989, 2002)
直接の質問は 30 Frost Street, Cambridge, MA 02140 にすること。
C ルーティンとのやりとりのために配列を扱うために含まれた arrays.c は Karl Glazebrook kgb@zzoepp.aao.gov.au の開発した PGPLOT モジュールに由来する。
perl インタフェースについては Randy Kobes に著作権がある。
本ライブラリはフリーソフトウェアであり、 Perl 本体と同等の条件で修正・再配布してもよい。
![]() |
Updated : 2007/11/13 |