time-to-botec

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

README.md (3204B)


      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 # fresnel
     22 
     23 > Compute the [Fresnel integrals][fresnel-integral] S(x) and C(x).
     24 
     25 <section class="intro">
     26 
     27 The [Fresnel integrals][fresnel-integral] are defined as
     28 
     29 <!-- <equation class="equation" label="eq:fresnel_integrals" align="center" raw="\begin{align} S(x) &= \int_0^x \sin\left(\frac{\pi}{2} t^2\right)\,\mathrm{d}t, \\ C(x) &= \int_0^x \cos\left(\frac{\pi}{2} t^2\right)\,\mathrm{d}t. \end{align}" alt="Fresnel integral"> -->
     30 
     31 <div class="equation" align="center" data-raw-text="\begin{align} S(x) &amp;= \int_0^x \sin\left(\frac{\pi}{2} t^2\right)\,\mathrm{d}t, \\ C(x) &amp;= \int_0^x \cos\left(\frac{\pi}{2} t^2\right)\,\mathrm{d}t. \end{align}" data-equation="eq:fresnel_integrals">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@591cf9d5c3a0cd3c1ceec961e5c49d73a68374cb/lib/node_modules/@stdlib/math/base/special/fresnel/docs/img/equation_fresnel_integrals.svg" alt="Fresnel integral">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 Some sources define the Fresnel integrals using t<sup>2</sup> for the argument of the sine and cosine. To get these functions, multiply the computed integrals by `√(π/2)` and multiply the argument `x` by `√(2/π)`.
     39 
     40 </section>
     41 
     42 <!-- /.intro -->
     43 
     44 <section class="usage">
     45 
     46 ## Usage
     47 
     48 ```javascript
     49 var fresnel = require( '@stdlib/math/base/special/fresnel' );
     50 ```
     51 
     52 #### fresnel( \[out,] x )
     53 
     54 Simultaneously computes the [Fresnel integrals][fresnel-integral] S(x) and C(x).
     55 
     56 ```javascript
     57 var v = fresnel( 0.0 );
     58 // returns [ ~0.0, ~0.0 ]
     59 
     60 v = fresnel( 1.0 );
     61 // returns [ ~0.438, ~0.780 ]
     62 
     63 v = fresnel( Infinity );
     64 // returns [ ~0.5, ~0.5 ]
     65 
     66 v = fresnel( -Infinity );
     67 // returns [ ~-0.5, ~-0.5 ]
     68 
     69 v = fresnel( NaN );
     70 // returns [ NaN, NaN ]
     71 ```
     72 
     73 By default, the function returns the S(x) and C(x) as a two-element `array`. To avoid extra memory allocation, the function supports providing an output (destination) object.
     74 
     75 ```javascript
     76 var Float64Array = require( '@stdlib/array/float64' );
     77 
     78 var out = new Float64Array( 2 );
     79 
     80 var v = fresnel( out, 0.0 );
     81 // returns <Float64Array>[ ~0.0, ~0.0 ]
     82 
     83 var bool = ( v === out );
     84 // returns true
     85 ```
     86 
     87 </section>
     88 
     89 <!-- /.usage -->
     90 
     91 <section class="examples">
     92 
     93 ## Examples
     94 
     95 <!-- eslint no-undef: "error" -->
     96 
     97 ```javascript
     98 var linspace = require( '@stdlib/array/linspace' );
     99 var fresnel = require( '@stdlib/math/base/special/fresnel' );
    100 
    101 var x = linspace( 0.0, 10.0, 100 );
    102 var i;
    103 
    104 for ( i = 0; i < x.length; i++ ) {
    105     console.log( fresnel( x[ i ] ) );
    106 }
    107 ```
    108 
    109 </section>
    110 
    111 <!-- /.examples -->
    112 
    113 <section class="links">
    114 
    115 [fresnel-integral]: https://en.wikipedia.org/wiki/Fresnel_integral
    116 
    117 </section>
    118 
    119 <!-- /.links -->