### 7.3.11 Error function

The error function erf is defined by:

erf(x)= |
2
√ |
π
| ∫ |
x
0
| e−t2d t,

where the constant 2/√π is chosen so that erf(+∞)=1 and erf(−∞)=−1, since

| ∫ |
+∞
0
| e−t2d t= |
√ |
π
2
| .

The erf command computes the error function.

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

#### Examples

erf(1)

erf | ⎛ ⎝ | 1 | ⎞ ⎠

erf(1.0)

0.84270079295 |  |  |  |  |  |  |  |  |  |

erf(1/(sqrt(2)))*1/2+0.5

0.841344746069 |  |  |  |  |  |  |  |  |  |

##### Remark.

The relation between erf and normal_cdf (see Section 20.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π∫0xe−t2/2d t yields:

normal_cdf(x)= |
1
2
| + |
1
√ |
π
| ∫ |
x
√ |
2
0
| e−u2d u= |
1
2
| + |
1
2
| erf | ⎛ ⎜ ⎜ ⎜ ⎜ ⎝ |
x
√ |
2
| ⎞ ⎟ ⎟ ⎟ ⎟ ⎠ | .