function polygamma( n, x ) {
	var xSmallLimit;
	var result;
	var z;

	if ( !isNonNegativeInteger( n ) ) {
		return NaN;
	}
	if ( n === 0 ) {
		return digamma( x );
	}
	if ( n === 1 ) {
		return trigamma( x );
	}
	if ( x < 0.0 ) {
		if ( floor(x) === x ) {
			// Result is infinity if `x` is odd, and a pole error if `x` is even.
			if ( trunc( x ) & 1 ) {
				return PINF;
			}
			debug( 'Evaluation at negative integer: %d.', x );
			return NaN;
		}
		z = 1.0 - x;
		result = polygamma( n, z ) + ( PI * polycotpi( n, z, x ) );
		return ( n & 1 ) ? -result : result;
	}
	// Limit for use of small-x series is chosen so that the series doesn't go too divergent in the first few terms. Ordinarily, this would mean setting the limit to `~1/n`, but we can tolerate a small amount of divergence:
	xSmallLimit = min( 5.0/n, 0.25 );
	if ( x < xSmallLimit ) {
		return nearzero( n, x );
	}
	if ( x > ( 0.4 * DIGITS_BASE10 ) + ( 4*n ) ) {
		return atinfinityplus( n, x );
	}
	if ( x === 1.0 ) {
		return ( ( n & 1 ) ? 1.0 : -1.0 ) * factorial( n ) * zeta( n+1 );
	}
	if ( x === 0.5 ) {
		result = ( ( n & 1 ) ? 1.0 : -1.0 ) * factorial( n ) * zeta( n+1 );
		if ( abs( result ) >= ldexp( MAX, -n-1 ) ) {
			return ( signum( result ) === 1 ) ? PINF : NINF;
		}
		result *= ldexp( 1.0, n+1 ) - 1.0;
		return result;
	}
	return attransitionplus( n, x );
}
Evaluates the polygamma function.

@param {NonNegativeInteger} n - order of derivative
@param {number} x - input value
@returns {number} (n+1)'th derivative

@example
var v = polygamma( 3, 1.2 );
// returns ~3.245

@example
var v = polygamma( 5, 1.2 );
// returns ~41.39

@example
var v = polygamma( 3, -4.9 );
// returns ~60014.239

@example
var v = polygamma( 2.5, -1.2 );
// returns NaN

@example
var v = polygamma( -1, 5.3 );
// returns NaN

@example
var v = polygamma( 2, -2.0 );
// returns NaN

@example
var v = polygamma( NaN, 2.1 );
// returns NaN

@example
var v = polygamma( 1, NaN );
// returns NaN

@example
var v = polygamma( NaN, NaN );
// returns NaN