Compute the cardinal sine of a number.
The normalized cardinal sine function is defined as
for any real number x
.
var sinc = require( '@stdlib/math/base/special/sinc' );
Computes the normalized cardinal sine of a number
.
var v = sinc( 0.5 );
// returns ~0.637
v = sinc( -1.2 );
// returns ~-0.156
v = sinc( 0.0 );
// returns 1.0
v = sinc( NaN );
// returns NaN
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var sinc = require( '@stdlib/math/base/special/sinc' );
var opts = {
'dtype': 'float64'
};
var x = uniform( 100, -5.0, 5.0, opts );
logEachMap( 'sinc( %0.4f ) = %0.4f', x, sinc );
#include "stdlib/math/base/special/sinc.h"
Computes the normalized cardinal sine of a number
.
double y = stdlib_base_sinc( 0.5 );
// returns ~0.637
The function accepts the following arguments:
- x:
[in] double
input value.
double stdlib_base_sinc( const double x );
#include "stdlib/math/base/special/sinc.h"
#include <stdio.h>
int main( void ) {
const double x[] = { 0.0, 0.523, 0.785, 1.047, 3.14 };
double y;
int i;
for ( i = 0; i < 5; i++ ) {
y = stdlib_base_sinc( x[ i ] );
printf( "sinc(%lf) = %lf\n", x[ i ], y );
}
}
@stdlib/math/base/special/sin
: compute the sine of a number.