time-to-botec

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

README.md (1801B)


      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 # cosm1
     22 
     23 > Compute `cos(x) - 1`.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var cosm1 = require( '@stdlib/math/base/special/cosm1' );
     31 ```
     32 
     33 #### cosm1( x )
     34 
     35 Computes `cos(x) - 1`, where `cos` is the [cosine][@stdlib/math/base/special/cos] of a `number` (in radians). This function should be used instead of manually calculating `cos(x) - 1` when the argument is near unity.
     36 
     37 ```javascript
     38 var PI = require( '@stdlib/constants/float64/pi' );
     39 
     40 var v = cosm1( 0.0 );
     41 // returns 0.0
     42 
     43 v = cosm1( PI/4.0 );
     44 // returns ~-0.293
     45 
     46 v = cosm1( -PI/6.0 );
     47 // returns ~-0.134
     48 
     49 v = cosm1( NaN );
     50 // returns NaN
     51 ```
     52 
     53 </section>
     54 
     55 <!-- /.usage -->
     56 
     57 <section class="examples">
     58 
     59 ## Examples
     60 
     61 <!-- eslint no-undef: "error" -->
     62 
     63 ```javascript
     64 var linspace = require( '@stdlib/array/linspace' );
     65 var PI = require( '@stdlib/constants/float64/pi' );
     66 var cosm1 = require( '@stdlib/math/base/special/cosm1' );
     67 
     68 var x = linspace( 0.0, 2.0*PI, 100 );
     69 var i;
     70 
     71 for ( i = 0; i < x.length; i++ ) {
     72     console.log( cosm1( x[ i ] ) );
     73 }
     74 ```
     75 
     76 </section>
     77 
     78 <!-- /.examples -->
     79 
     80 <section class="links">
     81 
     82 [@stdlib/math/base/special/cos]: https://www.npmjs.com/package/@stdlib/math/tree/main/base/special/cos
     83 
     84 </section>
     85 
     86 <!-- /.links -->