time-to-botec

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

README.md (1624B)


      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 # sqrt1pm1
     22 
     23 > Compute `sqrt( 1 + x ) - 1`.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var sqrt1pm1 = require( '@stdlib/math/base/special/sqrt1pm1' );
     31 ```
     32 
     33 #### sqrt1pm1( x )
     34 
     35 Computes `sqrt( 1 + x ) - 1` more accurately for small `x`. 
     36 
     37 ```javascript
     38 var v = sqrt1pm1( 3.0 );
     39 // returns 1.0
     40 
     41 v = sqrt1pm1( 0.5 );
     42 // returns ~0.225
     43 
     44 v = sqrt1pm1( 0.02 );
     45 // returns ~0.01
     46 
     47 v = sqrt1pm1( -0.5 );
     48 // returns ~-0.293
     49 
     50 v = sqrt1pm1( -1.1 );
     51 // returns NaN
     52 
     53 v = sqrt1pm1( NaN );
     54 // returns NaN
     55 ```
     56 
     57 </section>
     58 
     59 <!-- /.usage -->
     60 
     61 <section class="examples">
     62 
     63 ## Examples
     64 
     65 <!-- eslint no-undef: "error" -->
     66 
     67 ```javascript
     68 var randu = require( '@stdlib/random/base/randu' );
     69 var round = require( '@stdlib/math/base/special/round' );
     70 var sqrt1pm1 = require( '@stdlib/math/base/special/sqrt1pm1' );
     71 
     72 var x;
     73 var i;
     74 
     75 for ( i = 0; i < 100; i++ ) {
     76     x = round( randu() * 100.0 );
     77     console.log( 'sqrt(1+%d) - 1 = %d', x, sqrt1pm1( x ) );
     78 }
     79 ```
     80 
     81 </section>
     82 
     83 <!-- /.examples -->
     84 
     85 <section class="links">
     86 
     87 </section>
     88 
     89 <!-- /.links -->