@stdlib/math-base-special-sinpif
v0.1.1
Published
Compute sin(πx) in single-precision floating-point format.
Readme
sinpif
Installation
npm install @stdlib/math-base-special-sinpifUsage
var sinpif = require( '@stdlib/math-base-special-sinpif' );sinpif( x )
Computes sin(πx) in single-precision floating-point format more accurately than sin(pi*x), especially for large x.
var y = sinpif( 0.0 );
// returns 0.0
y = sinpif( 0.5 );
// returns 1.0
y = sinpif( 0.9 );
// returns ~0.309
y = sinpif( NaN );
// returns NaNExamples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var sinpif = require( '@stdlib/math-base-special-sinpif' );
var opts = {
'dtype': 'float32'
};
var x = uniform( 100, -100.0, 100.0, opts );
logEachMap( 'sin( π * %0.4f ) = %0.4f', x, sinpif );C APIs
Usage
#include "stdlib/math/base/special/sinpif.h"stdlib_base_sinpif( x )
Computes sin(πx) in single-precision floating-point format more accurately than sin(pi*x), especially for large x.
float y = stdlib_base_sinpif( 0.5f );
// returns 1.0fThe function accepts the following arguments:
- x:
[in] floatinput value.
float stdlib_base_sinpif( const float x );Examples
#include "stdlib/math/base/special/sinpif.h"
#include <stdio.h>
int main( void ) {
const float x[] = { 0.0f, 0.523f, 0.785f, 1.047f, 3.14f };
float y;
int i;
for ( i = 0; i < 5; i++ ) {
y = stdlib_base_sinpif( x[ i ] );
printf( "sin( π * %f ) = %f\n", x[ i ], y );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
