# Gamma Lanczos Sum > Calculate the Lanczos sum for the approximation of the [gamma function][gamma-function].
The [Lanczos approximation][lanczos-approximation] for the [gamma function][gamma-function] can be written in partial fraction form as follows:
Lanczos approximation for gamma function.
where `g` is an [arbitrary constant][@stdlib/constants/float64/gamma-lanczos-g] and `L_g(n)` is the Lanczos sum.
## Usage ```javascript var gammaLanczosSum = require( '@stdlib/math/base/special/gamma-lanczos-sum' ); ``` #### gammaLanczosSum( x ) Calculates the Lanczos sum for the approximation of the [gamma function][gamma-function]. ```javascript var v = gammaLanczosSum( 4.0 ); // returns ~950.366 v = gammaLanczosSum( -1.5 ); // returns ~1373366.245 v = gammaLanczosSum( -0.5 ); // returns ~-699841.735 v = gammaLanczosSum( 0.5 ); // returns ~96074.186 v = gammaLanczosSum( 0.0 ); // returns Infinity v = gammaLanczosSum( NaN ); // returns NaN ```
## Examples ```javascript var linspace = require( '@stdlib/array/linspace' ); var gammaLanczosSum = require( '@stdlib/math/base/special/gamma-lanczos-sum' ); var x = linspace( -10.0, 10.0, 100 ); var v; var i; for ( i = 0; i < x.length; i++ ) { v = gammaLanczosSum( x[ i ] ); console.log( 'x: %d, f(x): %d', x[ i ], v ); } ```