TorchLean API

NN.Spec.Core.Erf

The Gauss error function #

Mathlib has no error function, so this module defines erf x = 2 / √π ∫₀ˣ exp (-t²) dt on the reals. It proves the facts that torch.erf and the exact GELU rely on: erf 0 = 0, oddness, the derivative 2 / √π exp (-x²), strict monotonicity, and the limits 1 at +∞ and -1 at -∞, hence -1 < erf x < 1.

References #

noncomputable def Spec.erf (x : ℝ) :

The Gauss error function, 2 / √π ∫₀ˣ exp (-t²) dt.

Instances For

    The Gaussian integrand is continuous.

    @[simp]
    theorem Spec.erf_zero :
    erf 0 = 0

    The error function vanishes at zero.

    theorem Spec.erf_neg (x : ℝ) :
    erf (-x) = -erf x

    The error function is odd.

    The derivative of the error function is 2 / √π exp (-x²).

    theorem Spec.deriv_erf (x : ℝ) :

    deriv erf is the scaled Gaussian.

    The error function is differentiable everywhere.

    The error function is continuous.

    The error function is strictly increasing.

    The error function tends to 1 at +∞.

    The error function tends to -1 at -∞.

    theorem Spec.erf_lt_one (x : ℝ) :
    erf x < 1

    The error function stays below 1.

    theorem Spec.neg_one_lt_erf (x : ℝ) :
    -1 < erf x

    The error function stays above -1.