erfcx

Scaled complementary error function.

The scaled complementary error function is defined as

For large values, the scaled complementary error function is approximately equal to

Usage

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

erfcx( x )

Evaluates the scaled complementary error function.

var y = erfcx( 0.0 );
// returns 1.0

y = erfcx( 1.0 );
// returns ~0.4276

y = erfcx( -1.0 );
// returns ~5.01

y = erfcx( 50.0 );
// returns ~0.011

y = erfcx( -50.0 );
// returns +Infinity

If provided NaN, the function returns NaN.

var y = erfcx( NaN );
// returns NaN

Examples

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

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

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

C APIs

Usage

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

erfcx( x )

Evaluates the scaled complementary error function.

double y  = stdlib_base_erfcx( 0.0 );
// returns 1.0

y  = stdlib_base_erfcx( 1.0 );
// returns ~0.4276

The function accepts the following arguments:

  • x: [in] double input value.
double stdlib_base_erfcx( const double x );

Examples

#include "stdlib/math/base/special/erfcx.h"
#include <stdio.h>

int main( void ) {
    const double x[] = { 0.0, 0.22, 0.44, 0.67, 0.89, 1.11, 1.33, 1.56, 1.78, 2.0 };

    double v;
    int i;
    for ( i = 0; i < 10; i++ ) {
        v = stdlib_base_erfcx( x[ i ] );
        printf( "x: %lf, erfcx(x): %lf\n", x[ i ], v );
    }
}
Did you find this page helpful?