special_funcs

special_funcs.Bernoulli(n, x)[source]

The Bernoulli polynomial B_n(x), n < 60.

Parameters:
  • n (int) – Order of the Bernoulli polynomial (must be < 60).

  • x (float or array) – Argument of the polynomial.

Returns:

Value of B_n(x).

Return type:

float or array

Notes

See Wikipedia article on Bernoulli polynomials for definition.

special_funcs.K0(z)[source]

Modified Bessel function of the second kind of order 0.

Parameters:

z (float or array) – Argument of the Bessel function.

Returns:

Value of K_0(z).

Return type:

float or array

Notes

Uses different series approximations for z < 9 and z ≥ 9. Algorithm from Zhang and Jin.

special_funcs.K1(z)[source]

Modified Bessel function of the second kind of order 1.

Parameters:

z (float or array) – Argument of the Bessel function.

Returns:

Value of K_1(z).

Return type:

float or array

special_funcs.K2(z)[source]

Modified Bessel function of the second kind of order 2.

Parameters:

z (float or array) – Argument of the Bessel function.

Returns:

Value of K_2(z).

Return type:

float or array

Notes

Computed using recurrence relation: K_2(z) = K_0(z) + 2/z K_1(z).

special_funcs.Li(n, z)[source]

Polylogarithm of order n and argument z.

Parameters:
  • n (int) – Order of the polylogarithm (static argument).

  • z (float or complex) – Argument of the polylogarithm.

Returns:

Value of Li_n(z).

Return type:

float

Notes

Uses different series expansions depending on |z|: - |z| ≤ 0.5: direct series - 0.5 < |z| < 2: intermediate series with harmonic terms - |z| ≥ 2: reciprocal series with Bernoulli polynomials

special_funcs.Riemann_zeta(n)[source]

Riemann zeta function with extended domain.

Parameters:

n (int or array) – Argument of the zeta function (must be > -60).

Returns:

Value of ζ(n).

Return type:

float or array

Notes

Uses Bernoulli numbers for negative arguments. Returns 0 for negative even integers.

special_funcs.comb(N, k)[source]

Combinatoric factor N! / (k! (N-k)!).

Parameters:
  • N (int or array) – Total number of items.

  • k (int or array) – Number of items to choose.

Returns:

Binomial coefficient.

Return type:

float or array

special_funcs.gamma(x)[source]

Gamma function using the Lanczos approximation.

Parameters:

x (float or complex) – Argument of the gamma function.

Returns:

Value of Γ(x).

Return type:

float or complex

Notes

Uses Lanczos approximation with reflection formula for x < 0.5. Supports complex arguments.