README.md (2666B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # digamma 22 23 > [Digamma][digamma-function] function. 24 25 <section class="intro"> 26 27 The [digamma function][digamma-function] `ψ` is the logarithmic derivative of the [gamma function][gamma-function], i.e. 28 29 <!-- <equation class="equation" label="eq:digamma_function" align="center" raw="\psi(x) =\frac{d}{dx} \ln{\Gamma(x)}= \frac{\Gamma\,'(x)}{\Gamma(x)}" alt="Digamma function"> --> 30 31 <div class="equation" align="center" data-raw-text="\psi(x) =\frac{d}{dx} \ln{\Gamma(x)}= \frac{\Gamma\,'(x)}{\Gamma(x)}" data-equation="eq:digamma_function"> 32 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/digamma/docs/img/equation_digamma_function.svg" alt="Digamma function"> 33 <br> 34 </div> 35 36 <!-- </equation> --> 37 38 </section> 39 40 <!-- /.intro --> 41 42 <section class="usage"> 43 44 ## Usage 45 46 ```javascript 47 var digamma = require( '@stdlib/math/base/special/digamma' ); 48 ``` 49 50 #### digamma( x ) 51 52 Evaluates the [digamma function][digamma-function]. 53 54 ```javascript 55 var v = digamma( -2.5 ); 56 // returns ~1.103 57 58 v = digamma( 1.0 ); 59 // returns ~-0.577 60 61 v = digamma( 10.0 ); 62 // returns ~2.252 63 ``` 64 65 If `x` is `0` or a negative `integer`, the function returns `NaN`. 66 67 ```javascript 68 var v = digamma( 0.0 ); 69 // returns NaN 70 71 v = digamma( -1.0 ); 72 // returns NaN 73 74 v = digamma( -2.0 ); 75 // returns NaN 76 ``` 77 78 If provided `NaN`, the function returns `NaN`. 79 80 ```javascript 81 var v = digamma( NaN ); 82 // returns NaN 83 ``` 84 85 </section> 86 87 <!-- /.usage --> 88 89 <section class="examples"> 90 91 ## Examples 92 93 <!-- eslint no-undef: "error" --> 94 95 ```javascript 96 var randu = require( '@stdlib/random/base/randu' ); 97 var digamma = require( '@stdlib/math/base/special/digamma' ); 98 99 var x; 100 var v; 101 var i; 102 103 for ( i = 0; i < 10; i++ ) { 104 x = (randu()*10.0) - 5.0; 105 v = digamma( x ); 106 console.log( 'x: %d, f(x): %d', x, v ); 107 } 108 ``` 109 110 </section> 111 112 <!-- /.examples --> 113 114 <section class="links"> 115 116 [digamma-function]: https://en.wikipedia.org/wiki/Digamma_function 117 118 [gamma-function]: https://en.wikipedia.org/wiki/Gamma_function 119 120 </section> 121 122 <!-- /.links -->