Skip to content

HMath.Special

Module index ยท Numerical conventions

Description

Real special functions with checked domains. SFResult reports an estimated absolute truncation/rounding error, never an interval certificate. Series and quadrature have finite work budgets and reject nonconvergence. Complex hypergeometric functions use principal powers and their power-series disk; no unspecified continuation across a branch cut is performed. Equations and normalization: https://dlmf.nist.gov/ (chapters 5--33). The C99 libm gammaerrorBessel entry points are used as platform elementary kernels. They do not change the process error handler or floating-point mode.

On this page

API Purpose
SFResult Finite value and estimated absolute numerical error.
SFResult Declaration and type contract below.
sfValue Returned special-function numerical estimate.
sfError Absolute numerical error estimate accompanying sfValue.
gamma Real gamma using C99 libm; rejects nonfinite arguments and nonpositive integer poles.
logGamma Natural logarithm of gamma for strictly positive finite arguments; avoids overflow of gamma itself.
gammaP Regularized lower incomplete gamma.
gammaQ Regularized upper gamma Q(a,x); the upper-tail continued fraction is evaluated directly when x>=a+1.
incompleteGamma Unregularized lower gamma gamma(a,x)=Gamma(a)*P(a,x).
beta Beta function for strictly positive parameters, evaluated through log gamma.
logBeta Log beta for strictly positive finite parameters.
betaI Regularized lower incomplete beta I_x(a,b), positive parameters and x in [0,1], via reflected Lentz continued fraction.
incompleteBeta Unregularized lower incomplete beta B_x(a,b).
digamma Log-gamma derivative for x>0, using recurrence to x>=12 and an inverse-power asymptotic expansion.
trigamma First polygamma derivative for x>0, using the Hurwitz-zeta identity.
polygamma Derivative order 0..32 of digamma for x>0; higher orders use signed factorial times Hurwitz zeta.
erf Real error function from C99 libm; finite arguments required.
erfc Real complementary error function from C99 libm; upper tails avoid subtracting erf from one.
inverseErf Real inverse error function for -1<x<1, using the normal inverse identity.
erfcx exp(x^2)*erfc(x), with a large-positive-x inverse-power asymptotic expansion to avoid overflow.
normalCDF Standard-normal CDF through erfc, with stable small lower tails.
normalQuantile Standard-normal inverse CDF for 0<p<1.
dawson Dawson integral for |x|<=100; scaled quadrature below |x|=10, inverse-power asymptotics above.
exponentialIntegral E_n(x), integer n=0..100000,x>0.
logarithmicIntegral Real principal-value Ei for x>0; logarithmic integral li(x)=Ei(log x), with the real PV continuation on 0<x<1.
sineIntegral Real Si(x) on |x|<=1000, with its removable singularity explicitly filled at zero.
cosineIntegral Real Ci(x) on 0<x<=1000, using phase-resolved quadrature near zero and inverse-power oscillatory asymptotics above x=50.
fresnel Fresnel (C,S), phase pi*t^2/2, |x|<=100.
ellipticF Legendre incomplete elliptic integrals, parameter m (not modulus k), real branch |phi|<=pi/2, m<1; Pi additionally n<1.
ellipticE Legendre incomplete second-kind elliptic integral with the same amplitude/parameter convention.
ellipticPi Legendre third-kind integral with arguments characteristic n, amplitude phi, parameter m; n<1, m<1, |phi|<=pi/2.
jacobiElliptic Real (sn,cn,dn), |u|<=10^6 and 0<=m<1, using periodic amplitude inversion.
besselJ Integer-order J_n(x) from libm, |n|<=100000 and finite real x.
besselY Integer-order Y_n(x) from libm, |n|<=100000 and x>0.
besselI Modified Bessel I_n(x) via its convergent series, integer order 0..100 and |x|<=700.
besselK Modified Bessel K_n(x)=exp(-x)*scaledBesselK(n,x), integer order 0..100,x>0.
sphericalBesselJ Spherical j_n(x), order 0..100; uses a series for small x relative to order and upward recurrence otherwise.
sphericalBesselY Spherical y_n(x), integer order 0..100,x>0, by upward recurrence.
hankel Complex H_n^(kind)(x)=J_n(x)+/-iY_n(x), kind 1 or 2, integer order and x>0.
airy Airy Ai,Bi and derivatives solve y''=x y by convergent Maclaurin series.
struve Real Struve H_nu(x) by a convergent series; nu>-3/2 and 0<=x<=30.
hypergeometric Generalized pFq power series.
hypergeometric1F1 Kummer confluent hypergeometric 1F1(a;b;z), real power-series evaluation with denominator-pole rejection.
hypergeometric2F1 Gauss 2F1(a,b;c;z) in the real power-series disk |z|<1.
complex1F1 Complex Kummer 1F1 in its entire z plane, rejecting denominator poles and nonfinite arithmetic; cancellation can limit accuracy for large imaginary z.
legendre Legendre P_n(x), n=0..1000 and |x|<=1.
associatedLegendre Associated P_l^m(x) with Condon--Shortley phase, 0<=m<=l<=1000 and |x|<=1.
sphericalHarmonic Orthonormal complex spherical harmonic Y_l^m(theta,phi), theta in [0,pi], including negative-m conjugation symmetry.
riemannZeta Real zeta: Euler--Maclaurin for s>1, Euler-transformed eta for 0<s<1 and reflection for -170<s<0.
hurwitzZeta Hurwitz zeta for s>1,q>0 using 64 explicit terms plus seven Euler--Maclaurin corrections.
polylogarithm Real polylog Li_s(z) in the convergent power-series disk |z|<1; no cross-cut continuation is implied.
dilogarithm Real Li_2(x) for x<=1, with reflection and negative-axis transformations for convergent evaluation.
lambertW Real Lambert W branch 0 or -1, x>=-1/e and x<0 on branch -1, using bounded Halley iteration.
debye Normalized Debye D_n(x), integer n=1..16,x>=0, with D_n(0)=1.
clausen Periodic Clausen Cl_2(theta) from an integral with a squared-variable substitution at its logarithmic endpoint.
fermiDirac Complete normalized Fermi--Dirac integral F_order(eta), 0<=order<=20, |eta|<=100.
boseEinstein Complete normalized Bose--Einstein integral, same order range, -100<=eta<=0 and positive order at eta=0.
coulombWave Regular and irregular Coulomb waves F_l,G_l.
gegenbauer Gegenbauer C_n^alpha(x), degree 0..10000 and alpha>-12, alpha=0, by three-term recurrence.
parabolicCylinder Real D_nu(x) via Kummer's representation; reference |x|<=6, |nu|<=10.
mathieu Mathieu ce_n (even=True) or se_n, from a 32-term Fourier Galerkin eigenproblem. ce(0)=1 or se'(0)=1.
bernoulliPolynomial Exact rational Bernoulli/Euler coefficients evaluated as Double.
eulerPolynomial Euler E_n(x), n=0..100, from the Bernoulli duplication identity.
wigner3j Angular momenta and projections are encoded as doubled integers, allowing half-integers exactly.
wigner6j Racah factorial sum for a Wigner 6j symbol; each angular momentum is a doubled integer in 0..60.
wigner9j Wigner 9j as a finite sum of three 6j symbols; accepts nine row-major doubled angular momenta in 0..30.
clebschGordan Clebsch--Gordan coefficient <j1 m1,j2 m2|j m> through the Condon--Shortley 3j convention; all arguments doubled integers.
scaledBesselI exp(-|x|)*I_n(x).
scaledBesselK exp(x)*K_n(x) from its cosh integral, integer order 0..100,x>0; scaling is inside the integrand.

Documentation

SFResult

data SFResult Source #

Finite value and estimated absolute numerical error. The estimate includes truncation/discretization and a small rounding allowance; it is not a certified enclosure.

Constructors

SFResultย 

Fields

  • sfValue :: Double

    Returned special-function numerical estimate.

  • sfError :: Double

    Absolute numerical error estimate accompanying sfValue.

Instances

Instances details
Show SFResult Source #ย 
Instance details

Defined in HMath.Special

Eq SFResult Source #ย 
Instance details

Defined in HMath.Special

gamma

gamma :: Double -> Either MathError Double Source #

Real gamma using C99 libm; rejects nonfinite arguments and nonpositive integer poles. Overflow is reported as NonFiniteResult.

logGamma

logGamma :: Double -> Either MathError Double Source #

Natural logarithm of gamma for strictly positive finite arguments; avoids overflow of gamma itself.

gammaP

gammaP :: Double -> Double -> Either MathError Double Source #

Regularized lower incomplete gamma. Series below a+1, Lentz continued fraction above; upper tail is evaluated directly instead of subtracting 1.

gammaQ

gammaQ :: Double -> Double -> Either MathError Double Source #

Regularized upper gamma Q(a,x); the upper-tail continued fraction is evaluated directly when x>=a+1.

incompleteGamma

incompleteGamma :: Double -> Double -> Either MathError Double Source #

Unregularized lower gamma gamma(a,x)=Gamma(a)*P(a,x). Overflow is an error.

beta

beta :: Double -> Double -> Either MathError Double Source #

Beta function for strictly positive parameters, evaluated through log gamma.

logBeta

logBeta :: Double -> Double -> Either MathError Double Source #

Log beta for strictly positive finite parameters.

betaI

betaI :: Double -> Double -> Double -> Either MathError Double Source #

Regularized lower incomplete beta I_x(a,b), positive parameters and x in [0,1], via reflected Lentz continued fraction.

incompleteBeta

incompleteBeta :: Double -> Double -> Double -> Either MathError Double Source #

Unregularized lower incomplete beta B_x(a,b).

digamma

digamma :: Double -> Either MathError Double Source #

Log-gamma derivative for x>0, using recurrence to x>=12 and an inverse-power asymptotic expansion.

trigamma

trigamma :: Double -> Either MathError Double Source #

First polygamma derivative for x>0, using the Hurwitz-zeta identity.

polygamma

polygamma :: Int -> Double -> Either MathError Double Source #

Derivative order 0..32 of digamma for x>0; higher orders use signed factorial times Hurwitz zeta.

erf

erf :: Double -> Either MathError Double Source #

Real error function from C99 libm; finite arguments required.

erfc

erfc :: Double -> Either MathError Double Source #

Real complementary error function from C99 libm; upper tails avoid subtracting erf from one.

inverseErf

inverseErf :: Double -> Either MathError Double Source #

Real inverse error function for -1<x<1, using the normal inverse identity.

erfcx

erfcx :: Double -> Either MathError SFResult Source #

exp(x^2)*erfc(x), with a large-positive-x inverse-power asymptotic expansion to avoid overflow.

normalCDF

normalCDF :: Double -> Either MathError Double Source #

Standard-normal CDF through erfc, with stable small lower tails.

normalQuantile

normalQuantile :: Double -> Either MathError Double Source #

Standard-normal inverse CDF for 0<p<1. Symmetry preserves tiny upper-tail probabilities before bounded bisection.

dawson

dawson :: Double -> Either MathError SFResult Source #

Dawson integral for |x|<=100; scaled quadrature below |x|=10, inverse-power asymptotics above.

exponentialIntegral

exponentialIntegral :: Int -> Double -> Either MathError SFResult Source #

E_n(x), integer n=0..100000,x>0. Uses a continued fraction for x>=1, the logarithmic E1 series and stable upward recurrence below one.

logarithmicIntegral

logarithmicIntegral :: Double -> Either MathError SFResult Source #

Real principal-value Ei for x>0; logarithmic integral li(x)=Ei(log x), with the real PV continuation on 0<x<1.

sineIntegral

sineIntegral :: Double -> Either MathError SFResult Source #

Real Si(x) on |x|<=1000, with its removable singularity explicitly filled at zero.

cosineIntegral

cosineIntegral :: Double -> Either MathError SFResult Source #

Real Ci(x) on 0<x<=1000, using phase-resolved quadrature near zero and inverse-power oscillatory asymptotics above x=50.

fresnel

fresnel :: Double -> Either MathError (SFResult, SFResult) Source #

Fresnel (C,S), phase pi*t^2/2, |x|<=100. Phase-sized subintervals prevent oscillatory quadrature aliasing; above |x|=8 inverse-power asymptotics avoid it.

ellipticF

ellipticF :: Double -> Double -> Either MathError SFResult Source #

Legendre incomplete elliptic integrals, parameter m (not modulus k), real branch |phi|<=pi/2, m<1; Pi additionally n<1.

ellipticE

ellipticE :: Double -> Double -> Either MathError SFResult Source #

Legendre incomplete second-kind elliptic integral with the same amplitude/parameter convention.

ellipticPi

ellipticPi :: Double -> Double -> Double -> Either MathError SFResult Source #

Legendre third-kind integral with arguments characteristic n, amplitude phi, parameter m; n<1, m<1, |phi|<=pi/2.

jacobiElliptic

jacobiElliptic :: Double -> Double -> Either MathError (Double, Double, Double) Source #

Real (sn,cn,dn), |u|<=10^6 and 0<=m<1, using periodic amplitude inversion. The complete period uses AGM; the argument cap prevents accumulated period uncertainty from being presented as a resolved large-argument phase.

besselJ

besselJ :: Int -> Double -> Either MathError Double Source #

Integer-order J_n(x) from libm, |n|<=100000 and finite real x.

besselY

besselY :: Int -> Double -> Either MathError Double Source #

Integer-order Y_n(x) from libm, |n|<=100000 and x>0.

besselI

besselI :: Int -> Double -> Either MathError SFResult Source #

Modified Bessel I_n(x) via its convergent series, integer order 0..100 and |x|<=700. Overflow is an error.

besselK

besselK :: Int -> Double -> Either MathError SFResult Source #

Modified Bessel K_n(x)=exp(-x)*scaledBesselK(n,x), integer order 0..100,x>0.

sphericalBesselJ

sphericalBesselJ :: Int -> Double -> Either MathError Double Source #

Spherical j_n(x), order 0..100; uses a series for small x relative to order and upward recurrence otherwise.

sphericalBesselY

sphericalBesselY :: Int -> Double -> Either MathError Double Source #

Spherical y_n(x), integer order 0..100,x>0, by upward recurrence.

hankel

hankel :: Int -> Int -> Double -> Either MathError (Complex Double) Source #

Complex H_n^(kind)(x)=J_n(x)+/-iY_n(x), kind 1 or 2, integer order and x>0.

airy

airy :: Double -> Either MathError (SFResult, SFResult, SFResult, SFResult) Source #

Airy Ai,Bi and derivatives solve y''=x y by convergent Maclaurin series. The bounded real reference domain |x|<=8 avoids severe recessive cancellation.

struve

struve :: Double -> Double -> Either MathError SFResult Source #

Real Struve H_nu(x) by a convergent series; nu>-3/2 and 0<=x<=30.

hypergeometric

hypergeometric :: [Double] -> [Double] -> Double -> Either MathError SFResult Source #

Generalized pFq power series. Requires p<=q or p=q+1 with |z|<1 and no nonpositive-integer denominator parameters; finite budget 10000 terms.

hypergeometric1F1

hypergeometric1F1 :: Double -> Double -> Double -> Either MathError SFResult Source #

Kummer confluent hypergeometric 1F1(a;b;z), real power-series evaluation with denominator-pole rejection.

hypergeometric2F1

hypergeometric2F1 :: Double -> Double -> Double -> Double -> Either MathError SFResult Source #

Gauss 2F1(a,b;c;z) in the real power-series disk |z|<1.

complex1F1

complex1F1 :: Complex Double -> Complex Double -> Complex Double -> Either MathError (Complex Double) Source #

Complex Kummer 1F1 in its entire z plane, rejecting denominator poles and nonfinite arithmetic; cancellation can limit accuracy for large imaginary z.

legendre

legendre :: Int -> Double -> Either MathError Double Source #

Legendre P_n(x), n=0..1000 and |x|<=1.

associatedLegendre

associatedLegendre :: Int -> Int -> Double -> Either MathError Double Source #

Associated P_l^m(x) with Condon--Shortley phase, 0<=m<=l<=1000 and |x|<=1.

sphericalHarmonic

sphericalHarmonic :: Int -> Int -> Double -> Double -> Either MathError (Complex Double) Source #

Orthonormal complex spherical harmonic Y_l^m(theta,phi), theta in [0,pi], including negative-m conjugation symmetry.

riemannZeta

riemannZeta :: Double -> Either MathError SFResult Source #

Real zeta: Euler--Maclaurin for s>1, Euler-transformed eta for 0<s<1 and reflection for -170<s<0. The pole s=1 is rejected.

hurwitzZeta

hurwitzZeta :: Double -> Double -> Either MathError SFResult Source #

Hurwitz zeta for s>1,q>0 using 64 explicit terms plus seven Euler--Maclaurin corrections.

polylogarithm

polylogarithm :: Double -> Double -> Either MathError SFResult Source #

Real polylog Li_s(z) in the convergent power-series disk |z|<1; no cross-cut continuation is implied.

dilogarithm

dilogarithm :: Double -> Either MathError SFResult Source #

Real Li_2(x) for x<=1, with reflection and negative-axis transformations for convergent evaluation.

lambertW

lambertW :: Int -> Double -> Either MathError SFResult Source #

Real Lambert W branch 0 or -1, x>=-1/e and x<0 on branch -1, using bounded Halley iteration.

debye

debye :: Int -> Double -> Either MathError SFResult Source #

Normalized Debye D_n(x), integer n=1..16,x>=0, with D_n(0)=1. At large x the complete Bose integral supplies the asymptote and an exponentially small omitted-tail estimate; logarithmic scaling avoids x^n overflow.

clausen

clausen :: Double -> Either MathError SFResult Source #

Periodic Clausen Cl_2(theta) from an integral with a squared-variable substitution at its logarithmic endpoint.

fermiDirac

fermiDirac :: Double -> Double -> Either MathError SFResult Source #

Complete normalized Fermi--Dirac integral F_order(eta), 0<=order<=20, |eta|<=100.

boseEinstein

boseEinstein :: Double -> Double -> Either MathError SFResult Source #

Complete normalized Bose--Einstein integral, same order range, -100<=eta<=0 and positive order at eta=0.

coulombWave

coulombWave :: Int -> Double -> Double -> Either MathError (SFResult, SFResult) Source #

Regular and irregular Coulomb waves F_l,G_l. The regular function follows the convergent hypergeometric representation. G is integrated backwards from a first-order asymptotic boundary at R>=300 using RK4; its error estimate includes the omitted O((l(l+1)+eta^2)/R) term. Real reference domain l<=8, |eta|<=3, 0.5<=rho<=30. This is deliberately not a high-accuracy scattering solver.

gegenbauer

gegenbauer :: Int -> Double -> Double -> Either MathError Double Source #

Gegenbauer C_n^alpha(x), degree 0..10000 and alpha>-12, alpha=0, by three-term recurrence.

parabolicCylinder

parabolicCylinder :: Double -> Double -> Either MathError SFResult Source #

Real D_nu(x) via Kummer's representation; reference |x|<=6, |nu|<=10.

mathieu

mathieu :: Bool -> Int -> Double -> Double -> Either MathError (Double, SFResult) Source #

Mathieu ce_n (even=True) or se_n, from a 32-term Fourier Galerkin eigenproblem. ce(0)=1 or se'(0)=1. Error estimates the last coefficient; reference 0<=n<=12, |q|<=10, any real x. Characteristic value is returned.

bernoulliPolynomial

bernoulliPolynomial :: Int -> Double -> Either MathError Double Source #

Exact rational Bernoulli/Euler coefficients evaluated as Double. Bernoulli B1=-12; Euler E_n(x) defined by 2 exp(xt)(exp t+1).

eulerPolynomial

eulerPolynomial :: Int -> Double -> Either MathError Double Source #

Euler E_n(x), n=0..100, from the Bernoulli duplication identity.

wigner3j

wigner3j :: Int -> Int -> Int -> Int -> Int -> Int -> Either MathError Double Source #

Angular momenta and projections are encoded as doubled integers, allowing half-integers exactly. Factorial Racah sums have j<=30 and return selection rule zeros rather than factorials of negative arguments.

wigner6j

wigner6j :: Int -> Int -> Int -> Int -> Int -> Int -> Either MathError Double Source #

Racah factorial sum for a Wigner 6j symbol; each angular momentum is a doubled integer in 0..60.

wigner9j

wigner9j :: [Int] -> Either MathError Double Source #

Wigner 9j as a finite sum of three 6j symbols; accepts nine row-major doubled angular momenta in 0..30.

clebschGordan

clebschGordan :: Int -> Int -> Int -> Int -> Int -> Int -> Either MathError Double Source #

Clebsch--Gordan coefficient <j1 m1,j2 m2|j m> through the Condon--Shortley 3j convention; all arguments doubled integers.

scaledBesselI

scaledBesselI :: Int -> Double -> Either MathError SFResult Source #

exp(-|x|)*I_n(x). Uses the power series for |x|<=50 and asymptotics when n<=20 and |x|>n^2.

scaledBesselK

scaledBesselK :: Int -> Double -> Either MathError SFResult Source #

exp(x)*K_n(x) from its cosh integral, integer order 0..100,x>0; scaling is inside the integrand.