Function of #cas

erf

Proved decimal enclosures of the error function at a rational point, for SymLean’s CAS.erf, defined by the Gaussian integral.

#cas [N d] (erf q)
proves a decimal enclosure of width at most 10−d of erfq at a rational q, and prints it.

erf gives certified decimals for the error function. The Mathlib we build on doesn’t have an error function, so erf is our own CAS.erf, defined by the Gaussian integral

erfx=2π∫0xe−t2dt.

What you get back is a decimal interval of width at most 10−d and a theorem that erfq lies in it. The call only ever computes enclosures, and for the error function that’s usually what I want anyway: a number I can use in a proof, as accurate as I asked for.

Details and Options

  • q is a rational number with |q|≤10 and a denominator of at most 1000, and 1≤d≤30.
  • The theorem is a ≤ CAS.erf q ∧ CAS.erf q ≤ b ∧ b - a ≤ 1 / 10 ^ d for the printed interval [a,b], by CAS.erfCheck_sound.
  • The kernel checks a partial sum of the Taylor series with a bound on its tail, and an interval for π from Machin’s formula. The Output line says how many terms of the series the check used.
  • The call computes enclosures only, so #cas (erf q) is refused and points to #cas [N d] (erf q). The library proves the exact value CAS.erf_zero : CAS.erf 0 = 0.
  • There are no options.

Examples (11)#

Basic Examples (1)

Ten proved digits of erf12:

In[1]:=
#cas [N 10] (erf (1/2))
Out[1]=

decimal enclosure of width at most 10^-10, with 10 terms of the series

[0.52049987781, 0.52049987782]
[0.52049987781, 0.52049987782]
Domain
error function erf x = 2/√π ∫₀ˣ e^(-t²) dt at a rational point

Checked by Lean’s kernel: Enclosure of erf 1/2

0.52049987781 ≤ CAS.erf (1 / 2) ∧
  CAS.erf (1 / 2) ≤ 0.52049987782 ∧ 0.52049987782 - 0.52049987781 ≤ 1 / 10 ^ 10

from CAS.erfCheck_sound

The certificate: 1 checked step
  1. Enclosure of erf 1/2

    0.52049987781 ≤ CAS.erf (1 / 2) ∧
      CAS.erf (1 / 2) ≤ 0.52049987782 ∧ 0.52049987782 - 0.52049987781 ≤ 1 / 10 ^ 10

    Checked by Lean’s kernel · CAS.erfCheck_sound

Scope (4)

Thirty digits, the most the call gives:

In[2]:=
#cas [N 30] (erf 1)
Out[2]=

decimal enclosure of width at most 10^-30, with 30 terms of the series

[0.8427007929497148693412206350826, 0.8427007929497148693412206350827]
[0.8427007929497148693412206350826, 0.8427007929497148693412206350827]
Domain
error function erf x = 2/√π ∫₀ˣ e^(-t²) dt at a rational point

Checked by Lean’s kernel: Enclosure of erf 1

0.8427007929497148693412206350826 ≤ CAS.erf 1 ∧
  CAS.erf 1 ≤ 0.8427007929497148693412206350827 ∧
    0.8427007929497148693412206350827 - 0.8427007929497148693412206350826 ≤ 1 / 10 ^ 30

from CAS.erfCheck_sound

The certificate: 1 checked step
  1. Enclosure of erf 1

    0.8427007929497148693412206350826 ≤ CAS.erf 1 ∧
      CAS.erf 1 ≤ 0.8427007929497148693412206350827 ∧
        0.8427007929497148693412206350827 - 0.8427007929497148693412206350826 ≤ 1 / 10 ^ 30

    Checked by Lean’s kernel · CAS.erfCheck_sound


A negative point:

In[3]:=
#cas [N 20] (erf (-3))
Out[3]=

decimal enclosure of width at most 10^-20, with 57 terms of the series

[−0.999977909503001414559, −0.999977909503001414558]
[-0.999977909503001414559, -0.999977909503001414558]
Domain
error function erf x = 2/√π ∫₀ˣ e^(-t²) dt at a rational point

Checked by Lean’s kernel: Enclosure of erf -3

-0.999977909503001414559 ≤ CAS.erf (-3) ∧
  CAS.erf (-3) ≤ -0.999977909503001414558 ∧ -0.999977909503001414558 + 0.999977909503001414559 ≤ 1 / 10 ^ 20

from CAS.erfCheck_sound

The certificate: 1 checked step
  1. Enclosure of erf -3

    -0.999977909503001414559 ≤ CAS.erf (-3) ∧
      CAS.erf (-3) ≤ -0.999977909503001414558 ∧ -0.999977909503001414558 + 0.999977909503001414559 ≤ 1 / 10 ^ 20

    Checked by Lean’s kernel · CAS.erfCheck_sound


At q=10, the end of the range, the check takes 294 terms of the series, and the enclosure contains 1:

In[4]:=
#cas [N 10] (erf 10)
Out[4]=

decimal enclosure of width at most 10^-10, with 294 terms of the series

[0.99999999999, 1.00000000001]
[0.99999999999, 1.00000000001]
Domain
error function erf x = 2/√π ∫₀ˣ e^(-t²) dt at a rational point

Checked by Lean’s kernel: Enclosure of erf 10

0.99999999999 ≤ CAS.erf 10 ∧
  CAS.erf 10 ≤ 1.00000000001 ∧ 1.00000000001 - 0.99999999999 ≤ 1 / 10 ^ 10

from CAS.erfCheck_sound

The certificate: 1 checked step
  1. Enclosure of erf 10

    0.99999999999 ≤ CAS.erf 10 ∧
      CAS.erf 10 ≤ 1.00000000001 ∧ 1.00000000001 - 0.99999999999 ≤ 1 / 10 ^ 10

    Checked by Lean’s kernel · CAS.erfCheck_sound


At 0 the enclosure is the single point 0, and the report prints it as the exact value:

In[5]:=
#cas [N 5] (erf 0)
Out[5]=

exact value

0
Domain
error function erf x = 2/√π ∫₀ˣ e^(-t²) dt at a rational point

Checked by Lean’s kernel: Enclosure of erf 0

0 ≤ CAS.erf 0 ∧ CAS.erf 0 ≤ 0 ∧ 0 - 0 ≤ 1 / 10 ^ 5

from CAS.erfCheck_sound

The certificate: 1 checked step
  1. Enclosure of erf 0

    0 ≤ CAS.erf 0 ∧ CAS.erf 0 ≤ 0 ∧ 0 - 0 ≤ 1 / 10 ^ 5

    Checked by Lean’s kernel · CAS.erfCheck_sound

Applications (1)

A proof can take an enclosure as a hypothesis, here a coarser one than the printed interval. Only the three standard axioms are used:

In[6]:=
theorem erf_one_pos (h : 21 / 25 ≤ CAS.erf 1 ∧ CAS.erf 1 ≤ 17 / 20) : 0 < CAS.erf 1 := by
  linarith [h.1]

#print axioms erf_one_pos
Out[6]=

erf_one_pos depends on the axioms propext, Classical.choice, Quot.sound.

Properties and Relations (2)

integrate integrates Gaussians in terms of erf, with the theorem for every interval [a,b]:

In[7]:=
#cas [integrate x] (exp (-x ^ 2))
Out[7]=

antiderivative (with the interval integrals)

12πerf(x)
1/2*sqrt(pi)*erf(x)
Input (c e ^ (-α x ^ 2 + β x + γ), α > 0)
(exp (-x ^ 2))

Checked by Lean’s kernel: Integral of the input

∀ (a b : ℝ),
  ∫ (x : ℝ) in a..b, Real.exp (-x ^ 2) = 1 / 2 * √Real.pi * CAS.erf b - 1 / 2 * √Real.pi * CAS.erf a

from CAS.integral_gaussian_eq

The certificate: 2 checked steps
  1. Integral of the input

    ∀ (a b : ℝ),
      ∫ (x : ℝ) in a..b, Real.exp (-x ^ 2) = 1 / 2 * √Real.pi * CAS.erf b - 1 / 2 * √Real.pi * CAS.erf a

    Checked by Lean’s kernel · CAS.integral_gaussian_eq

  2. Derivative of the primitive

    ∀ (x : ℝ), HasDerivAt (fun x ↦ 1 / 2 * √Real.pi * CAS.erf x) (Real.exp (-x ^ 2)) x

    Checked by Lean’s kernel · CAS.hasDerivAt_gaussianPrimitive


derive differentiates erf, with erf′(x)=2πe−x2:

In[8]:=
#cas [derive x] (erf x)
Out[8]=

derivative

2πe−x2
2/sqrt(pi)*exp(-x^2)
Input (sum of c * erf (A x + B))
(erf x)

Checked by Lean’s kernel: Derivative of the input

∀ (x : ℝ), HasDerivAt (fun x ↦ CAS.erf x) (2 / √Real.pi * Real.exp (-x ^ 2)) x

from CAS.hasDerivAt_erf

The certificate: 1 checked step
  1. Derivative of the input

    ∀ (x : ℝ), HasDerivAt (fun x ↦ CAS.erf x) (2 / √Real.pi * Real.exp (-x ^ 2)) x

    Checked by Lean’s kernel · CAS.hasDerivAt_erf

Possible Issues (3)

#cas gives no exact value of erf, and the message points to [N d]:

In[9]:=
#cas (erf 1)
Out[9]=

Error

`#cas` computes no exact value of `erf x`; `#cas [N d] (erf x)` gives its digits

The point is a rational with |q|≤10 and a denominator of at most 1000. The series converges slowly far from 0, and the bound keeps the kernel’s partial sum short:

In[10]:=
#cas [N 10] (erf 11)
Out[10]=

Error

erf accepts rational points with |q| ≤ 10 and a denominator of at most 1000

The call gives at most 30 digits:

In[11]:=
#cas [N 31] (erf 1)
Out[11]=

Error

erf accepts at most 30 digits

See Also

N · integrate · derive · BesselJ · enclose