pub fn gamma(z: &Expression) -> ExpressionExpand description
Gamma function Γ(z)
The Gamma function extends the factorial to complex numbers: Γ(n) = (n-1)! for positive integers n
§Mathematical Properties
- Γ(n+1) = n·Γ(n) (functional equation)
- Γ(1) = 1
- Γ(1/2) = √π
- Pole at non-positive integers
§Numerical Evaluation
Float inputs are evaluated numerically using Lanczos approximation (14-digit precision). Half-integers return exact symbolic forms (e.g., Γ(1/2) = √π).
§Input Validation
- NaN or infinity inputs return NaN
- Non-positive integers are poles (return symbolic or error)
§Arguments
z- Expression to evaluate gamma function at
§Examples
use mathhook_core::{Expression, Number};
use mathhook_core::functions::special::gamma;
let result = gamma(&Expression::Number(Number::Integer(5)));
assert_eq!(result, Expression::Number(Number::Integer(24)));
let half = gamma(&Expression::Number(Number::Float(0.5)));