Shunyaya Symbolic Mathematics — Special functions I — gamma & beta (2.41)

Abstract
We lift the gamma and beta functions to symbolic numerals (m, a) as magnitude maps with alignment carry. We give domains/guards, collapse checks, log-space numerics, and asymptotics. For the bivariate beta function we attach an alignment tag via a reproducible rapidity-mean; under collapse phi(m,a) = m, all results reduce to the classical functions.


Definitions and domains (principal real branch)

Gamma (unary lift).

Gamma*(m, a) = ( Gamma(m) , a )

  • Integral definition (real): Gamma(m) = ∫_0^inf t^{m-1} e^{-t} dt for m > 0.
  • Analytic continuation: real principal branch to R \ {0,-1,-2,...} with simple poles at nonpositive integers (not used by default on the real line).

Beta (bivariate lift).

B*((x, a_x), (y, a_y)) = ( B(x, y) , a_B )
B(x,y) = ∫_0^1 t^{x-1} (1 - t)^{y-1} dt = Gamma(x)Gamma(y)/Gamma(x+y)   for x>0, y>0

  • Alignment tag (default summary): u_x = atanh(a_x), u_y = atanh(a_y) a_B = tanh( (u_x + u_y)/2 ) # equal-weights rapidity mean (You may refine weights as in 2.44; declare in the manifest.)

Collapse checks.

phi( Gamma*(m,a) ) = Gamma(m)
phi( B*((x,a_x),(y,a_y)) ) = B(x,y)

Guards (manifest).

gamma_domain_guard = "m>0" (default) | "principal_extension" | "error" | "nan"
beta_domain_guard  = "x>0&y>0" (default) | "error" | "nan"


Ordering, monotonicity, convexity

  • Gamma. log Gamma is convex on (0, inf); Gamma decreases on (0, m*) and increases on (m*, inf), where m* ≈ 1.4616 is the unique minimizer (solve psi(m)=0, with psi the digamma). Make order claims branchwise on intervals where Gamma is monotone.
  • Beta. For x>0, y>0, ∂/∂x log B(x,y) = psi(x) - psi(x+y) < 0 (psi increasing) ∂/∂y log B(x,y) = psi(y) - psi(x+y) < 0 Hence B(x,y) is strictly decreasing in each argument, holding the other fixed.

Asymptotics and special values

  • Stirling (for large m): log Gamma(m) = (m - 1/2) * log m - m + (1/2) * log(2*pi) + O(1/m)
  • Half-integer: Gamma(1/2) = sqrt(pi), Gamma(n + 1) = n! for n in N
  • Beta via gamma: B(x,y) = Gamma(x)Gamma(y)/Gamma(x+y)
  • Near poles (principal extension): Gamma(m) has simple poles at m = 0, -1, -2, ...; default policy is to error rather than extend across poles on the real line.

Log-space numerics (recommended)

Avoid overflow/underflow by computing in log-space:

lgamma(m) = log Gamma(m)
betaln(x,y) = lgamma(x) + lgamma(y) - lgamma(x+y)
B(x,y) = exp( betaln(x,y) )    # only if within safe range

Manifest knobs.

report_mode_gamma = "value" | "log_value"     # default: "value", fall back if overflow risk
report_mode_beta  = "value" | "log_value"
overflow_policy   = "switch_to_log" (default) | "error"


Worked examples

A) Gamma on integers and half-integers.

Gamma*((5, +0.7))     = ( 24 , +0.7 )            # 4!
Gamma*((1/2, -0.2))   = ( sqrt(pi) , -0.2 ) ≈ ( 1.772454 , -0.2 )

B) Beta with equal-weights rapidity mean.

x = (2, 0.6),  y = (3, 0.2)

B(x,y) = Gamma(2)Gamma(3)/Gamma(5) = (1! * 2!) / 4! = 2/24 = 1/12 ≈ 0.083333
u_x = atanh(0.6) ≈ 0.6931
u_y = atanh(0.2) ≈ 0.2027
a_B = tanh( (u_x + u_y)/2 ) = tanh(0.4479) ≈ 0.421
Result: B*((2,0.6),(3,0.2)) ≈ ( 0.083333 , 0.421 )

C) Log-space evaluation (large inputs).

x = (30, 0.8),  y = (12, 0.5)

betaln = lgamma(30) + lgamma(12) - lgamma(42)     # compute in log-space
Report: ( betaln ,  a_B ) in "log_value" mode
a_B = tanh( (atanh(0.8) + atanh(0.5))/2 ) ≈ tanh( (1.0986 + 0.5493)/2 ) ≈ tanh(0.82395) ≈ 0.677

Switch to magnitude only if exp(betaln) is safe per overflow_policy.


Implementation notes (manifest)

  • Domains. gamma.domain = "m>0" (default real-line usage) beta.domain = "x>0 & y>0"
  • Alignment handling.
    Unary: carry a unchanged.
    Binary (beta): a_B = tanh( (Σ w_i atanh(a_i)) / (Σ w_i) ) with default w_i = 1; declare any other weights (see 2.44).
  • Numerics.
    Use lgamma/betaln; enable Stirling fallback for very large inputs; reflection formula is optional on m<0 under "principal_extension" (declare explicitly).
  • Zero-class.
    If a computed magnitude is exactly 0, record (0, +1).

Takeaway

Gamma and Beta lift cleanly to symbolic numerals by acting on magnitudes and carrying alignment. Domain guards keep the real-line usage safe; log-space numerics prevent overflow; asymptotics guide scale. Under collapse, all values reduce exactly to the classical functions.


Navigation
Previous → Generating functions & transforms (2.40)
Next → Special functions II — erf, Bessel, polylog, Lambert W (2.42)


Disclaimer
Observation only. Results reproduce mathematically; domain claims require independent peer review. Defaults: mult_mode = M2, clamp_eps = 1e-6, |a| < 1. All formulas are presented in plain text. Collapse uses phi(m,a) = m.