time-to-botec

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

README.md (2877B)


      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 # Polygamma
     22 
     23 > [Polygamma][polygamma-function] function.
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var polygamma = require( '@stdlib/math/base/special/polygamma' );
     37 ```
     38 
     39 #### polygamma( n, x )
     40 
     41 Evaluates the [polygamma function][polygamma-function] of order `n`; i.e., the `(n+1)`th derivative of the [natural logarithm][@stdlib/math/base/special/ln] of the [gamma function][@stdlib/math/base/special/gamma].
     42 
     43 ```javascript
     44 var v = polygamma( 3, 1.2 );
     45 // returns ~3.245
     46 
     47 v = polygamma( 5, 1.2 );
     48 // returns ~41.39
     49 
     50 v = polygamma( 3, -4.9 );
     51 // returns ~60014.239
     52 ```
     53 
     54 If `n` is not a nonnegative `integer`, the function returns `NaN`.
     55 
     56 ```javascript
     57 var v = polygamma( 2.5, -1.2 );
     58 // returns NaN
     59 
     60 v = polygamma( -1, 5.3 );
     61 // returns NaN
     62 ```
     63 
     64 If `x` is `0` or a negative odd `integer`, the function returns `+Infinity`.
     65 
     66 ```javascript
     67 var v = polygamma( 2, 0.0 );
     68 // returns +Infinity
     69 
     70 v = polygamma( 2, -1.0 );
     71 // returns +Infinity
     72 ```
     73 
     74 If `x` on the other hand is a negative even `integer`, the function returns `NaN`.
     75 
     76 ```javascript
     77 v = polygamma( 2, -4.0 );
     78 // returns NaN
     79 
     80 v = polygamma( 2, -2.0 );
     81 // returns NaN
     82 ```
     83 
     84 If provided `NaN` as either parameter, the function returns `NaN`.
     85 
     86 ```javascript
     87 var v = polygamma( NaN, 2.1 );
     88 // returns NaN
     89 
     90 v = polygamma( 1, NaN );
     91 // returns NaN
     92 
     93 v = polygamma( NaN, NaN );
     94 // returns NaN
     95 ```
     96 
     97 </section>
     98 
     99 <!-- /.usage -->
    100 
    101 <section class="examples">
    102 
    103 ## Examples
    104 
    105 <!-- eslint no-undef: "error" -->
    106 
    107 ```javascript
    108 var randu = require( '@stdlib/random/base/randu' );
    109 var round = require( '@stdlib/math/base/special/round' );
    110 var polygamma = require( '@stdlib/math/base/special/polygamma' );
    111 
    112 var n;
    113 var x;
    114 var v;
    115 var i;
    116 
    117 for ( i = 0; i < 100; i++ ) {
    118     x = (randu()*100.0) - 50.0;
    119     n = round( randu()*50.0 );
    120     v = polygamma( x, n );
    121     console.log( 'x: %d, ψ^(%d)(x): %d', x, n, v );
    122 }
    123 ```
    124 
    125 </section>
    126 
    127 <!-- /.examples -->
    128 
    129 <section class="links">
    130 
    131 [polygamma-function]: https://en.wikipedia.org/wiki/Polygamma_function
    132 
    133 [@stdlib/math/base/special/ln]: https://www.npmjs.com/package/@stdlib/math/tree/main/base/special/ln
    134 
    135 [@stdlib/math/base/special/gamma]: https://www.npmjs.com/package/@stdlib/math/tree/main/base/special/gamma
    136 
    137 </section>
    138 
    139 <!-- /.links -->