Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

README.md

Outline

erfcx

Scaled complementary error function.

The scaled complementary error function is defined as

$$\mathop{\mathrm{erfcx}}(x) = e^{x^2} \mathop{\mathrm{erfc}}(x)$$

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

$$\left( \frac{1}{\sqrt{\pi}} \right) \frac{1}{x}$$

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 uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var erfcx = require( '@stdlib/math/base/special/erfcx' );

var opts = {
    'dtype': 'float64'
};
var x = uniform( 100, -30.0, 30.0, opts );

logEachMap( 'x: %0.4f, erfcx(x): %0.4f', x, erfcx );

C APIs

Usage

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

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

See Also

Morty Proxy This is a proxified and sanitized view of the page, visit original site.