Special | Science @ Science @ MentDB Weak
Special functions
• Special functions of the mathematical expressions: math eval, math calc, num (solve, integrate, derivative...), stat fit_model, plot function, math diff.
• Bessel (J, Y, I, K, spherical), orthogonal polynomials (Legendre, Hermite, Laguerre, Chebyshev), gamma family, incomplete gamma and beta, error function, Riemann zeta.
• The results agree with SciPy (scipy.special) to about 1e-13; the derivatives with respect to the variable are exact (automatic differentiation).
• Bessel (J, Y, I, K, spherical), orthogonal polynomials (Legendre, Hermite, Laguerre, Chebyshev), gamma family, incomplete gamma and beta, error function, Riemann zeta.
• The results agree with SciPy (scipy.special) to about 1e-13; the derivatives with respect to the variable are exact (automatic differentiation).
bessel_j(nu, x)bessel_y(nu, x)bessel_i(nu, x)bessel_k(nu, x)sph_bessel_j(n, x)sph_bessel_y(n, x)legendre(n, x)assoc_legendre(n, m, x)hermite(n, x)laguerre(n, x)chebyshev_t(n, x)chebyshev_u(n, x)gamma(x)lgamma(x)digamma(x)polygamma(n, x)beta(a, b)gamma_inc(a, x)beta_inc(a, b, x)erf(x)zeta(s)
bessel_j(nu, x)
Description
Bessel function of the first kind J_nu(x), real order nu (x < 0 only for an integer order).
Derivatives (num derivative, math diff...) with respect to x; the order is a constant.
Bessel function of the first kind J_nu(x), real order nu (x < 0 only for an integer order).
Derivatives (num derivative, math diff...) with respect to x; the order is a constant.
Parameters
nu: The order (real) - Number - required
x: The argument - Number - required
nu: The order (real) - Number - required
x: The argument - Number - required
Examples (9)
admin
math eval "bessel_j(0, 1)"
mentdb
0.7651976865579666
admin
math eval "bessel_j(1.5, 2)"
mentdb
0.49129377868716234
Half integer order: J_1/2(x) = sqrt(2/(pi x)) sin(x)
admin
math eval "bessel_j(0.5, 2)"
mentdb
0.5130161365618278
Vibration modes of a drum: first zero of J1
admin
num solve "bessel_j(1, x)" "x" 3 4.5
mentdb
3.831705970207512
Derivative: J0'(x) = -J1(x)
admin
math diff "bessel_j(0, x)" "x"
mentdb
-bessel_j(1, x)
J0 at 0 = 1
admin
math eval "bessel_j(0, 0)"
mentdb
1
Negative integer order: J-1(x) = -J1(x)
admin
math eval "bessel_j(-1, 2)"
mentdb
-0.5767248077568736
Large x
admin
math eval "bessel_j(0, 100)"
mentdb
0.01998585030422313
Table of J1 on [0, 10]
admin
num table "bessel_j(1, x)" "x" 0 10 2.5
mentdb
[ [0,0], [2.5,0.49709410246427416], [5,-0.32757913759146506], [7.5,0.13524842757970565], [10,0.04347274616886133] ]
bessel_y(nu, x)
Description
Bessel function of the second kind Y_nu(x) (Neumann), real order nu, x > 0.
Bessel function of the second kind Y_nu(x) (Neumann), real order nu, x > 0.
Parameters
nu: The order (real) - Number - required
x: The argument (> 0) - Number - required
nu: The order (real) - Number - required
x: The argument (> 0) - Number - required
Examples (6)
admin
math eval "bessel_y(0, 1)"
mentdb
0.08825696421567694
admin
math eval "bessel_y(2.5, 3)"
mentdb
-0.3690407300737977
Order 1
admin
math eval "bessel_y(1, 2.5)"
mentdb
0.1459181379667862
Y0 near 0 goes to -infinity
admin
math eval "bessel_y(0, 0.01)"
mentdb
-3.005455637083646
First zero of Y0
admin
num solve "bessel_y(0, x)" "x" 0.5 1.5
mentdb
0.8935769662791675
Recurrence: Y2 = 2 Y1 / x - Y0
admin
math eval "2*bessel_y(1, 3)/3-bessel_y(0, 3)"
mentdb
-0.16040039348492413
bessel_i(nu, x)
Description
Modified Bessel function of the first kind I_nu(x), real order nu.
Modified Bessel function of the first kind I_nu(x), real order nu.
Parameters
nu: The order (real) - Number - required
x: The argument - Number - required
nu: The order (real) - Number - required
x: The argument - Number - required
Examples (6)
admin
math eval "bessel_i(0, 1)"
mentdb
1.2660658777520082
admin
math eval "bessel_i(1, 10)"
mentdb
2670.9883037012564
Order 2
admin
math eval "bessel_i(2, 3)"
mentdb
2.2452124409299516
I0 at 0 = 1
admin
math eval "bessel_i(0, 0)"
mentdb
1
Decimal order
admin
math eval "bessel_i(0.5, 1)"
mentdb
0.9376748882454877
Large x: exponential growth
admin
math eval "bessel_i(0, 50)"
mentdb
2.9325537838493368E20
bessel_k(nu, x)
Description
Modified Bessel function of the second kind K_nu(x) (Macdonald), real order nu, x > 0.
Modified Bessel function of the second kind K_nu(x) (Macdonald), real order nu, x > 0.
Parameters
nu: The order (real) - Number - required
x: The argument (> 0) - Number - required
nu: The order (real) - Number - required
x: The argument (> 0) - Number - required
Examples (5)
K0 at 1
admin
math eval "bessel_k(0, 1)"
mentdb
0.4210244382405724
admin
math eval "bessel_k(0.5, 2)"
mentdb
0.11993777196806142
Large x: exponential decrease
admin
math eval "bessel_k(1, 10)"
mentdb
1.8648773453825592E-5
Symmetry in the order: K-nu = Knu
admin
math eval "bessel_k(-1, 2)-bessel_k(1, 2)"
mentdb
0
Near 0: large
admin
math eval "bessel_k(1, 0.01)"
mentdb
99.97389411829624
sph_bessel_j(n, x)
Description
Spherical Bessel function of the first kind j_n(x) = sqrt(pi/(2x)) J_(n+1/2)(x), integer n >= 0.
Spherical Bessel function of the first kind j_n(x) = sqrt(pi/(2x)) J_(n+1/2)(x), integer n >= 0.
Parameters
n: The order (integer >= 0) - Number - required
x: The argument - Number - required
n: The order (integer >= 0) - Number - required
x: The argument - Number - required
Examples (6)
admin
math eval "sph_bessel_j(0, 1)"
mentdb
0.8414709848078964
admin
math eval "sph_bessel_j(2, 5)"
mentdb
0.13473121008512512
j_1(x)
admin
math eval "sph_bessel_j(1, 2)"
mentdb
0.4353977749799916
j0(x) = sin(x)/x
admin
math eval "sph_bessel_j(0, 2)-sin(2)/2"
mentdb
-5.551115123125783E-17
Order 3
admin
math eval "sph_bessel_j(3, 4)"
mentdb
0.22924385795503027
Small x
admin
math eval "sph_bessel_j(1, 0.001)"
mentdb
3.333333000000017E-4
sph_bessel_y(n, x)
Description
Spherical Bessel function of the second kind y_n(x), integer n >= 0, x != 0.
Spherical Bessel function of the second kind y_n(x), integer n >= 0, x != 0.
Parameters
n: The order (integer >= 0) - Number - required
x: The argument - Number - required
n: The order (integer >= 0) - Number - required
x: The argument - Number - required
Examples (4)
admin
math eval "sph_bessel_y(0, 1)"
mentdb
-0.5403023058681398
admin
math eval "sph_bessel_y(1, 3)"
mentdb
0.06295916360231599
y0(x) = -cos(x)/x
admin
math eval "sph_bessel_y(0, 2)+cos(2)/2"
mentdb
0
Order 2
admin
math eval "sph_bessel_y(2, 4)"
mentdb
0.009129107382315343
legendre(n, x)
Description
Legendre polynomial P_n(x), integer n >= 0.
Legendre polynomial P_n(x), integer n >= 0.
Parameters
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
Examples (7)
admin
math eval "legendre(2, 0.5)"
mentdb
-0.125
admin
math eval "legendre(5, 0.3)"
mentdb
0.34538625
Integral of P2 * P2 on [-1, 1] = 2/5 (orthogonality)
admin
num integrate "legendre(2, x)^2" "x" -1 1
mentdb
0.4
Integral of P2 * P3 on [-1, 1] = 0
admin
num integrate "legendre(2, x)*legendre(3, x)" "x" -1 1
mentdb
0
P_n(1) = 1
admin
math eval "legendre(7, 1)"
mentdb
1
P_n(-1) = (-1)^n
admin
math eval "legendre(3, -1)"
mentdb
-1
Roots of P3 (Gauss points)
admin
num solve "legendre(3, x)" "x" 0.5 1
mentdb
0.7745966692414834
assoc_legendre(n, m, x)
Description
Associated Legendre function P_n^m(x) with the Condon-Shortley phase (as scipy.special.lpmv(m, n, x)), integers |m| <= n, -1 <= x <= 1.
Associated Legendre function P_n^m(x) with the Condon-Shortley phase (as scipy.special.lpmv(m, n, x)), integers |m| <= n, -1 <= x <= 1.
Parameters
n: The degree (integer >= 0) - Number - required
m: The order (integer, |m| <= n) - Number - required
x: The argument in [-1, 1] - Number - required
n: The degree (integer >= 0) - Number - required
m: The order (integer, |m| <= n) - Number - required
x: The argument in [-1, 1] - Number - required
Examples (5)
admin
math eval "assoc_legendre(2, 1, 0.5)"
mentdb
-1.299038105676658
admin
math eval "assoc_legendre(3, 2, 0.3)"
mentdb
4.095000000000001
m = 0: the Legendre polynomial
admin
math eval "assoc_legendre(2, 0, 0.5)-legendre(2, 0.5)"
mentdb
0
m > n: 0
admin
math eval "assoc_legendre(1, 2, 0.5)"
mentdb
0
Spherical harmonic part: P1,1(cos 60 degrees)
admin
math eval "assoc_legendre(1, 1, cos(60))" "{\"_angle\": \"deg\"}"
mentdb
-0.8660254037844386
hermite(n, x)
Description
Hermite polynomial H_n(x) of the physicists (H_1 = 2x), integer n >= 0.
Hermite polynomial H_n(x) of the physicists (H_1 = 2x), integer n >= 0.
Parameters
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
Examples (6)
admin
math eval "hermite(3, 2)"
mentdb
40
admin
math eval "hermite(4, 0.5)"
mentdb
1
Quantum harmonic oscillator: H3(x) e^(-x^2/2)
admin
math eval "hermite(3, x)*exp(-x^2/2)" "{\"x\": 1}"
mentdb
-2.4261226388505337
H0 = 1, H1 = 2x
admin
math eval "hermite(1, 3)"
mentdb
6
Large order
admin
math eval "hermite(10, 1)"
mentdb
8224
Orthogonality with the weight exp(-x^2)
admin
num integrate "hermite(2, x)*hermite(3, x)*exp(-x^2)" "x" -10 10
mentdb
0
laguerre(n, x)
Description
Laguerre polynomial L_n(x), integer n >= 0.
Laguerre polynomial L_n(x), integer n >= 0.
Parameters
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
Examples (5)
admin
math eval "laguerre(2, 1)"
mentdb
-0.5
admin
math eval "laguerre(3, 2.5)"
mentdb
0.2708333333333333
L_n(0) = 1
admin
math eval "laguerre(5, 0)"
mentdb
1
Hydrogen atom: radial part L1(r)
admin
math eval "laguerre(1, 2)"
mentdb
-1
Orthogonality with the weight exp(-x)
admin
num integrate "laguerre(1, x)*laguerre(2, x)*exp(-x)" "x" 0 100
mentdb
-2.0816681711721685E-17
chebyshev_t(n, x)
Description
Chebyshev polynomial of the first kind T_n(x), integer n >= 0.
Chebyshev polynomial of the first kind T_n(x), integer n >= 0.
Parameters
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
Examples (5)
admin
math eval "chebyshev_t(3, 0.5)"
mentdb
-1
admin
math eval "chebyshev_t(4, 0.3)"
mentdb
0.34480000000000005
T_n(cos t) = cos(n t)
admin
math eval "chebyshev_t(5, cos(0.3))-cos(1.5)"
mentdb
-8.743006318923108E-16
T_n(1) = 1
admin
math eval "chebyshev_t(8, 1)"
mentdb
1
Outside [-1, 1]
admin
math eval "chebyshev_t(3, 2)"
mentdb
26
chebyshev_u(n, x)
Description
Chebyshev polynomial of the second kind U_n(x), integer n >= 0.
Chebyshev polynomial of the second kind U_n(x), integer n >= 0.
Parameters
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
n: The degree (integer >= 0) - Number - required
x: The argument - Number - required
Examples (4)
admin
math eval "chebyshev_u(3, 0.5)"
mentdb
-1
admin
math eval "chebyshev_u(2, 2)"
mentdb
15
U_n(1) = n + 1
admin
math eval "chebyshev_u(4, 1)"
mentdb
5
Recurrence U2 = 2x U1 - U0
admin
math eval "2*0.3*chebyshev_u(1, 0.3)-chebyshev_u(0, 0.3)-chebyshev_u(2, 0.3)"
mentdb
0
gamma(x)
Description
Gamma function (x! = gamma(x+1)); negative non-integer x allowed.
Gamma function (x! = gamma(x+1)); negative non-integer x allowed.
Parameters
x: The argument - Number - required
x: The argument - Number - required
Examples (8)
admin
math eval "gamma(5)"
mentdb
24
admin
math eval "gamma(0.5)"
mentdb
1.772453850905516
Negative non-integer argument
admin
math eval "gamma(-1.5)"
mentdb
2.3632718012073544
Factorial of a large number: 20! = gamma(21)
admin
math eval "gamma(21)"
mentdb
2.43290200817664E18
gamma(1) = gamma(2) = 1
admin
math eval "gamma(1)+gamma(2)"
mentdb
2
Large values (above 170: infinity)
admin
math eval "gamma(170)"
mentdb
4.2690680090047027E304
Reflection formula: gamma(x) gamma(1-x) = pi / sin(pi x)
admin
math eval "gamma(0.3)*gamma(0.7)-pi/sin(0.3*pi)"
mentdb
8.881784197001252E-16
Volume of the unit ball in 4 dimensions
admin
math eval "pi^2/gamma(3)"
mentdb
4.934802200544679
lgamma(x)
Description
Logarithm of the absolute value of the gamma function, without overflow (lgamma(1000)).
Logarithm of the absolute value of the gamma function, without overflow (lgamma(1000)).
Parameters
x: The argument - Number - required
x: The argument - Number - required
Examples (5)
admin
math eval "lgamma(1000)"
mentdb
5905.220423209182
admin
math eval "lgamma(0.5)"
mentdb
0.5723649429247001
ln(gamma(10)) = ln(9!)
admin
math eval "lgamma(10)"
mentdb
12.801827480081469
Large x: no overflow
admin
math eval "lgamma(1e6)"
mentdb
1.2815504569147611E7
Binomial coefficient C(200, 100) with logarithms
admin
math eval "exp(lgamma(201)-2*lgamma(101))"
mentdb
9.054851465611304E58
digamma(x)
Description
Digamma function psi(x) = gamma'(x)/gamma(x).
Digamma function psi(x) = gamma'(x)/gamma(x).
Parameters
x: The argument - Number - required
x: The argument - Number - required
Examples (5)
admin
math eval "digamma(1)"
mentdb
-0.5772156649015325
admin
math eval "digamma(0.5)"
mentdb
-1.9635100260214227
digamma(1) = -Euler gamma
admin
math eval "-digamma(1)"
mentdb
0.5772156649015325
Recurrence: digamma(x+1) = digamma(x) + 1/x
admin
math eval "digamma(3.5)-digamma(2.5)-1/2.5"
mentdb
0
Large x: ln(x)
admin
math eval "digamma(1000)"
mentdb
6.907255195648812
polygamma(n, x)
Description
Polygamma function psi^(n)(x), n-th derivative of digamma (polygamma(1, x) = trigamma).
Polygamma function psi^(n)(x), n-th derivative of digamma (polygamma(1, x) = trigamma).
Parameters
n: The order (integer >= 0) - Number - required
x: The argument - Number - required
n: The order (integer >= 0) - Number - required
x: The argument - Number - required
Examples (5)
admin
math eval "polygamma(1, 1)"
mentdb
1.6449340668482266
admin
math eval "polygamma(2, 3)"
mentdb
-0.1541138063191886
polygamma(0, x) = digamma(x)
admin
math eval "polygamma(0, 2)-digamma(2)"
mentdb
0
Trigamma at 1 = pi^2/6
admin
math eval "polygamma(1, 1)-pi^2/6"
mentdb
2.220446049250313E-16
Order 3
admin
math eval "polygamma(3, 1)"
mentdb
6.493939402266829
beta(a, b)
Description
Beta function B(a, b) = gamma(a) gamma(b) / gamma(a+b).
Beta function B(a, b) = gamma(a) gamma(b) / gamma(a+b).
Parameters
a: First argument - Number - required
b: Second argument - Number - required
a: First argument - Number - required
b: Second argument - Number - required
Examples (6)
admin
math eval "beta(2, 3)"
mentdb
0.08333333333333333
admin
math eval "beta(0.5, 0.5)"
mentdb
3.141592653589794
B(a, b) = gamma(a) gamma(b) / gamma(a+b)
admin
math eval "beta(2.5, 1.5)"
mentdb
0.1963495408493621
B(1, 1) = 1
admin
math eval "beta(1, 1)"
mentdb
1
Integral form: integral of t^(a-1) (1-t)^(b-1)
admin
num integrate "t*(1-t)^2" "t" 0 1
mentdb
0.08333333333333333
Large parameters
admin
math eval "beta(100, 200)"
mentdb
3.6072854497946974E-84
gamma_inc(a, x)
Description
Regularized lower incomplete gamma function P(a, x) (cumulative distribution of the gamma law); gamma_incc(a, x) = 1 - P(a, x) is the upper one.
Regularized lower incomplete gamma function P(a, x) (cumulative distribution of the gamma law); gamma_incc(a, x) = 1 - P(a, x) is the upper one.
Parameters
a: The shape (> 0) - Number - required
x: The argument (>= 0) - Number - required
a: The shape (> 0) - Number - required
x: The argument (>= 0) - Number - required
Examples (6)
admin
math eval "gamma_inc(2, 1)"
mentdb
0.2642411176571153
admin
math eval "gamma_incc(2, 1)"
mentdb
0.7357588823428847
Chi-square cdf with k = 4 at x = 3: P(2, 1.5)
admin
math eval "gamma_inc(2, 1.5)"
mentdb
0.44217459962892536
P(a, x) + Q(a, x) = 1
admin
math eval "gamma_inc(3, 2)+gamma_incc(3, 2)"
mentdb
1
Chi-square law: P(chi2_k <= x) = P(k/2, x/2), k = 3, x = 7.815
admin
math eval "gamma_inc(1.5, 3.9075)"
mentdb
0.9500060970251162
Poisson law: P(N < 3) for a mean 2 = Q(3, 2)
admin
math eval "gamma_incc(3, 2)"
mentdb
0.6766764161830634
beta_inc(a, b, x)
Description
Regularized incomplete beta function I_x(a, b), 0 <= x <= 1 (cumulative distribution of the beta law).
Regularized incomplete beta function I_x(a, b), 0 <= x <= 1 (cumulative distribution of the beta law).
Parameters
a: First shape (> 0) - Number - required
b: Second shape (> 0) - Number - required
x: The argument in [0, 1] - Number - required
a: First shape (> 0) - Number - required
b: Second shape (> 0) - Number - required
x: The argument in [0, 1] - Number - required
Examples (5)
admin
math eval "beta_inc(2, 3, 0.4)"
mentdb
0.5248000000000003
admin
math eval "beta_inc(0.5, 0.5, 0.25)"
mentdb
0.3333333333333333
I_x(1, 1) = x
admin
math eval "beta_inc(1, 1, 0.3)"
mentdb
0.3
Symmetry: I_x(a, b) = 1 - I_(1-x)(b, a)
admin
math eval "beta_inc(2, 5, 0.3)+beta_inc(5, 2, 0.7)"
mentdb
1
Binomial law: P(X >= 3), n = 10, p = 0.2
admin
math eval "beta_inc(3, 8, 0.2)"
mentdb
0.32220047360000015
erf(x)
Description
Error function erf(x); erfc(x) = 1 - erf(x) without cancellation; erf_inv(y) is the inverse function.
Error function erf(x); erfc(x) = 1 - erf(x) without cancellation; erf_inv(y) is the inverse function.
Parameters
x: The argument - Number - required
x: The argument - Number - required
Examples (7)
admin
math eval "erf(1)"
mentdb
0.8427007929497151
Inverse
admin
math eval "erf_inv(0.5)"
mentdb
0.4769362762044698
Complementary error function
admin
math eval "erfc(2)"
mentdb
0.00467773498104726
erf(0) = 0
admin
math eval "erf(0)"
mentdb
0
Normal law: P(|Z| < 2)
admin
math eval "erf(2/sqrt(2))"
mentdb
0.9544997361036417
erfc for the small tails
admin
math eval "erfc(5)"
mentdb
1.5374597944280333E-12
erf_inv(erf(x)) = x
admin
math eval "erf_inv(erf(0.7))"
mentdb
0.6999999999999962
zeta(s)
Description
Riemann zeta function, real s != 1 (zeta(2) = pi^2/6, zeta(-1) = -1/12).
Riemann zeta function, real s != 1 (zeta(2) = pi^2/6, zeta(-1) = -1/12).
Parameters
s: The argument (real, not 1) - Number - required
s: The argument (real, not 1) - Number - required
Examples (8)
admin
math eval "zeta(2)"
mentdb
1.6449340668482264
admin
math eval "zeta(-1)"
mentdb
-0.08333333333333333
zeta(4) = pi^4/90
admin
math eval "zeta(4)"
mentdb
1.0823232337111384
Apery constant zeta(3)
admin
math eval "zeta(3)"
mentdb
1.2020569031595942
zeta(0) = -1/2
admin
math eval "zeta(0)"
mentdb
-0.5
Pole at s = 1
admin
math eval "zeta(1)"
mentdb
NaN
Trivial zeros at -2, -4...
admin
math eval "zeta(-2)"
mentdb
0
Large s: 1
admin
math eval "zeta(50)"
mentdb
1.0000000000000009
