@toshiara/special-erf
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

erf / erfc

Error function and complementary error function.

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

MIT license.

Copyright

Copyright © 2016. The Compute.io Authors.

Package Sidebar

Install

npm i @toshiara/special-erf

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

62.9 kB

Total Files

21

Last publish

Collaborators

  • toshiara