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)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
What you get back is a decimal interval of width at most and a theorem that 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.
Examples (11)#
Basic Examples (1)
Ten proved digits of :
#cas [N 10] (erf (1/2))
decimal enclosure of width at most 10^-10, with 10 terms of the series
[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
Enclosure of erf 1/2
0.52049987781 ≤ CAS.erf (1 / 2) ∧ CAS.erf (1 / 2) ≤ 0.52049987782 ∧ 0.52049987782 - 0.52049987781 ≤ 1 / 10 ^ 10
Scope (4)
Thirty digits, the most the call gives:
#cas [N 30] (erf 1)
decimal enclosure of width at most 10^-30, with 30 terms of the series
[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
Enclosure of erf 1
0.8427007929497148693412206350826 ≤ CAS.erf 1 ∧ CAS.erf 1 ≤ 0.8427007929497148693412206350827 ∧ 0.8427007929497148693412206350827 - 0.8427007929497148693412206350826 ≤ 1 / 10 ^ 30
A negative point:
#cas [N 20] (erf (-3))
decimal enclosure of width at most 10^-20, with 57 terms of the series
[-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
Enclosure of erf -3
-0.999977909503001414559 ≤ CAS.erf (-3) ∧ CAS.erf (-3) ≤ -0.999977909503001414558 ∧ -0.999977909503001414558 + 0.999977909503001414559 ≤ 1 / 10 ^ 20
At , the end of the range, the check takes 294 terms of the series, and the enclosure contains 1:
#cas [N 10] (erf 10)
decimal enclosure of width at most 10^-10, with 294 terms of the series
[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
Enclosure of erf 10
0.99999999999 ≤ CAS.erf 10 ∧ CAS.erf 10 ≤ 1.00000000001 ∧ 1.00000000001 - 0.99999999999 ≤ 1 / 10 ^ 10
At 0 the enclosure is the single point 0, and the report prints it as the exact value:
#cas [N 5] (erf 0)
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
Enclosure of erf 0
0 ≤ CAS.erf 0 ∧ CAS.erf 0 ≤ 0 ∧ 0 - 0 ≤ 1 / 10 ^ 5
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:
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
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 :
#cas [integrate x] (exp (-x ^ 2))
antiderivative (with the interval integrals)
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
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
Derivative of the primitive
∀ (x : ℝ), HasDerivAt (fun x ↦ 1 / 2 * √Real.pi * CAS.erf x) (Real.exp (-x ^ 2)) x
derive differentiates erf, with :
#cas [derive x] (erf x)
derivative
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
Derivative of the input
∀ (x : ℝ), HasDerivAt (fun x ↦ CAS.erf x) (2 / √Real.pi * Real.exp (-x ^ 2)) x
Possible Issues (3)
#cas gives no exact value of erf, and the message points to [N d]:
#cas (erf 1)
Error
`#cas` computes no exact value of `erf x`; `#cas [N d] (erf x)` gives its digits
The point is a rational with and a denominator of at most 1000. The series converges slowly far from 0, and the bound keeps the kernel’s partial sum short:
#cas [N 10] (erf 11)
Error
erf accepts rational points with |q| ≤ 10 and a denominator of at most 1000
The call gives at most 30 digits:
#cas [N 31] (erf 1)
Error
erf accepts at most 30 digits
