Home Libraries People FAQ More

#### Log Gamma

##### 概要

```#include <boost/math/special_functions/gamma.hpp>
```

```namespace boost{ namespace math{

template <class T>
calculated-result-type lgamma(T z);

template <class T, class Policy>
calculated-result-type lgamma(T z, const Policy&);

template <class T>
calculated-result-type lgamma(T z, int* sign);

template <class T, class Policy>
calculated-result-type lgamma(T z, int* sign, const Policy&);

}} // namespaces
```

lgamma 函數 定義如下:

##### 精確性

53

Win32 Visual C++ 8

(GSL=33) (Cephes=1.5)

(GSL=5.2) (Cephes=1.1)

(GSL=1168) (Cephes~500000)

(GSL=25) (Cephes=1.6)

64

Linux IA32 / GCC

(GNU C Lib 峰值=1.7 均值=0.49)

(GNU C Lib 峰值= 0.96 均值=0.54)

(GNU C Lib 峰值=0.74 均值=0.26)

(GNU C Lib 峰值=3.0 均值=0.86)

64

Linux IA64 / GCC

(GNU C Lib 峰值 0)

(GNU C Lib 峰值 0)

(GNU C Lib 峰值 0)

(GNU C Lib 峰值 0)

113

HPUX IA64, aCC A.06.06

##### 實現

```lgamma(z) = (z-2)(z+1)(Y + R(z-2));
```

```lgamma(z+1) = log(z) + lgamma(z);
```

```lgamma(z) = (z-1)(z-2)(Y + R(z-1));
```

Y是一個常量，R(z-1)針對於與Y相比的絕對誤差進行了優化。對於z>1.5 ，上面的形式不會收斂於一個極值解，但是下面的一個類似的形式可以做到這一點：

```lgamma(z) = (2-z)(1-z)(Y + R(2-z));
```

```lgamma(z) = lgamma(z+1) - log(z);
```