time-to-botec

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

README.md (3007B)


      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 # spence
     22 
     23 > [Spence’s function][spence], also known as the dilogarithm.
     24 
     25 <section class="intro">
     26 
     27 The dilogarithm is defined as
     28 
     29 <!-- <equation class="equation" label="eq:dilogarithm" align="center" raw="\operatorname{Li}_{2}(z) = -\int_{0}^{z}{\ln(1-u) \over u}\,du{\text{, }}z\in \mathbb {C}" alt="Dilogarithm."> -->
     30 
     31 <div class="equation" align="center" data-raw-text="\operatorname{Li}_{2}(z) = -\int_{0}^{z}{\ln(1-u) \over u}\,du{\text{, }}z\in \mathbb {C}" data-equation="eq:dilogarithm">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@ea8657e10f42753f63de0b5c7dd8b13b4879409a/lib/node_modules/@stdlib/math/base/special/spence/docs/img/equation_dilogarithm.svg" alt="Dilogarithm.">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 or also alternatively as
     39 
     40 <!-- <equation class="equation" label="eq:dilogarithm_alt" align="center" raw="\int _{1}^{v}{\frac {\ln t}{1-t}}dt=\operatorname {Li} _{2}(1-v)." alt="Alternative definition of dilogarithm."> -->
     41 
     42 <div class="equation" align="center" data-raw-text="\int _{1}^{v}{\frac {\ln t}{1-t}}dt=\operatorname {Li} _{2}(1-v)." data-equation="eq:dilogarithm_alt">
     43     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@ea8657e10f42753f63de0b5c7dd8b13b4879409a/lib/node_modules/@stdlib/math/base/special/spence/docs/img/equation_dilogarithm_alt.svg" alt="Alternative definition of dilogarithm.">
     44     <br>
     45 </div>
     46 
     47 <!-- </equation> -->
     48 
     49 </section>
     50 
     51 <!-- /.intro -->
     52 
     53 <section class="usage">
     54 
     55 ## Usage
     56 
     57 ```javascript
     58 var spence = require( '@stdlib/math/base/special/spence' );
     59 ```
     60 
     61 #### spence( x )
     62 
     63 Evaluates [Spence’s function][spence], which is alternatively known as the dilogarithm.
     64 
     65 ```javascript
     66 var v = spence( 3.0 );
     67 // returns ~-1.437
     68 
     69 v = spence( 0.0 );
     70 // returns ~1.645
     71 
     72 v = spence( NaN );
     73 // returns NaN
     74 ```
     75 
     76 For negative numbers, the dilogarithm is **not** defined.
     77 
     78 ```javascript
     79 var v = spence( -4.0 );
     80 // returns NaN
     81 ```
     82 
     83 </section>
     84 
     85 <!-- /.usage -->
     86 
     87 <section class="examples">
     88 
     89 ## Examples
     90 
     91 <!-- eslint no-undef: "error" -->
     92 
     93 ```javascript
     94 var randu = require( '@stdlib/random/base/randu' );
     95 var spence = require( '@stdlib/math/base/special/spence' );
     96 
     97 var x;
     98 var i;
     99 
    100 for ( i = 0; i < 100; i++ ) {
    101     x = randu() * 100.0;
    102     console.log( 'spence( %d ) = %d', x, spence( x ) );
    103 }
    104 ```
    105 
    106 </section>
    107 
    108 <!-- /.examples -->
    109 
    110 <section class="links">
    111 
    112 [spence]: https://en.wikipedia.org/wiki/Spence%27s_function
    113 
    114 </section>
    115 
    116 <!-- /.links -->