Skip to content

Commit

Permalink
doc: add example and doctest for gamma (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
inkydragon authored Apr 9, 2024
1 parent e02c1e0 commit dc9ba56
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
34 changes: 34 additions & 0 deletions src/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit dc9ba56

Please sign in to comment.