function polycotpi( n, x, xc ) {
	var powTerms;
	var idx;
	var out;
	var sum;
	var c;
	var s;

	s = ( abs( x ) < abs( xc ) ) ? sinpi( x ) : sinpi( xc );
	c = cospi( x );
	switch ( n ) { // eslint-disable-line default-case
	case 1:
		return -PI / ( s * s );
	case 2:
		return 2.0 * PI2 * c / pow( s, 3.0 );
	case 3:
		return PI3 * polyval3( c*c ) / pow( s, 4.0 );
	case 4:
		return PI4 * c * polyval4( c*c ) / pow( s, 5.0 );
	case 5:
		return PI5 * polyval5( c*c ) / pow( s, 6.0 );
	case 6:
		return PI6 * c * polyval6( c*c ) / pow( s, 7.0 );
	case 7:
		return PI7 * polyval7( c*c ) / pow( s, 8.0 );
	case 8:
		return PI8 * c * polyval8( c*c ) / pow( s, 9.0 );
	case 9:
		return PI9 * polyval9( c*c ) / pow( s, 10.0 );
	case 10:
		return PI10 * c * polyval10( c*c ) / pow( s, 11.0 );
	case 11:
		return PI11 * polyval11( c*c ) / pow( s, 12.0 );
	case 12:
		return PI12 * c * polyval12( c*c ) / pow( s, 13.0 );
	}
	// We'll have to compute the coefficients up to `n`, complexity is O(n^2) which we don't worry about as the values are computed once and then cached. However, if the final evaluation would have too many terms just bail out right away:
	if ( n/2 > MAX_SERIES_ITERATIONS ) {
		debug( 'The value of `n` is so large that we\'re unable to compute the result in reasonable time.' );
		return NaN;
	}
	idx = n - 1;
	if ( idx >= table.length ) {
		// Lazily calculate derivatives:
		calculateDerivatives( n );
	}
	sum = evalpoly( table[ idx ], c*c );
	if ( idx & 1 ) {
		sum *= c; // First coefficient is order 1, and really an odd polynomial.
	}
	if ( sum === 0.0 ) {
		return sum;
	}
	// The remaining terms are computed using logs since the powers and factorials get real large real quick:
	powTerms = n * LN_PI;
	if ( s === 0.0 ) {
		return ( sum >= 0.0 ) ? PINF : NINF;
	}
	powTerms -= ln( abs( s ) ) * ( n+1 );
	powTerms += gammaln( n ) + ln( abs(sum) );

	if ( powTerms > MAX_LN ) {
		return ( sum >= 0.0 ) ? PINF : NINF;
	}
	out = exp( powTerms ) * signum( sum );
	if ( s < 0.0 && ( (n+1)&1 ) ) {
		out *= -1;
	}
	return out;
}
Returns n'th derivative of \\(\operatorname{cot|(\pi x)\\) at \\(x\\).

## Notes

-   The derivatives are simply tabulated for up to \\(n = 9\\), beyond that it is possible to calculate coefficients as follows. The general form of each derivative is:

    ```tex
    \pi^n * \sum_{k=0}^n C[k,n] \cdot \cos^k(\pi \cdot x) \cdot \operatorname{csc}^{(n+1)}(\pi \cdot x)
    ```

    with constant \\( C\[0,1\] = -1 \\) and all other \\( C\[k,n\] = 0 \)). Then for each \\( k < n+1 \\):

    ```tex
    \begin{align*}
    C[k-1, n+1]  &-= k * C[k, n]; \\
    C[k+1, n+1]  &+= (k-n-1) * C[k, n];
    \end{align*}
    ```

-   Note that there are many different ways of representing this derivative thanks to the many trigonometric identities available. In particular, the sum of powers of cosines could be replaced by a sum of cosine multiple angles, and, indeed, if you plug the derivative into Mathematica, this is the form it will give. The two forms are related via the Chebeshev polynomials of the first kind and \\( T_n(\cos(x)) = \cos(n x) \\). The polynomial form has the great advantage that all the cosine terms are zero at half integer arguments - right where this function has it's minimum - thus avoiding cancellation error in this region.

-   And finally, since every other term in the polynomials is zero, we can save space by only storing the non-zero terms. This greatly increases complexity when subscripting the tables in the calculation, but halves the storage space (and complexity for that matter).

@private
@param {PositiveInteger} n - derivative to evaluate
@param {number} x - input
@param {number} xc - one minus `x`
@returns {number} n'th derivative