A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/cmath/lgamma/ below:

function

<cmath> <ctgmath>

lgamma
     double lgamma  (double x);      float lgammaf (float x);long double lgammal (long double x);
     double lgamma (double x);      float lgamma (float x);long double lgamma (long double x);     double lgamma (T x);           // additional overloads for integral types

Compute log-gamma function

Returns the natural logarithm of the absolute value of the gamma function of x.

Header

<tgmath.h>

provides a type-generic macro version of this function.


Additional overloads

are provided in this header (

<cmath>

) for the

integral types

: These overloads effectively cast

x

to a

double

before calculations (defined for

T

being any

integral type

).



Parameters
x
Parameter for the log-gamma function.

Return Value Log-gamma function of x.
If x is too large, an overflow range error occurs.
If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).

If an overflow range error occurs:


- And math_errhandling has MATH_ERRNO set: the global variable errno is set to ERANGE.
- And math_errhandling has MATH_ERREXCEPT set: FE_OVERFLOW is raised.

If a pole error occurs:


- And math_errhandling has MATH_ERRNO set: the global variable errno is set to ERANGE.
- And math_errhandling has MATH_ERREXCEPT set: FE_DIVBYZERO is raised.

Example
1
2
3
4
5
6
7
8
9
10
11
12
/* lgamma example */
#include <stdio.h>      /* printf */
#include <math.h>       /* lgamma */

int main ()
{
  double param, result;
  param = 0.5;
  result = lgamma (param);
  printf ("lgamma(%f) = %f\n", param, result );
  return 0;
}

Output:
lgamma (0.500000) = 0.572365


See also
tgamma
Compute gamma function (function)
erf
Compute error function (function)
erfc
Compute complementary error function (function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4