diff --git a/docs/make.jl b/docs/make.jl index d4b180ff..62c5f6c1 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,5 +1,7 @@ using SpecialFunctions, Documenter +# `using SpecialFunctions` for all doctests +DocMeta.setdocmeta!(SpecialFunctions, :DocTestSetup, :(using SpecialFunctions); recursive=true) makedocs(modules=[SpecialFunctions], sitename="SpecialFunctions.jl", authors="Jeff Bezanson, Stefan Karpinski, Viral B. Shah, et al.", diff --git a/src/gamma.jl b/src/gamma.jl index 82264241..a69c34de 100644 --- a/src/gamma.jl +++ b/src/gamma.jl @@ -559,6 +559,40 @@ Compute the gamma function for complex ``z``, defined by ``` and by analytic continuation in the whole complex plane. +# Examples +Special Values: +```jldoctest +julia> gamma(0) +Inf + +julia> gamma(1) +1.0 + +julia> gamma(2) +1.0 +``` + +``\Gamma(0.5)^2 = \pi`` +```jldoctest +julia> gamma(0.5)^2 +3.1415926535897936 + +julia> gamma(0.5)^2 ≈ π +true +``` + +For integer `n`: ``\Gamma(n+1) = prod(1:n) = factorial(n)`` +```jldoctest +julia> gamma(4+1) +24.0 + +julia> prod(1:4) # == 1*2*3*4 +24 + +julia> gamma(4+1) == prod(1:4) == factorial(4) +true +``` + External links: [DLMF](https://dlmf.nist.gov/5.2.1), [Wikipedia](https://en.wikipedia.org/wiki/Gamma_function).