# Error function: erf

### 5.8.11 Error function: erf

The error function erf is defined by:

erf(x)=

2

√

π

∫

x
0

e−t2dt

where the constant 2/√π is chosen so that

erf(+∞)=1, erf(−∞)=−1

since

∫

+∞
0

e−t2dt=

√

π

2

The erf command computes the error function.

- erf takes one argument:
  a, a number.
- erf(a) returns the value of erf(a).

#### Examples.

- Input:
  erf(1)
  Output:

  erf | ⎛ ⎝ | 1 | ⎞ ⎠

- Input:
  erf(1.0)
  Output:

  0.84270079295

- Input:
  erf(1/(sqrt(2)))*1/2+0.5
  Output:

  0.841344746069

Remark.
The relation between erf and normal_cdf (see Section 8.4.7) is:

normal_cdf(x)=

1
2

+

1
2

erf(

x

√

2

)

Indeed, making the change of variable t=u*√2 in

normal_cdf(x)=

1
2

+

1

√

2π

∫

x
0

e−t2/2dt

gives:

normal_cdf(x)=

1
2

+

1

√

π

∫

x

√

2

0

e−u2du=

1
2

+

1
2

erf(

x

√

2

)

Check:
Input:

normal_cdf(1.0)

Output:

0.841344746069