Error Functions

This module provides symbolic error functions. These functions use the \(mpmath library\) for numerical evaluation and Maxima, Pynac for symbolics.

The main objects which are exported from this module are:

  • erf – The error function

  • erfc – The complementary error function

  • erfi – The imaginary error function

  • erfinv – The inverse error function

  • fresnel_sin – The Fresnel integral \(S(x)\)

  • fresnel_cos – The Fresnel integral \(C(x)\)

AUTHORS:

  • Original authors erf/error_fcn (c) 2006-2014: Karl-Dieter Crisman, Benjamin Jones, Mike Hansen, William Stein, Burcin Erocal, Jeroen Demeyer, W. D. Joyner, R. Andrew Ohana

  • Reorganisation in new file, addition of erfi/erfinv/erfc (c) 2016: Ralf Stephan

  • Fresnel integrals (c) 2017 Marcelo Forets

REFERENCES:

class sage.functions.error.Function_Fresnel_cos

Bases: sage.symbolic.function.BuiltinFunction

The cosine Fresnel integral.

It is defined by the integral

\[\operatorname{C}(x) = \int_0^x \cos\left(\frac{\pi t^2}{2}\right)\, dt\]

for real \(x\). Using power series expansions, it can be extended to the domain of complex numbers. See the Wikipedia article Fresnel_integral.

INPUT:

  • x – the argument of the function

EXAMPLES:

sage: fresnel_cos(0)
0
sage: fresnel_cos(x).subs(x==0)
0
sage: x = var('x')
sage: fresnel_cos(1).n(100)
0.77989340037682282947420641365
sage: fresnel_cos(x)._sympy_()
fresnelc(x)
class sage.functions.error.Function_Fresnel_sin

Bases: sage.symbolic.function.BuiltinFunction

The sine Fresnel integral.

It is defined by the integral

\[\operatorname{S}(x) = \int_0^x \sin\left(\frac{\pi t^2}{2}\right)\, dt\]

for real \(x\). Using power series expansions, it can be extended to the domain of complex numbers. See the Wikipedia article Fresnel_integral.

INPUT:

  • x – the argument of the function

EXAMPLES:

sage: fresnel_sin(0)
0
sage: fresnel_sin(x).subs(x==0)
0
sage: x = var('x')
sage: fresnel_sin(1).n(100)
0.43825914739035476607675669662
sage: fresnel_sin(x)._sympy_()
fresnels(x)
class sage.functions.error.Function_erf

Bases: sage.symbolic.function.BuiltinFunction

The error function.

The error function is defined for real values as

\[\operatorname{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt.\]

This function is also defined for complex values, via analytic continuation.

EXAMPLES:

We can evaluate numerically:

sage: erf(2)
erf(2)
sage: erf(2).n()
0.995322265018953
sage: erf(2).n(100)
0.99532226501895273416206925637
sage: erf(ComplexField(100)(2+3j))
-20.829461427614568389103088452 + 8.6873182714701631444280787545*I

Basic symbolic properties are handled by Sage and Maxima:

sage: x = var("x")
sage: diff(erf(x),x)
2*e^(-x^2)/sqrt(pi)
sage: integrate(erf(x),x)
x*erf(x) + e^(-x^2)/sqrt(pi)

ALGORITHM:

Sage implements numerical evaluation of the error function via the erf() function from mpmath. Symbolics are handled by Sage and Maxima.

REFERENCES:

class sage.functions.error.Function_erfc

Bases: sage.symbolic.function.BuiltinFunction

The complementary error function.

The complementary error function is defined by

\[\frac{2}{\sqrt{\pi}} \int_t^\infty e^{-x^2} dx.\]

EXAMPLES:

sage: erfc(6)
erfc(6)
sage: erfc(6).n()
2.15197367124989e-17
sage: erfc(RealField(100)(1/2))
0.47950012218695346231725334611

sage: 1 - erfc(0.5)
0.520499877813047
sage: erf(0.5)
0.520499877813047
class sage.functions.error.Function_erfi

Bases: sage.symbolic.function.BuiltinFunction

The imaginary error function.

The imaginary error function is defined by

\[\operatorname{erfi}(x) = -i \operatorname{erf}(ix).\]
class sage.functions.error.Function_erfinv

Bases: sage.symbolic.function.BuiltinFunction

The inverse error function.

The inverse error function is defined by:

\[\operatorname{erfinv}(x) = \operatorname{erf}^{-1}(x).\]