time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (2762B)


      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 # Trigamma
     22 
     23 > [Trigamma][trigamma-function] function.
     24 
     25 <section class="intro">
     26 
     27 The [trigamma function][trigamma-function] `ψ^(1)` is the derivative of the [digamma function][@stdlib/math/base/special/digamma].
     28 
     29 <!-- <equation class="equation" label="eq:trigamma_function" align="center" raw="\psi^{(1)}(x) =\frac{d}{dx} \Psi(x) = \sum_{k=0}^\infty \frac{1}{(k+x)^2}" alt="Trigamma function"> -->
     30 
     31 <div class="equation" align="center" data-raw-text="\psi^{(1)}(x) =\frac{d}{dx} \Psi(x) = \sum_{k=0}^\infty \frac{1}{(k+x)^2}" data-equation="eq:trigamma_function">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/trigamma/docs/img/equation_trigamma_function.svg" alt="Trigamma 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 trigamma = require( '@stdlib/math/base/special/trigamma' );
     48 ```
     49 
     50 #### trigamma( x )
     51 
     52 Evaluates the [trigamma function][trigamma-function].
     53 
     54 ```javascript
     55 var v = trigamma( -2.5 );
     56 // returns ~9.539
     57 
     58 v = trigamma( 1.0 );
     59 // returns ~1.645
     60 
     61 v = trigamma( 10.0 );
     62 // returns ~0.105
     63 ```
     64 
     65 If `x` is `0` or a negative `integer`, the function returns `NaN`.
     66 
     67 ```javascript
     68 var v = trigamma( 0.0 );
     69 // returns NaN
     70 
     71 v = trigamma( -1.0 );
     72 // returns NaN
     73 
     74 v = trigamma( -2.0 );
     75 // returns NaN
     76 ```
     77 
     78 If provided `NaN`, the function returns `NaN`.
     79 
     80 ```javascript
     81 var v = trigamma( 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 trigamma = require( '@stdlib/math/base/special/trigamma' );
     98 
     99 var x;
    100 var v;
    101 var i;
    102 
    103 for ( i = 0; i < 10; i++ ) {
    104     x = (randu()*100.0) - 50.0;
    105     v = trigamma( x );
    106     console.log( 'x: %d, ψ^(1)(x): %d', x, v );
    107 }
    108 ```
    109 
    110 </section>
    111 
    112 <!-- /.examples -->
    113 
    114 <section class="links">
    115 
    116 [trigamma-function]: https://en.wikipedia.org/wiki/Trigamma_function
    117 
    118 [@stdlib/math/base/special/digamma]: https://www.npmjs.com/package/@stdlib/math/tree/main/base/special/digamma
    119 
    120 </section>
    121 
    122 <!-- /.links -->