Skip to content
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

Double factorial can be extended to negative ints #103

Open
ron-wolf opened this issue Mar 2, 2021 · 0 comments
Open

Double factorial can be extended to negative ints #103

ron-wolf opened this issue Mar 2, 2021 · 0 comments

Comments

@ron-wolf
Copy link

ron-wolf commented Mar 2, 2021

The following error may be averted, or such functionality made possible with an additional method:

function doublefactorial(n::Integer)
if n < 0
throw(DomainError(n, "n must be nonnegative"))
end
z = Ref{BigInt}(0)
ccall((:__gmpz_2fac_ui, :libgmp), Cvoid, (Ref{BigInt}, UInt), z, UInt(n))
return z[]
end

An example of how ‼︎ can be extended to the signed integers is found on Wikipedia at Ellipse § Circumference:

where $n‼︎$ is the double factorial (extended to negative odd integers 
by the recurrence relation $(2n-1)‼︎ = (2n+1)‼︎ / (2n+1)$, for $n ≤ 0$).

Would this be a useful addition to the library? Alternatively, if there are multiple distinct analytical continuations of ‼︎ for the negative integers, could I have a lead for how to implement it in Julia? Would this issue be a better fit for the SpecialFunctions library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant