Computes \(\mathrm{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt\).

erf(x)

# S4 method for class 'numeric'
erf(x)

# S4 method for class 'dualr'
erf(x)

Arguments

x

A numeric or dual value.

Value

The error function value. For dual input, returns a dual with derivative \((2/\sqrt{\pi}) e^{-x^2}\).

Examples

erf(1)  # numeric
#> [1] 0.8427008
x <- dual_variable(1)
value(erf(x))  # erf(1)
#> [1] 0.8427008