erf

erf(x)

Compute the error function of x, defined by $\frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt$ for arbitrary complex x.

Examples

julia> A = rand(10,5)
b = rand(10)
x = A \ b
B = A' * A
erf(eigvals(B)) - 2x.^2 + 4x - 6

5-element Array{Float64,1}:
-6.29936
-3.67082
-8.87201
-3.20876
-4.82683
1. Compute the error function for a real number:

julia> x = 1.5;
julia> erf(x)
0.9661051464753108

This example calculates the error function value for the real number x = 1.5.

2. Compute the error function for a complex number:

julia> x = 2 + 3im;
julia> erf(x)
-0.4518627618776061 + 2.2873552871788423im

It computes the error function value for the complex number x = 2 + 3im.

3. Compute the error function for an array of numbers:
julia> x = [0.5, 1.0, 1.5];
julia> erf.(x)
3-element Array{Float64,1}:
0.5204998778130465
0.842700792949715
0.9661051464753108

This example calculates the error function values for each element of the array x.

Common mistake example:

julia> x = "abc";
julia> erf(x)
ERROR: MethodError: no method matching erf(::String)

In this example, the argument x is of type String, which is not a valid input for the erf function. Make sure to pass the correct type of argument to the erf function, such as a real or complex number.