sinc

Compute the cardinal sine of a number.

The normalized cardinal sine function is defined as

for any real number x.

Usage

var sinc = require( '@stdlib/math/base/special/sinc' );

sinc( x )

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

Examples

var linspace = require( '@stdlib/array/base/linspace' );
var sinc = require( '@stdlib/math/base/special/sinc' );

var x = linspace( -5.0, 5.0, 100 );

var i;
for ( i = 0; i < x.length; i++ ) {
    console.log( sinc( x[ i ] ) );
}

C APIs

Usage

#include "stdlib/math/base/special/sinc.h"

stdlib_base_sinc( x )

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 );

Examples

#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 );
    }
}
Did you find this page helpful?