time-to-botec

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

README.md (3787B)


      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 # Kernel Tangent
     22 
     23 > Compute the [tangent][tangent] of a number on `[-π/4, π/4]`.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var kernelTan = require( '@stdlib/math/base/special/kernel-tan' );
     31 ```
     32 
     33 #### kernelTan( x, y, k )
     34 
     35 Computes the [tangent][tangent] of a `number` on `[-π/4, π/4]`. For increased accuracy, the number for which the [tangent][tangent] should be evaluated can be supplied as a [double-double number][double-double-arithmetic] (i.e., a non-evaluated sum of two [double-precision floating-point numbers][ieee754] `x` and `y`).
     36 
     37 ```javascript
     38 var out = kernelTan( 3.141592653589793/4.0, 0.0, 1 );
     39 // returns ~1.0
     40 
     41 out = kernelTan( 3.141592653589793/6.0, 0.0, 1 );
     42 // returns ~0.577
     43 
     44 out = kernelTan( 0.664, 5.288e-17, 1 );
     45 // returns ~0.783
     46 ```
     47 
     48 If `k = 1`, the function returns `tan(x+y)`. To return the negative inverse `-1/tan(x+y)`, set `k = -1`. 
     49 
     50 ```javascript
     51 var out = kernelTan( 3.141592653589793/4.0, 0.0, -1 );
     52 // returns ~-1.0
     53 ```
     54 
     55 If either `x` or `y` is `NaN`, the function returns `NaN`.
     56 
     57 ```javascript
     58 var out = kernelTan( NaN, 0.0, 1 );
     59 // returns NaN
     60 
     61 out = kernelTan( 3.0, NaN, 1 );
     62 // returns NaN
     63 
     64 out = kernelTan( NaN, NaN, 1 );
     65 // returns NaN
     66 ```
     67 
     68 </section>
     69 
     70 <!-- /.usage -->
     71 
     72 <section class="notes">
     73 
     74 ## Notes
     75 
     76 -   As components of a [double-double number][double-double-arithmetic], the two [double-precision floating-point numbers][ieee754] `x` and `y` must satisfy 
     77 
     78     <!-- <equation class="equation" label="eq:double_double_inequality" align="center" raw="|y| \leq \frac{1}{2} \operatorname{ulp}(x)" alt="Inequality for the two components of a double-double number."> -->
     79 
     80     <div class="equation" align="center" data-raw-text="|y| \leq \frac{1}{2} \operatorname{ulp}(x)" data-equation="eq:double_double_inequality">
     81         <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/kernel-tan/docs/img/equation_double_double_inequality.svg" alt="Inequality for the two components of a double-double number.">
     82         <br>
     83     </div>
     84 
     85     <!-- </equation> -->
     86 
     87     where `ulp` stands for [units in the last place][ulp].
     88 
     89 </section>
     90 
     91 <!-- /.notes -->
     92 
     93 <section class="examples">
     94 
     95 ## Examples
     96 
     97 <!-- eslint no-undef: "error" -->
     98 
     99 ```javascript
    100 var linspace = require( '@stdlib/array/linspace' );
    101 var binomial = require( '@stdlib/random/base/binomial' ).factory;
    102 var PI = require( '@stdlib/constants/float64/pi' );
    103 var kernelTan = require( '@stdlib/math/base/special/kernel-tan' );
    104 
    105 var x = linspace( -PI/4.0, PI/4.0, 100 );
    106 var rbinom = binomial( 1, 0.5 );
    107 
    108 var descr;
    109 var i;
    110 var k;
    111 
    112 for ( i = 0; i < x.length; i++ ) {
    113     k = rbinom();
    114     descr = ( k === 1 ) ? 'tan(%d) = %d' : '-1/tan(%d) = %d';
    115     console.log( descr, x[ i ], kernelTan( x[ i ], 0.0, k ) );
    116 }
    117 ```
    118 
    119 </section>
    120 
    121 <!-- /.examples -->
    122 
    123 <section class="links">
    124 
    125 [tangent]: https://en.wikipedia.org/wiki/Tangent
    126 
    127 [double-double-arithmetic]: https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format#Double-double_arithmetic
    128 
    129 [ieee754]: https://en.wikipedia.org/wiki/IEEE_floating_point
    130 
    131 [ulp]: https://en.wikipedia.org/wiki/Unit_in_the_last_place
    132 
    133 </section>
    134 
    135 <!-- /.links -->