Skip to content

Generalized binomial coefficient #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/functions_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ SpecialFunctions.besseli
SpecialFunctions.besselix
SpecialFunctions.besselk
SpecialFunctions.besselkx
SpecialFunctions.binomial
SpecialFunctions.jinc
SpecialFunctions.ellipk
SpecialFunctions.ellipe
Expand Down
1 change: 1 addition & 0 deletions docs/src/functions_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Here the *Special Functions* are listed according to the structure of [NIST Digi
| [`logbeta(x,y)`](@ref SpecialFunctions.logbeta) | accurate `log(beta(x,y))` for large `x` or `y` |
| [`logabsbeta(x,y)`](@ref SpecialFunctions.logabsbeta) | accurate `log(abs(beta(x,y)))` for large `x` or `y` |
| [`logabsbinomial(x,y)`](@ref SpecialFunctions.logabsbinomial) | accurate `log(abs(binomial(n,k)))` for large `n` and `k` near `n/2` |
| [`binomial(x,y)`](@ref SpecialFunctions.binomial) | generalized binomial coefficient ``{ x \choose y}`` for ``x,y \in \mathbb{C}``|


## [Exponential and Trigonometric Integrals](https://dlmf.nist.gov/6)
Expand Down
1 change: 1 addition & 0 deletions src/SpecialFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export
bessely0,
bessely1,
besselyx,
binomial,
jinc,
dawson,
ellipk,
Expand Down
19 changes: 19 additions & 0 deletions src/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -926,3 +926,22 @@ function logabsbinomial(n::T, k::T) where {T<:Integer}
end
end
logabsbinomial(n::Integer, k::Integer) = logabsbinomial(promote(n, k)...)


# this trickery is needed while the deprecated method in Base exists
@static if !hasmethod(Base.binomial, Tuple{Number, Number})
import Base: binomial
end
binomial(n, k) = Base.binomial(n, k) # to make SpecialFunctions.binomial work unconditionally

"""
binomial(x, y)

Generalized binomial coefficient
``{x \\choose y} = \\frac{1}{(x+1) \\Beta(x-y+1,y+1)}``.

External links: [Wikipedia](https://en.wikipedia.org/wiki/Binomial_coefficient#Two_real_or_complex_valued_arguments)

See also [`beta(a,b)`](@ref SpecialFunctions.beta).
"""
binomial(x::Number, y::Number) = inv((x+1) * beta(x-y+1, y+1))