Motivated by the need of some special functions when writing signal processing code for NMath, we decided to add a suite of special functions to be included in NMath 6.1. While the field of special functions is vast [1], our 41 functions cover many of the most commonly needed functions in physics and engineering. This includes the gamma function and related functions, Bessel functions, elliptic integrals, and more. All special functions in NMath are now organized in a SpecialFunctions
class, which is structured similarly to the existing StatsFunctions
and NMathFunctions
classes.
Special functions list
Below is a complete list of the special functions now available in the SpecialFunctions
class which resides in the CenterSpace.NMath.Core
name space. Previously a handful of these functions were available in either the NMathFunctions
or StatsFunctions
classes, but now those functions have been deprecated and consolidated into the SpecialFunctions
class. Please update your code accordingly as these deprecated functions will be removed from NMath within two to three release cycles.
Using these special functions in your code is simple.
using namespace CenterSpace.NMath.Core
// Compute the Jacobi function Sn() with a complex argument.
var cmplx = new DoubleComplex( 0.1, 3.3 )
var sn = SpecialFunctions.Sn( cmplx, .3 ); // sn = 0.16134 - i 0.99834
// Compute the elliptic integral, K(m)
var ei = SpecialFunctions.EllipticK( 0.432 ); // ei = 1.80039
Below is a complete list of all NMath special functions.
Special Function | Comments |
---|---|
EulerGamma |
A constant, also known as the Euler-Macheroni constant. Famously, rationality unknown. |
Airy |
Provides solutions Ai, Bi, and derivatives Ai’, Bi’ to y” – yz = 0. |
Zeta |
The Riemann zeta function. |
PolyLogarithm |
The Polylogarithm, Li_n(x) reduces to the Riemann zeta for x = 1. |
HarmonicNumber |
The harmonic number is a truncated sum of the harmonic series, closely related to the digamma function. |
Factorial |
n! |
FactorialLn |
The natural log of the factorial, ln( n! ). |
Binomial |
The binomial coefficient, n choose k; The number of ways of picking k unordered outcomes from n possibilities. |
BinomialLn |
The natural log of the binomial coefficient. |
Gamma |
The gamma function, conceptually a generalization of the factorial. |
GammaReciprocal |
The reciprocal of the gamma function. |
IncompleteGammaFunction |
Computes the gamma integral from 0 to x. |
IncompleteGammaComplement |
Computes the gamma integral from x to infinity (and beyond!). |
Digamma |
Also known as the psi function. |
GammaLn |
The natural log of the gamma function. |
Beta |
The beta integral is also known as the Eulerian integral of the first kind. |
IncompleteBeta |
Computes the beta integral from 0 to x in [0,1]. |
Ei |
The exponential integral. |
EllipticK |
The complete elliptic integral, K(m), of the first kind. Note that m is related to the elliptic modulus k with, m = k * k. |
EllipticE( m ) |
The complete elliptic integral, E(m), of the second kind. |
EllipticF |
The incomplete elliptic integral of the first kind. |
EllipticE(phi, m) |
The incomplete elliptic integral of the second kind. |
EllipJ |
Computes the Jacobi elliptic functions Cn(), Sn(), and Dn() for real arguments. |
Sn |
Computes the Jacobi elliptic function Sn() for complex arguments. |
Cn |
Computes the Jacobi elliptic function Cn() for complex arguments. |
BesselI0 |
Modified Bessel function of the first kind, order zero. |
BesselI1 |
Modified Bessel function of the first kind, first order. |
BesselIv |
Modified Bessel function of the first kind, non-integer order. |
BesselJ0 |
Bessel function of the first kind, order zero. |
BesselJ1 |
Bessel function of the first kind, first order. |
BesselJn |
Bessel function of the first kind, arbitrary integer order. |
BesselJv |
Bessel function of first kind, non-integer order. |
BesselK0 |
Modified Bessel function of the second kind, order zero. |
BesselK1 |
Modified Bessel function of the second kind, order one. |
BesselKn |
Modified Bessel function of the second kind, arbitrary integer order. |
BesselY0 |
Bessel function of the second kind, order zero. |
BesselY1 |
Bessel function of the second kind, order one. |
BesselYn |
Bessel function of the second kind of integer order. |
BesselYv |
Bessel function of the second kind, non-integer order. |
Hypergeometric1F1 |
The confluent hypergeometric series of the first kind. |
Hypergeometric2F1 |
The Gauss or generalized hypergeometric function. |
Let us know if you need any additional special functions and we’ll see if we can add them.
Mathematically,
Paul Shirkey
References
[1] Abramowitz, M. and Stegun, I. (1965). Handbook of Mathematical Functions. Dover Publications. ( Abramowitz and Stegun PDF )
[2] Wolfram Alpha LLC. (2014). www.wolframalpha.com
[3] Weisstein, Eric W. “[Various Articles]” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/
[4] Moshier L. Stephen. (1995) The Cephes Math Library. (Cephes).