time-to-botec

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

README.md (3254B)


      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 # sici
     22 
     23 > Compute the sine and cosine integrals.
     24 
     25 <section class="intro">
     26 
     27 The sine integral is defined as
     28 
     29 <!-- <equation class="equation" label="eq:sine_integral" align="center" raw="\int_0^x \frac{\sin t}{t}\; dt" alt="Sine integral."> -->
     30 
     31 <div class="equation" align="center" data-raw-text="\int_0^x \frac{\sin t}{t}\; dt" data-equation="eq:sine_integral">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/sici/docs/img/equation_sine_integral.svg" alt="Sine integral.">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 and the cosine integral is defined as
     39 
     40 <!-- <equation class="equation" label="eq:cosine_integral" align="center" raw="\gamma + \log( x ) + \int_0^x \frac{\cos t - 1}{t}\; dt" alt="Cosine integral."> -->
     41 
     42 <div class="equation" align="center" data-raw-text="\gamma + \log( x ) + \int_0^x \frac{\cos t - 1}{t}\; dt" data-equation="eq:cosine_integral">
     43     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/sici/docs/img/equation_cosine_integral.svg" alt="Cosine integral.">
     44     <br>
     45 </div>
     46 
     47 <!-- </equation> -->
     48 
     49 where `γ` is the [Euler-Mascheroni][eulergamma] constant.
     50 
     51 </section>
     52 
     53 <!-- /.intro -->
     54 
     55 <section class="usage">
     56 
     57 ## Usage
     58 
     59 ```javascript
     60 var sici = require( '@stdlib/math/base/special/sici' );
     61 ```
     62 
     63 #### sici( \[out,] x )
     64 
     65 Computes the sine and cosine integrals.
     66 
     67 ```javascript
     68 var v = sici( 3.0 );
     69 // returns [ ~1.849, ~0.12 ]
     70 
     71 v = sici( 0.0 );
     72 // returns [ 0.0, -Infinity ]
     73 
     74 v = sici( -9.0 );
     75 // returns [ ~-1.665, ~0.055 ]
     76 
     77 v = sici( NaN );
     78 // returns [ NaN, NaN ]
     79 ```
     80 
     81 By default, the function returns the sine and cosine integrals as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object.
     82 
     83 ```javascript
     84 var Float64Array = require( '@stdlib/array/float64' );
     85 
     86 var out = new Float64Array( 2 );
     87 
     88 var v = sici( out, 3.0 );
     89 // returns <Float64Array>[ ~1.849, ~0.12 ]
     90 
     91 var bool = ( v === out );
     92 // returns true
     93 ```
     94 
     95 </section>
     96 
     97 <!-- /.usage -->
     98 
     99 <section class="examples">
    100 
    101 ## Examples
    102 
    103 <!-- eslint no-undef: "error" -->
    104 
    105 ```javascript
    106 var randu = require( '@stdlib/random/base/randu' );
    107 var sici = require( '@stdlib/math/base/special/sici' );
    108 
    109 var x;
    110 var y;
    111 var i;
    112 
    113 for ( i = 0; i < 100; i++ ) {
    114     x = randu() * 100.0;
    115     y = sici( x );
    116     console.log( 'si(%d) = %d, ci(%d) = %d', x, y[ 0 ], x, y[ 1 ] );
    117 }
    118 ```
    119 
    120 </section>
    121 
    122 <!-- /.examples -->
    123 
    124 <section class="links">
    125 
    126 [eulergamma]: http://mathworld.wolfram.com/Euler-MascheroniConstant.html
    127 
    128 </section>
    129 
    130 <!-- /.links -->