time-to-botec

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

README.md (2445B)


      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 # powm1
     22 
     23 > Evaluate `bˣ - 1`.
     24 
     25 <section class="intro">
     26 
     27 <!-- <equation class="equation" label="eq:exponential_function_minus_one" align="center" raw="y = b^x - 1" alt="Exponential function minus one"> -->
     28 
     29 <div class="equation" align="center" data-raw-text="y = b^x - 1" data-equation="eq:exponential_function_minus_one">
     30     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/powm1/docs/img/equation_exponential_function_minus_one.svg" alt="Exponential function minus one">
     31     <br>
     32 </div>
     33 
     34 <!-- </equation> -->
     35 
     36 When `b` is close to `1` and/or `x` is small, this implementation is more accurate than naively computing `bˣ` minus `1`.
     37 
     38 </section>
     39 
     40 <!-- /.intro -->
     41 
     42 <section class="usage">
     43 
     44 ## Usage
     45 
     46 ```javascript
     47 var powm1 = require( '@stdlib/math/base/special/powm1' );
     48 ```
     49 
     50 #### powm1( b, x )
     51 
     52 Evaluates `bˣ - 1`.
     53 
     54 ```javascript
     55 var y = powm1( 2.0, 3.0 );
     56 // returns 7.0
     57 
     58 y = powm1( 4.0, 0.5 );
     59 // returns 1.0
     60 
     61 y = powm1( 0.0, 100.0 );
     62 // returns -1.0
     63 
     64 y = powm1( 100.0, 0.0 );
     65 // returns 0.0
     66 
     67 y = powm1( 0.0, 0.0 );
     68 // returns 0.0
     69 
     70 y = powm1( 3.141592653589793, 5.0 );
     71 // returns ~305.0197
     72 
     73 y = powm1( NaN, 3.0 );
     74 // returns NaN
     75 
     76 y = powm1( 5.0, NaN );
     77 // returns NaN
     78 ```
     79 
     80 </section>
     81 
     82 <!-- /.usage -->
     83 
     84 <section class="examples">
     85 
     86 ## Examples
     87 
     88 <!-- eslint no-undef: "error" -->
     89 
     90 ```javascript
     91 var randu = require( '@stdlib/random/base/randu' );
     92 var round = require( '@stdlib/math/base/special/round' );
     93 var powm1 = require( '@stdlib/math/base/special/powm1' );
     94 
     95 var b;
     96 var x;
     97 var y;
     98 var i;
     99 
    100 for ( i = 0; i < 100; i++ ) {
    101     b = round( randu()*10.0 );
    102     x = round( randu()*10.0 ) - 5.0;
    103     y = powm1( b, x );
    104     console.log( '%d^%d - 1 = %d', b, x, y );
    105 }
    106 ```
    107 
    108 </section>
    109 
    110 <!-- /.examples -->
    111 
    112 <section class="links">
    113 
    114 </section>
    115 
    116 <!-- /.links -->