@stdlib/math-base-special-sqrtpif
v0.1.1
Published
Compute the principal square root of the product of π and a positive single-precision floating-point number.
Downloads
239
Readme
sqrtpif
Compute the principal square root of the product of π and a positive single-precision floating-point number.
Installation
npm install @stdlib/math-base-special-sqrtpifUsage
var sqrtpif = require( '@stdlib/math-base-special-sqrtpif' );sqrtpif( x )
Computes the principal square root of the product of π and a positive single-precision floating-point number.
var v = sqrtpif( 4.0 );
// returns ~3.5449
v = sqrtpif( 10.0 );
// returns ~5.60499
v = sqrtpif( 0.0 );
// returns 0.0
v = sqrtpif( NaN );
// returns NaNFor negative numbers, the principal square root is not defined.
var v = sqrtpif( -4.0 );
// returns NaNExamples
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var sqrtpif = require( '@stdlib/math-base-special-sqrtpif' );
var opts = {
'dtype': 'float32'
};
var x = discreteUniform( 100, 0, 100, opts );
logEachMap( 'sqrtpif(%d) = %0.4f', x, sqrtpif );C APIs
Usage
#include "stdlib/math/base/special/sqrtpif.h"stdlib_base_sqrtpif( x )
Computes the principal square root of the product of π and a positive single-precision floating-point number.
float x = stdlib_base_sqrtpif( 4.0f );
// returns ~3.5449f
x = stdlib_base_sqrtpif( 10.0f );
// returns ~5.60499fThe function accepts the following arguments:
- x:
[in] floatinput value.
float stdlib_base_sqrtpif( const float x );Examples
#include "stdlib/math/base/special/sqrtpif.h"
#include <stdlib.h>
#include <stdio.h>
int main( void ) {
const float x[] = { 4.0f, 10.0f, 3.14f, -3.14f, 0.0f, 0.0f / 0.0f };
float v;
int i;
for ( i = 0; i < 6; i++ ) {
v = stdlib_base_sqrtpif( x[ i ] );
printf( "sqrtpif(%f) = %f", x[ i ], v );
}
}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.
