1 /* specfunc/gsl_sf_gamma.h
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 /* Author: G. Jungman */
22 #ifndef __GSL_SF_GAMMA_H__
23 #define __GSL_SF_GAMMA_H__
25 #include <gsl/gsl_sf_result.h>
30 # define __BEGIN_DECLS extern "C" {
31 # define __END_DECLS }
33 # define __BEGIN_DECLS /* empty */
34 # define __END_DECLS /* empty */
40 /* Log[Gamma(x)], x not a negative integer
41 * Uses real Lanczos method.
42 * Returns the real part of Log[Gamma[x]] when x < 0,
43 * i.e. Log[|Gamma[x]|].
45 * exceptions: GSL_EDOM, GSL_EROUND
47 int gsl_sf_lngamma_e(double x, gsl_sf_result * result);
48 double gsl_sf_lngamma(const double x);
51 /* Log[Gamma(x)], x not a negative integer
52 * Uses real Lanczos method. Determines
53 * the sign of Gamma[x] as well as Log[|Gamma[x]|] for x < 0.
54 * So Gamma[x] = sgn * Exp[result_lg].
56 * exceptions: GSL_EDOM, GSL_EROUND
58 int gsl_sf_lngamma_sgn_e(double x, gsl_sf_result * result_lg, double *sgn);
61 /* Gamma(x), x not a negative integer
62 * Uses real Lanczos method.
64 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EROUND
66 int gsl_sf_gamma_e(const double x, gsl_sf_result * result);
67 double gsl_sf_gamma(const double x);
70 /* Regulated Gamma Function, x > 0
71 * Gamma^*(x) = Gamma(x)/(Sqrt[2Pi] x^(x-1/2) exp(-x))
72 * = (1 + 1/(12x) + ...), x->Inf
73 * A useful suggestion of Temme.
75 * exceptions: GSL_EDOM
77 int gsl_sf_gammastar_e(const double x, gsl_sf_result * result);
78 double gsl_sf_gammastar(const double x);
82 * Uses real Lanczos method.
84 * exceptions: GSL_EUNDRFLW, GSL_EROUND
86 int gsl_sf_gammainv_e(const double x, gsl_sf_result * result);
87 double gsl_sf_gammainv(const double x);
90 /* Log[Gamma(z)] for z complex, z not a negative integer
91 * Uses complex Lanczos method. Note that the phase part (arg)
92 * is not well-determined when |z| is very large, due
93 * to inevitable roundoff in restricting to (-Pi,Pi].
94 * This will raise the GSL_ELOSS exception when it occurs.
95 * The absolute value part (lnr), however, never suffers.
99 * arg = arg(Gamma(z)) in (-Pi, Pi]
101 * exceptions: GSL_EDOM, GSL_ELOSS
103 int gsl_sf_lngamma_complex_e(double zr, double zi, gsl_sf_result * lnr, gsl_sf_result * arg);
109 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
111 int gsl_sf_taylorcoeff_e(const int n, const double x, gsl_sf_result * result);
112 double gsl_sf_taylorcoeff(const int n, const double x);
117 * exceptions: GSL_EDOM, GSL_OVRFLW
119 int gsl_sf_fact_e(const unsigned int n, gsl_sf_result * result);
120 double gsl_sf_fact(const unsigned int n);
123 /* n!! = n(n-2)(n-4) ...
125 * exceptions: GSL_EDOM, GSL_OVRFLW
127 int gsl_sf_doublefact_e(const unsigned int n, gsl_sf_result * result);
128 double gsl_sf_doublefact(const unsigned int n);
132 * Faster than ln(Gamma(n+1)) for n < 170; defers for larger n.
136 int gsl_sf_lnfact_e(const unsigned int n, gsl_sf_result * result);
137 double gsl_sf_lnfact(const unsigned int n);
144 int gsl_sf_lndoublefact_e(const unsigned int n, gsl_sf_result * result);
145 double gsl_sf_lndoublefact(const unsigned int n);
150 * exceptions: GSL_EDOM
152 int gsl_sf_lnchoose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
153 double gsl_sf_lnchoose(unsigned int n, unsigned int m);
158 * exceptions: GSL_EDOM, GSL_EOVRFLW
160 int gsl_sf_choose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
161 double gsl_sf_choose(unsigned int n, unsigned int m);
164 /* Logarithm of Pochhammer (Apell) symbol
166 * where (a)_x := Gamma[a + x]/Gamma[a]
170 * exceptions: GSL_EDOM
172 int gsl_sf_lnpoch_e(const double a, const double x, gsl_sf_result * result);
173 double gsl_sf_lnpoch(const double a, const double x);
176 /* Logarithm of Pochhammer (Apell) symbol, with sign information.
177 * result = log( |(a)_x| )
179 * where (a)_x := Gamma[a + x]/Gamma[a]
181 * a != neg integer, a+x != neg integer
183 * exceptions: GSL_EDOM
185 int gsl_sf_lnpoch_sgn_e(const double a, const double x, gsl_sf_result * result, double * sgn);
188 /* Pochhammer (Apell) symbol
189 * (a)_x := Gamma[a + x]/Gamma[x]
191 * a != neg integer, a+x != neg integer
193 * exceptions: GSL_EDOM, GSL_EOVRFLW
195 int gsl_sf_poch_e(const double a, const double x, gsl_sf_result * result);
196 double gsl_sf_poch(const double a, const double x);
199 /* Relative Pochhammer (Apell) symbol
201 * where (a,x) = (a)_x := Gamma[a + x]/Gamma[a]
203 * exceptions: GSL_EDOM
205 int gsl_sf_pochrel_e(const double a, const double x, gsl_sf_result * result);
206 double gsl_sf_pochrel(const double a, const double x);
209 /* Normalized Incomplete Gamma Function
211 * Q(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
215 * Q(0,x) := 0, x != 0
217 * exceptions: GSL_EDOM
219 int gsl_sf_gamma_inc_Q_e(const double a, const double x, gsl_sf_result * result);
220 double gsl_sf_gamma_inc_Q(const double a, const double x);
223 /* Complementary Normalized Incomplete Gamma Function
225 * P(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,0,x} ]
229 * exceptions: GSL_EDOM
231 int gsl_sf_gamma_inc_P_e(const double a, const double x, gsl_sf_result * result);
232 double gsl_sf_gamma_inc_P(const double a, const double x);
235 /* Non-normalized Incomplete Gamma Function
237 * Gamma(a,x) := Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
240 * Gamma(a, 0) := Gamma(a)
242 * exceptions: GSL_EDOM
244 int gsl_sf_gamma_inc_e(const double a, const double x, gsl_sf_result * result);
245 double gsl_sf_gamma_inc(const double a, const double x);
248 /* Logarithm of Beta Function
252 * exceptions: GSL_EDOM
254 int gsl_sf_lnbeta_e(const double a, const double b, gsl_sf_result * result);
255 double gsl_sf_lnbeta(const double a, const double b);
257 int gsl_sf_lnbeta_sgn_e(const double x, const double y, gsl_sf_result * result, double * sgn);
264 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
266 int gsl_sf_beta_e(const double a, const double b, gsl_sf_result * result);
267 double gsl_sf_beta(const double a, const double b);
270 /* Normalized Incomplete Beta Function
273 * a > 0, b > 0, 0 <= x <= 1
274 * exceptions: GSL_EDOM, GSL_EUNDRFLW
276 int gsl_sf_beta_inc_e(const double a, const double b, const double x, gsl_sf_result * result);
277 double gsl_sf_beta_inc(const double a, const double b, const double x);
280 /* The maximum x such that gamma(x) is not
281 * considered an overflow.
283 #define GSL_SF_GAMMA_XMAX 171.0
285 /* The maximum n such that gsl_sf_fact(n) does not give an overflow. */
286 #define GSL_SF_FACT_NMAX 170
288 /* The maximum n such that gsl_sf_doublefact(n) does not give an overflow. */
289 #define GSL_SF_DOUBLEFACT_NMAX 297
293 #endif /* __GSL_SF_GAMMA_H__ */