|
29 | 29 | * NAN = $(RED NAN)
|
30 | 30 | * SUP = <span style="vertical-align:super;font-size:smaller">$0</span>
|
31 | 31 | * GAMMA = Γ
|
| 32 | + * PSI = Ψ |
32 | 33 | * THETA = θ
|
33 | 34 | * INTEGRAL = ∫
|
34 | 35 | * INTEGRATE = $(BIG ∫<sub>$(SMALL $1)</sub><sup>$2</sup>)
|
|
37 | 38 | * BIGSUM = $(BIG Σ <sup>$2</sup><sub>$(SMALL $1)</sub>)
|
38 | 39 | * CHOOSE = $(BIG () <sup>$(SMALL $1)</sup><sub>$(SMALL $2)</sub> $(BIG ))
|
39 | 40 | * PLUSMN = ±
|
| 41 | + * MNPLUS = ∓ |
40 | 42 | * INFIN = ∞
|
41 | 43 | * PLUSMNINF = ±∞
|
| 44 | + * MNPLUSINF = ∓∞ |
42 | 45 | * PI = π
|
43 | 46 | * LT = <
|
44 | 47 | * GT = >
|
@@ -166,19 +169,47 @@ real beta(real x, real y)
|
166 | 169 | assert(isIdentical(beta(2, NaN(0xABC)), NaN(0xABC)));
|
167 | 170 | }
|
168 | 171 |
|
169 |
| -/** Digamma function |
| 172 | +/** Digamma function, $(PSI)(x) |
170 | 173 | *
|
171 |
| - * The digamma function is the logarithmic derivative of the gamma function. |
| 174 | + * $(PSI)(x), is the logarithmic derivative of the gamma function, $(GAMMA)(x). |
172 | 175 | *
|
173 |
| - * digamma(x) = d/dx logGamma(x) |
| 176 | + * $(PSI)(x) = $(SUP d)$(SUB /, dx) ln|$(GAMMA)(x)| (the derivative of `logGamma(x)`) |
174 | 177 | *
|
175 |
| - * See_Also: $(LREF logmdigamma), $(LREF logmdigammaInverse). |
| 178 | + * Params: |
| 179 | + * x = the domain value |
| 180 | + * |
| 181 | + * Returns: |
| 182 | + * It returns $(PSI)(x). |
| 183 | + * |
| 184 | + * $(TABLE_SV |
| 185 | + * $(SVH x, digamma(x) ) |
| 186 | + * $(SV integer < 0, $(NAN) ) |
| 187 | + * $(SV $(PLUSMN)0.0, $(MNPLUSINF) ) |
| 188 | + * $(SV +$(INFIN), +$(INFIN) ) |
| 189 | + * $(SV -$(INFIN), $(NAN) ) |
| 190 | + * $(SV $(NAN), $(NAN) ) |
| 191 | + * ) |
| 192 | + * |
| 193 | + * See_Also: $(LREF logmdigamma), $(LREF logmdigammaInverse). |
176 | 194 | */
|
177 | 195 | real digamma(real x)
|
178 | 196 | {
|
179 | 197 | return std.internal.math.gammafunction.digamma(x);
|
180 | 198 | }
|
181 | 199 |
|
| 200 | +/// |
| 201 | +@safe unittest |
| 202 | +{ |
| 203 | + const euler = 0.57721_56649_01532_86061L; |
| 204 | + |
| 205 | + assert(digamma(1) == -euler); |
| 206 | + assert(digamma(+0.) == -real.infinity); |
| 207 | + assert(digamma(-0.) == +real.infinity); |
| 208 | + assert(digamma(+real.infinity) == +real.infinity); |
| 209 | + assert(isNaN(digamma(-1))); |
| 210 | + assert(isNaN(digamma(-real.infinity))); |
| 211 | +} |
| 212 | + |
182 | 213 | /** Log Minus Digamma function
|
183 | 214 | *
|
184 | 215 | * logmdigamma(x) = log(x) - digamma(x)
|
|
0 commit comments