time-to-botec

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

README.md (3224B)


      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 # expm1rel
     22 
     23 > Compute the relative error exponential.
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 The relative error exponential is defined as
     30 
     31 <!-- <equation class="equation" label="eq:relative_error_exponential" align="center" raw="f(x) = \frac{e^x - 1}{x}" alt="Equation for the relative error exponential."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="f(x) = \frac{e^x - 1}{x}" data-equation="eq:relative_error_exponential">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@237a80443a932a41f0195d0b9fc7699aa8c8e417/lib/node_modules/@stdlib/math/base/special/expm1rel/docs/img/equation_relative_error_exponential.svg" alt="Equation for the relative error exponential.">
     35     <br>
     36 </div>
     37 
     38 <!-- </equation> -->
     39 
     40 </section>
     41 
     42 <!-- /.intro -->
     43 
     44 <!-- Package usage documentation. -->
     45 
     46 <section class="usage">
     47 
     48 ## Usage
     49 
     50 ```javascript
     51 var expm1rel = require( '@stdlib/math/base/special/expm1rel' );
     52 ```
     53 
     54 #### expm1rel( x )
     55 
     56 Computes the relative error exponential.
     57 
     58 ```javascript
     59 var v = expm1rel( 0.0 );
     60 // returns 1.0
     61 
     62 v = expm1rel( 1.0 );
     63 // returns ~1.718
     64 
     65 v = expm1rel( -1.0 );
     66 // returns ~0.632
     67 
     68 v = expm1rel( NaN );
     69 // returns NaN
     70 ```
     71 
     72 </section>
     73 
     74 <!-- /.usage -->
     75 
     76 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     77 
     78 <section class="notes">
     79 
     80 ## Notes
     81 
     82 -   When `x` is near zero, `exp(x)-1` can suffer catastrophic cancellation (i.e., a significant loss in precision). `expm1rel` avoids such a loss in precision.
     83 
     84 </section>
     85 
     86 <!-- /.notes -->
     87 
     88 <!-- Package usage examples. -->
     89 
     90 <section class="examples">
     91 
     92 ## Examples
     93 
     94 <!-- eslint no-undef: "error" -->
     95 
     96 ```javascript
     97 var randu = require( '@stdlib/random/base/randu' );
     98 var expm1rel = require( '@stdlib/math/base/special/expm1rel' );
     99 
    100 var x;
    101 var y;
    102 var a;
    103 var i;
    104 
    105 for ( i = 0; i < 100; i++ ) {
    106     x = (randu()*100.0) - 50.0;
    107     a = x.toFixed( 3 );
    108     y = expm1rel( x );
    109     console.log( '(e^%d - 1)/%d = %d', a, a, y );
    110 }
    111 ```
    112 
    113 </section>
    114 
    115 <!-- /.examples -->
    116 
    117 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    118 
    119 <section class="references">
    120 
    121 </section>
    122 
    123 <!-- /.references -->
    124 
    125 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    126 
    127 <section class="links">
    128 
    129 </section>
    130 
    131 <!-- /.links -->