function stirling( x ) {
	var z;
	if ( x < SMALLEST_FLOAT32 ) {
		return MAX_FLOAT32;
	}
	if ( x < 1.0 ) {
		return gammaln( x+1.0 ) - ( (x+0.5) * ln(x) ) + x - LN_SQRT_TWO_PI;
	}
	if ( x < 2.0 ) {
		return gammaln( x ) - ( (x-0.5) * ln(x) ) + x - LN_SQRT_TWO_PI;
	}
	if ( x < 3.0 ) {
		return gammaln( x-1.0 ) - ( (x-0.5) * ln(x) ) + x - LN_SQRT_TWO_PI + ln( x-1.0 ); // eslint-disable-line max-len
	}
	if ( x < 12.0 ) {
		z = ( 18.0/( x*x ) ) - 1.0;
		return chepolsum( 17, z ) / ( 12.0*x );
	}
	z = 1.0 / ( x * x );
	if ( x < 1000.0 ) {
		return polyvalC( z ) / ( C6+z ) / x;
	}
	return polyvalD( z ) / x;
}
Computes the Stirling series corresponding to asymptotic series for the logarithm of the gamma function.

```tex
\frac{1}{12x}-\frac{1}{360x^3}\ldots; x \ge 3
```

@private
@param {number} x - input value
@returns {number} function value