Skip to main content

Module special

Module special 

Source
Expand description

Special mathematical functions: gamma, ln_gamma, digamma, erf, erfc, bessel_j0, plus Euler-Mascheroni and Catalan constants. Special mathematical functions for arbitrary-precision floating-point.

Provides pure-Rust implementations of:

  • gamma — Gamma function Γ(x)
  • ln_gamma — log-Gamma function ln(Γ(x))
  • digamma — Digamma function ψ(x) = d/dx ln(Γ(x))
  • erf — Error function
  • erfc — Complementary error function
  • bessel_j0 — Bessel function J₀(x)
  • euler_gamma — Euler–Mascheroni constant γ
  • catalan — Catalan’s constant G
  • free_cache — No-op (MPFR compatibility shim)

All functions work on DBig (decimal arbitrary-precision big float) and accept a precision parameter giving the number of significant decimal digits to carry through the computation.

§Algorithms

  • Gamma / log-Gamma: Lanczos approximation (g=7, 9 coefficients) for x ∈ (0, 20]; Stirling series for x > 20; reflection formula for x < 0.
  • Digamma: recurrence to shift x > 8, then Bernoulli asymptotic series.
  • Erf: Taylor series for |x| ≤ 2; asymptotic continued-fraction for |x| > 2.
  • Erfc: complement of erf with careful sign handling.
  • Bessel J₀: power series for |x| ≤ 12; asymptotic expansion for |x| > 12.
  • Euler γ: pre-stored 200-digit decimal string.
  • Catalan G: pre-stored 200-digit decimal string.

Functions§

bessel_j0
Compute the Bessel function J₀(x) to precision significant decimal digits.
catalan
Compute Catalan’s constant G ≈ 0.9159655941… to precision significant decimal digits (capped at 200).
digamma
Compute the digamma function ψ(x) = d/dx ln(Γ(x)) to precision significant decimal digits.
erf
Compute erf(x) to precision significant decimal digits.
erfc
Compute erfc(x) = 1 - erf(x) to precision significant decimal digits.
euler_gamma
Compute the Euler–Mascheroni constant γ ≈ 0.5772156649… to precision significant decimal digits (capped at 200).
free_cache
No-op cache cleanup shim.
gamma
Compute the Gamma function Γ(x) to precision significant decimal digits.
ln_gamma
Compute ln(Γ(x)) to precision significant decimal digits.