abax 0.1.20

A lightweight Rust library providing high-precision mathematical constants and special functions, including Bernoulli numbers, Riemann Zeta values, and robust incomplete gamma functions.
Documentation

abax

A lightweight Rust library providing high-precision mathematical constants and special functions.

Features

  • Mathematical Constants:
    • Bernoulli numbers (B2n) up to n=16.
    • Riemann Zeta function values for integers 2 through 16.
    • Euler-Mascheroni constant.
    • Stirling series coefficients for asymptotic expansions.
  • Special Functions:
    • erf(x): Error function erf(x)=2π0xe-t2dt, implemented with piecewise 53-bit rational approximations for accurate f64 results.
    • erfc(x): Complementary error function erfc(x)=1-erf(x)=2πxe-t2dt, evaluated directly in tail regions to avoid cancellation.
    • erfcx(x): Scaled complementary error function erfcx(x)=ex2erfc(x), implemented with Laplace's continued fraction and reflection formula for numerical stability across all x.
    • erfinv(x): Inverse error function implemented with piecewise rational approximations for f64 inputs in [-1, 1].
    • erfcinv(x): Inverse complementary error function implemented with piecewise rational approximations for f64 inputs in [0, 2].
    • gamma(x): Gamma function Γ(x) computed with the Lanczos approximation and reflection formula.
    • beta(z, w): Beta function B(z,w)=Γ(z)Γ(w)Γ(z+w), implemented using the logarithmic Gamma function for numerical stability.
    • betainc(x, z, w, lower): Regularized incomplete beta function Ix(z,w)=1B(z,w)0xtz-1(1-t)w-1dt; returns upper tail when lower=false.
    • betaincinv(y, z, w, lower): Inverse of the regularized incomplete beta function; returns x such that betainc(x, z, w, lower) = y.
    • betaln(z, w): Natural logarithm of the Beta function ln(B(z,w)), computed using logarithmic Gamma functions.
    • gammaln(x): Natural logarithm of the Gamma function ln(Γ(x)) using Stirling's approximation for high precision.
    • digamma(x): Digamma function ψ(x), the logarithmic derivative of Γ(x), implemented with reflection, recurrence shifting, and asymptotic expansion for numerical stability.
    • trigamma(x): Trigamma function ψ(1)(x), implemented with reflection, recurrence shifting, and asymptotic expansion for numerical stability.
    • tetragamma(x): Tetragamma function ψ(2)(x), implemented with reflection, recurrence shifting, and asymptotic expansion for numerical stability.
    • gammainc(x, a, lower, scaled): Regularized lower/upper incomplete gamma function with explicit lower/upper tail selection; when scaled=true, returns tail value multiplied by Γ(a+1)exx-a for improved conditioning at large x.
    • normcdf(x, mu, sigma): Normal cumulative distribution function.
    • normpdf(x, mu, sigma): Normal probability density function.
    • norminv(p, mu, sigma): Inverse of the normal cumulative distribution function (quantile function).
    • gammaincinv(y, a, lower): Numerically robust inverse of the regularized incomplete gamma function utilizing a combined Halley-Newton-Bisection method for enhanced convergence speed and stability in tail regions.
    • psi(k, x): Polygamma interface returning ψ(k)(x) with stable handling of poles and infinities.

Usage

Add this to your Cargo.toml:

[dependencies]
abax = "0.1.20"

License

This project is licensed under the MIT License - see the LICENSE file for details.

Repository

Source code is available on GitHub.