|
Packit |
7cfc04 |
.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
|
|
Packit |
7cfc04 |
.\" Distributed under GPL
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Based on glibc infopages
|
|
Packit |
7cfc04 |
.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
|
|
Packit |
7cfc04 |
.\" <mtk.manpages@gmail.com>
|
|
Packit |
7cfc04 |
.\" Modified 2004-11-15, fixed error noted by Fabian Kreutz
|
|
Packit |
7cfc04 |
.\" <kreutz@dbs.uni-hannover.de>
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH TGAMMA 3 2017-09-15 "GNU" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
tgamma, tgammaf, tgammal \- true gamma function
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.B #include <math.h>
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BI "double tgamma(double " x );
|
|
Packit |
7cfc04 |
.br
|
|
Packit |
7cfc04 |
.BI "float tgammaf(float " x );
|
|
Packit |
7cfc04 |
.br
|
|
Packit |
7cfc04 |
.BI "long double tgammal(long double " x );
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Link with \fI\-lm\fP.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.in -4n
|
|
Packit |
7cfc04 |
Feature Test Macro Requirements for glibc (see
|
|
Packit |
7cfc04 |
.BR feature_test_macros (7)):
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.ad l
|
|
Packit |
7cfc04 |
.BR tgamma (),
|
|
Packit |
7cfc04 |
.BR tgammaf (),
|
|
Packit |
7cfc04 |
.BR tgammal ():
|
|
Packit |
7cfc04 |
.RS 4
|
|
Packit |
7cfc04 |
_ISOC99_SOURCE ||
|
|
Packit |
7cfc04 |
_POSIX_C_SOURCE\ >=\ 200112L
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.ad
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
These functions calculate the Gamma function of
|
|
Packit |
7cfc04 |
.IR x .
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The Gamma function is defined by
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.RS
|
|
Packit |
7cfc04 |
Gamma(x) = integral from 0 to infinity of t^(x\-1) e^\-t dt
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
It is defined for every real number except for nonpositive integers.
|
|
Packit |
7cfc04 |
For nonnegative integral
|
|
Packit |
7cfc04 |
.I m
|
|
Packit |
7cfc04 |
one has
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.RS
|
|
Packit |
7cfc04 |
Gamma(m+1) = m!
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
and, more generally, for all
|
|
Packit |
7cfc04 |
.IR x :
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.RS
|
|
Packit |
7cfc04 |
Gamma(x+1) = x * Gamma(x)
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Furthermore, the following is valid for all values of
|
|
Packit |
7cfc04 |
.I x
|
|
Packit |
7cfc04 |
outside the poles:
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.RS
|
|
Packit |
7cfc04 |
Gamma(x) * Gamma(1 \- x) = PI / sin(PI * x)
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.SH RETURN VALUE
|
|
Packit |
7cfc04 |
On success, these functions return Gamma(x).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I x
|
|
Packit |
7cfc04 |
is a NaN, a NaN is returned.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I x
|
|
Packit |
7cfc04 |
is positive infinity, positive infinity is returned.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I x
|
|
Packit |
7cfc04 |
is a negative integer, or is negative infinity,
|
|
Packit |
7cfc04 |
a domain error occurs,
|
|
Packit |
7cfc04 |
and a NaN is returned.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If the result overflows,
|
|
Packit |
7cfc04 |
a range error occurs,
|
|
Packit |
7cfc04 |
and the functions return
|
|
Packit |
7cfc04 |
.BR HUGE_VAL ,
|
|
Packit |
7cfc04 |
.BR HUGE_VALF ,
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR HUGE_VALL ,
|
|
Packit |
7cfc04 |
respectively, with the correct mathematical sign.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If the result underflows,
|
|
Packit |
7cfc04 |
a range error occurs,
|
|
Packit |
7cfc04 |
and the functions return 0, with the correct mathematical sign.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I x
|
|
Packit |
7cfc04 |
is \-0 or +0,
|
|
Packit |
7cfc04 |
a pole error occurs,
|
|
Packit |
7cfc04 |
and the functions return
|
|
Packit |
7cfc04 |
.BR HUGE_VAL ,
|
|
Packit |
7cfc04 |
.BR HUGE_VALF ,
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR HUGE_VALL ,
|
|
Packit |
7cfc04 |
respectively, with the same sign as the 0.
|
|
Packit |
7cfc04 |
.SH ERRORS
|
|
Packit |
7cfc04 |
See
|
|
Packit |
7cfc04 |
.BR math_error (7)
|
|
Packit |
7cfc04 |
for information on how to determine whether an error has occurred
|
|
Packit |
7cfc04 |
when calling these functions.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The following errors can occur:
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Domain error: \fIx\fP is a negative integer, or negative infinity
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
is set to
|
|
Packit |
7cfc04 |
.BR EDOM .
|
|
Packit |
7cfc04 |
An invalid floating-point exception
|
|
Packit |
7cfc04 |
.RB ( FE_INVALID )
|
|
Packit |
7cfc04 |
is raised (but see BUGS).
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Pole error: \fIx\fP is +0 or \-0
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
is set to
|
|
Packit |
7cfc04 |
.BR ERANGE .
|
|
Packit |
7cfc04 |
A divide-by-zero floating-point exception
|
|
Packit |
7cfc04 |
.RB ( FE_DIVBYZERO )
|
|
Packit |
7cfc04 |
is raised.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Range error: result overflow
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
is set to
|
|
Packit |
7cfc04 |
.BR ERANGE .
|
|
Packit |
7cfc04 |
An overflow floating-point exception
|
|
Packit |
7cfc04 |
.RB ( FE_OVERFLOW )
|
|
Packit |
7cfc04 |
is raised.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
glibc also gives the following error which is not specified
|
|
Packit |
7cfc04 |
in C99 or POSIX.1-2001.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Range error: result underflow
|
|
Packit |
7cfc04 |
.\" e.g., tgamma(-172.5) on glibc 2.8/x86-32
|
|
Packit |
7cfc04 |
.\" .I errno
|
|
Packit |
7cfc04 |
.\" is set to
|
|
Packit |
7cfc04 |
.\" .BR ERANGE .
|
|
Packit |
7cfc04 |
An underflow floating-point exception
|
|
Packit |
7cfc04 |
.RB ( FE_UNDERFLOW )
|
|
Packit |
7cfc04 |
is raised, and
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
is set to
|
|
Packit |
7cfc04 |
.BR ERANGE .
|
|
Packit |
7cfc04 |
.\" glibc (as at 2.8) also supports an inexact
|
|
Packit |
7cfc04 |
.\" exception for various cases.
|
|
Packit |
7cfc04 |
.SH VERSIONS
|
|
Packit |
7cfc04 |
These functions first appeared in glibc in version 2.1.
|
|
Packit |
7cfc04 |
.SH ATTRIBUTES
|
|
Packit |
7cfc04 |
For an explanation of the terms used in this section, see
|
|
Packit |
7cfc04 |
.BR attributes (7).
|
|
Packit |
7cfc04 |
.TS
|
|
Packit |
7cfc04 |
allbox;
|
|
Packit |
7cfc04 |
lbw30 lb lb
|
|
Packit |
7cfc04 |
l l l.
|
|
Packit |
7cfc04 |
Interface Attribute Value
|
|
Packit |
7cfc04 |
T{
|
|
Packit |
7cfc04 |
.BR tgamma (),
|
|
Packit |
7cfc04 |
.BR tgammaf (),
|
|
Packit |
7cfc04 |
.BR tgammal ()
|
|
Packit |
7cfc04 |
T} Thread safety MT-Safe
|
|
Packit |
7cfc04 |
.TE
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
C99, POSIX.1-2001, POSIX.1-2008.
|
|
Packit |
7cfc04 |
.SH NOTES
|
|
Packit |
7cfc04 |
This function had to be called "true gamma function"
|
|
Packit |
7cfc04 |
since there is already a function
|
|
Packit |
7cfc04 |
.BR gamma (3)
|
|
Packit |
7cfc04 |
that returns something else (see
|
|
Packit |
7cfc04 |
.BR gamma (3)
|
|
Packit |
7cfc04 |
for details).
|
|
Packit |
7cfc04 |
.SH BUGS
|
|
Packit |
7cfc04 |
Before version 2.18, the glibc implementation of these functions did not set
|
|
Packit |
7cfc04 |
.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6809
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
to
|
|
Packit |
7cfc04 |
.B EDOM
|
|
Packit |
7cfc04 |
when
|
|
Packit |
7cfc04 |
.I x
|
|
Packit |
7cfc04 |
is negative infinity.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Before glibc 2.19,
|
|
Packit |
7cfc04 |
.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6810
|
|
Packit |
7cfc04 |
the glibc implementation of these functions did not set
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
to
|
|
Packit |
7cfc04 |
.B ERANGE
|
|
Packit |
7cfc04 |
on an underflow range error.
|
|
Packit |
7cfc04 |
.I x
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
In glibc versions 2.3.3 and earlier,
|
|
Packit |
7cfc04 |
an argument of +0 or \-0 incorrectly produced a domain error
|
|
Packit |
7cfc04 |
.RI ( errno
|
|
Packit |
7cfc04 |
set to
|
|
Packit |
7cfc04 |
.B EDOM
|
|
Packit |
7cfc04 |
and an
|
|
Packit |
7cfc04 |
.B FE_INVALID
|
|
Packit |
7cfc04 |
exception raised), rather than a pole error.
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR gamma (3),
|
|
Packit |
7cfc04 |
.BR lgamma (3)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|