erf / erfc
Evaluates the error and complementary error functions.
This package is a rewrite of math-erf and math-erfc in Typescript. This package supports both CommonJs and ES Modules.
The error function is defined as
\mathrm{erf}(x) = \frac{2}{\sqrt\pi}\int_0^x e^{-t^2}\,\mathrm dt
The complementary error function is defined as
\mathrm{erfc}(x) = 1 - \mathrm{erf}(x) = \frac{2}{\sqrt\pi} \int_x^{\infty} e^{-t^2}\, dt
Installation
$ npm install @toshiara/special-erf
Usage
// for CommonJs
const { erf, erfc } = require('@toshiara/special-erf');
// for ES Modules
import { erf, erfc } from '@toshiara/special-erf';
erf(x)
Evaluates the error function.
erf(2);
// returns 0.9953222650189527
erf(-1);
// returns -0.8427007929497149
If provided NaN
, the function
returns NaN
.
erf(NaN);
// returns NaN
The error function is an odd function; i.e., erf(-x) = -erf(x)
. Thus, in accordance with the IEEE 754 standard, if provided -0
, the function
returns -0
.
erf(-0);
// returns -0
erfc( x )
Evaluates the complementary error function.
erfc(2);
// returns 0.004677734981047266
erfc(-1);
// returns 1.8427007929497148
erfc(Number.POSITIVE_INFINITY);
// returns 0
erfc(Number.NEGATIVE_INFINITY);
// returns 2
If provided NaN
, the function
returns NaN
.
erfc(NaN);
// returns NaN
License
Copyright
Copyright © 2016. The Compute.io Authors.