.\" Copyright (c) 1985, 1991 Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92 .\" %FreeBSD: src/lib/msun/man/lgamma.3,v 1.7.2.5 2001/12/17 10:08:36 ru Exp % .\" .\" $FreeBSD$ .Dd December 3, 1992 .Dt LGAMMA 3 .Os .Sh 名称 .Nm lgamma , .Nm lgammaf , .Nm gamma , .Nm gammaf .Nd ガンマ関数およびガンマ関数の対数計算 .Sh ライブラリ .Lb libm .Sh 書式 .Fd #include .Ft extern int .Fa signgam ; .sp .Ft double .Fn lgamma "double x" .Ft float .Fn lgammaf "float x" .Ft double .Fn gamma "double x" .Ft float .Fn gammaf "float x" .Sh 解説 .Fn lgamma x および .Fn lgammaf x は x のガンマ関数の自然対数を返します。 .Pp 外部変数 .Fa signgam には x のガンマ関数の符号が返されます。 .Pp .Fn gamma x および .Fn gammaf x では .Fa signgam は使用されません。 .Sh 特記事項 g := \(*G(x) の計算において .Dq Li signam\(**exp(lgamma(x)) のような記述は不適切です。 以下のような (C 言語) プログラムコーディングにします。 .Bd -literal -offset indent lg = lgamma(x); g = signam\(**exp(lg); .Ed .Pp signgam は、 .Fn lgamma あるいは .Fn lgammaf の処理が完了した段階でないと正しい値を得ることができません。 .Pp 引数の値域については、 .Fn gamma および .Fn gammaf のものが優先されます。 正値引数の場合は全ての計算要素まで正確に計算されます。 .Fn lgamma のベキ指数の有効サイズは 2 の 10 乗までです。 .Sh 戻り値 .Fn gamma , .Fn gammaf , .Fn lgamma , および .Fn lgammaf は引数の値が適正な範囲であれば正しい結果を返します。 制限を越えた大きな桁の正整数値や負符号の 整数値を指定すると桁あふれエラーとなります。 .Tn VAX では、予約語のオペレータが返され、 負の大きな非整数値に関しては .Fn gamma 関数でアンダフローエラーが発生し、 .Va errno に .Er ERANGE がセットされます。 .Sh 関連項目 .Xr math 3 .Sh 歴史 .Nm lgamma は .Bx 4.3 に実装された関数です。 .Nm gamma は .Bx 4.4 に実装された関数です。 .Fn gamma の名称は関数名 .Fn lgamma の元になっていますが、 旧いコードの部分では互換性が失われている場合もあります。