sqrtpif

Compute the principal square root of the product of π and a positive single-precision floating-point number.

Usage

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 NaN

For negative numbers, the principal square root is not defined.

var v = sqrtpif( -4.0 );
// returns NaN

Examples

var randu = require( '@stdlib/random/array/discrete-uniform' );
var sqrtpif = require( '@stdlib/math/base/special/sqrtpif' );

var x = randu( 100, 0.0, 100.0 );

var i;
for ( i = 0; i < 100; i++ ) {
    console.log( 'sqrtpif(%d) = %d', x[ i ], sqrtpif( x[ i ] ) );
}

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.60499f

The function accepts the following arguments:

  • x: [in] float input 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 );
    }
}
Did you find this page helpful?