README.md (2338B)
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 # sinc 22 23 > Compute the [cardinal sine][sinc] of a number. 24 25 <section class="intro"> 26 27 The normalized [cardinal sine][sinc] function is defined as 28 29 <!-- <equation class="equation" label="eq:sinc_function" align="center" raw="\operatorname{sinc}(x) := \begin{cases} \frac {\sin(\pi x)}{\pi x} & \textrm{if}\ x \neq 0 \\ 1 & \textrm{if}\ x = 0 \end{cases}" alt="Sinc function"> --> 30 31 <div class="equation" align="center" data-raw-text="\operatorname{sinc}(x) := \begin{cases} \frac {\sin(\pi x)}{\pi x} & \textrm{if}\ x \neq 0 \\ 1 & \textrm{if}\ x = 0 \end{cases}" data-equation="eq:sinc_function"> 32 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/sinc/docs/img/equation_sinc_function.svg" alt="Sinc function"> 33 <br> 34 </div> 35 36 <!-- </equation> --> 37 38 for any real number `x`. 39 40 </section> 41 42 <!-- /.intro --> 43 44 <section class="usage"> 45 46 ## Usage 47 48 ```javascript 49 var sinc = require( '@stdlib/math/base/special/sinc' ); 50 ``` 51 52 #### sinc( x ) 53 54 Computes the normalized [cardinal sine][sinc] of a `number`. 55 56 ```javascript 57 var v = sinc( 0.5 ); 58 // returns ~0.637 59 60 v = sinc( -1.2 ); 61 // returns ~-0.156 62 63 v = sinc( 0.0 ); 64 // returns 1.0 65 66 v = sinc( NaN ); 67 // returns NaN 68 ``` 69 70 </section> 71 72 <!-- /.usage --> 73 74 <section class="examples"> 75 76 ## Examples 77 78 <!-- eslint no-undef: "error" --> 79 80 ```javascript 81 var linspace = require( '@stdlib/array/linspace' ); 82 var sinc = require( '@stdlib/math/base/special/sinc' ); 83 84 var x = linspace( -5.0, 5.0, 100 ); 85 var i; 86 87 for ( i = 0; i < x.length; i++ ) { 88 console.log( sinc( x[ i ] ) ); 89 } 90 ``` 91 92 </section> 93 94 <!-- /.examples --> 95 96 <section class="links"> 97 98 [sinc]: https://en.wikipedia.org/wiki/Sinc_function 99 100 </section> 101 102 <!-- /.links -->