Skip to content
class method

Math.lgamma

(::Math::double x) -> [ ::Float, -1 | 1 ]
Math.lgamma(x) → [float, -1 or 1]

Returns a 2-element array equivalent to:

Example
[Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]

See log gamma function.

  • Domain: (-INFINITY, INFINITY].

  • Range of first element: (-INFINITY, INFINITY].

  • Second element is -1 or 1.

Examples:

Example
lgamma(-4.0) # => [Infinity, -1]
lgamma(-3.0) # => [Infinity, -1]
lgamma(-2.0) # => [Infinity, -1]
lgamma(-1.0) # => [Infinity, -1]
lgamma(0.0)  # => [Infinity, 1]

lgamma(1.0)  # => [0.0, 1]
lgamma(2.0)  # => [0.0, 1]
lgamma(3.0)  # => [0.6931471805599436, 1]
lgamma(4.0)  # => [1.7917594692280545, 1]

lgamma(-2.5) # => [-0.05624371649767279, -1]
lgamma(-1.5) # => [0.8600470153764797, 1]
lgamma(-0.5) # => [1.265512123484647, -1]
lgamma(0.5)  # => [0.5723649429247004, 1]
lgamma(1.5)  # => [-0.12078223763524676, 1]
lgamma(2.5)      # => [0.2846828704729205, 1]

Related: Math.gamma.

See also .ldexp .log .hypot .log10 also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0