<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->

# Function lgamma

Logarithm of the gamma function for real, positive numbers and complex numbers,
using Lanczos approximation for numbers and Stirling series for complex numbers.


## Syntax

```js
math.lgamma(n)
```

### Parameters

Parameter | Type | Description
--------- | ---- | -----------
`n` | number &#124; Complex | A real or complex number

### Returns

Type | Description
---- | -----------
number &#124; Complex | The log gamma of `n`


### Throws

Type | Description
---- | -----------


## Examples

```js
math.lgamma(5)       // returns 3.178053830347945
math.lgamma(0)       // returns Infinity
math.lgamma(-0.5)    // returns NaN
math.lgamma(math.i)  // returns -0.6509231993018536 - 1.8724366472624294i
```


## See also

[gamma](gamma.md)
