Skip to content

Commit dc9ba56

Browse files
authored
doc: add example and doctest for gamma (#462)
1 parent e02c1e0 commit dc9ba56

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

docs/make.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using SpecialFunctions, Documenter
22

3+
# `using SpecialFunctions` for all doctests
4+
DocMeta.setdocmeta!(SpecialFunctions, :DocTestSetup, :(using SpecialFunctions); recursive=true)
35
makedocs(modules=[SpecialFunctions],
46
sitename="SpecialFunctions.jl",
57
authors="Jeff Bezanson, Stefan Karpinski, Viral B. Shah, et al.",

src/gamma.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,40 @@ Compute the gamma function for complex ``z``, defined by
559559
```
560560
and by analytic continuation in the whole complex plane.
561561
562+
# Examples
563+
Special Values:
564+
```jldoctest
565+
julia> gamma(0)
566+
Inf
567+
568+
julia> gamma(1)
569+
1.0
570+
571+
julia> gamma(2)
572+
1.0
573+
```
574+
575+
``\Gamma(0.5)^2 = \pi``
576+
```jldoctest
577+
julia> gamma(0.5)^2
578+
3.1415926535897936
579+
580+
julia> gamma(0.5)^2 ≈ π
581+
true
582+
```
583+
584+
For integer `n`: ``\Gamma(n+1) = prod(1:n) = factorial(n)``
585+
```jldoctest
586+
julia> gamma(4+1)
587+
24.0
588+
589+
julia> prod(1:4) # == 1*2*3*4
590+
24
591+
592+
julia> gamma(4+1) == prod(1:4) == factorial(4)
593+
true
594+
```
595+
562596
External links:
563597
[DLMF](https://dlmf.nist.gov/5.2.1),
564598
[Wikipedia](https://en.wikipedia.org/wiki/Gamma_function).

0 commit comments

Comments
 (0)