Mode of #cas
N
The first digits of a closed real expression, with a theorem that every printed digit is right.
#cas [N d] eN returns a decimal approximation and a theorem enclosing the exact value of e between that decimal and the next one away from zero. The theorem is about Mathlib’s Real.pi, Real.exp and Real.sqrt, and Lean’s kernel checks its proof. For to six digits the theorem is .
Examples (18)#
Basic Examples (3)
The square root of 2 to 20 digits:
#cas [N 20] (sqrt 2)
first 20 significant digits, truncated
1.4142135623730950488- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
14142135623730950488 / 10 ^ 19 ≤ √2 ∧ √2 < (14142135623730950488 + 1) / 10 ^ 19
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
14142135623730950488 / 10 ^ 19 ≤ √2 ∧ √2 < (14142135623730950488 + 1) / 10 ^ 19
The computation
Certified numerical evaluation
Working precision: 106 bits, 44 series terms, 84 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
A sum of two constants:
#cas [N 10] (exp 1 + pi)
first 10 significant digits, truncated
5.859874482- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
5859874482 / 10 ^ 9 ≤ Real.exp 1 + Real.pi ∧ Real.exp 1 + Real.pi < (5859874482 + 1) / 10 ^ 9
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
5859874482 / 10 ^ 9 ≤ Real.exp 1 + Real.pi ∧ Real.exp 1 + Real.pi < (5859874482 + 1) / 10 ^ 9
The computation
Certified numerical evaluation
Working precision: 73 bits, 34 series terms, 62 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
Fifty digits of :
#cas [N 50] (pi)
first 50 significant digits, truncated
3.1415926535897932384626433832795028841971693993751- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
31415926535897932384626433832795028841971693993751 / 10 ^ 49 ≤ Real.pi ∧ Real.pi < (31415926535897932384626433832795028841971693993751 + 1) / 10 ^ 49
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
31415926535897932384626433832795028841971693993751 / 10 ^ 49 ≤ Real.pi ∧ Real.pi < (31415926535897932384626433832795028841971693993751 + 1) / 10 ^ 49
The computation
Certified numerical evaluation
Working precision: 206 bits, 74 series terms, 150 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
Scope (6)
Trigonometric values, and an inverse function:
#cas [N 30] (sin 1)
first 30 significant digits, truncated
0.841470984807896506652502321630- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
841470984807896506652502321630 / 10 ^ 30 ≤ Real.sin 1 ∧ Real.sin 1 < (841470984807896506652502321630 + 1) / 10 ^ 30
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
841470984807896506652502321630 / 10 ^ 30 ≤ Real.sin 1 ∧ Real.sin 1 < (841470984807896506652502321630 + 1) / 10 ^ 30
The computation
Certified numerical evaluation
Working precision: 139 bits, 54 series terms, 106 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
#cas [N 30] (sin (π / 7))
first 30 significant digits, truncated
0.433883739117558120475768332848- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
433883739117558120475768332848 / 10 ^ 30 ≤ Real.sin (Real.pi / 7) ∧ Real.sin (Real.pi / 7) < (433883739117558120475768332848 + 1) / 10 ^ 30
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
433883739117558120475768332848 / 10 ^ 30 ≤ Real.sin (Real.pi / 7) ∧ Real.sin (Real.pi / 7) < (433883739117558120475768332848 + 1) / 10 ^ 30
The computation
Certified numerical evaluation
Working precision: 139 bits, 54 series terms, 106 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
#cas [N 30] (arcsin (1 / 2))
first 30 significant digits, truncated
0.523598775598298873077107230546- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
523598775598298873077107230546 / 10 ^ 30 ≤ Real.arcsin (1 / 2) ∧ Real.arcsin (1 / 2) < (523598775598298873077107230546 + 1) / 10 ^ 30
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
523598775598298873077107230546 / 10 ^ 30 ≤ Real.arcsin (1 / 2) ∧ Real.arcsin (1 / 2) < (523598775598298873077107230546 + 1) / 10 ^ 30
The computation
Certified numerical evaluation
Working precision: 139 bits, 54 series terms, 106 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
A cube root, written as a real power:
#cas [N 30] (2 ^ (1 / 3 : ℝ))
first 30 significant digits, truncated
1.25992104989487316476721060727- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
125992104989487316476721060727 / 10 ^ 29 ≤ (2 : ℝ) ^ (1 / 3 : ℝ) ∧ (2 : ℝ) ^ (1 / 3 : ℝ) < (125992104989487316476721060727 + 1) / 10 ^ 29
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
125992104989487316476721060727 / 10 ^ 29 ≤ (2 : ℝ) ^ (1 / 3 : ℝ) ∧ (2 : ℝ) ^ (1 / 3 : ℝ) < (125992104989487316476721060727 + 1) / 10 ^ 29
The computation
Certified numerical evaluation
Working precision: 139 bits, 54 series terms, 106 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
A negative value. Its digits are truncated toward zero too:
#cas [N 25] (-log 2)
first 25 significant digits, truncated
-0.6931471805599453094172321- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
-(6931471805599453094172321 + 1) / 10 ^ 25 < -Real.log 2 ∧ -Real.log 2 ≤ -6931471805599453094172321 / 10 ^ 25
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
-(6931471805599453094172321 + 1) / 10 ^ 25 < -Real.log 2 ∧ -Real.log 2 ≤ -6931471805599453094172321 / 10 ^ 25
The computation
Certified numerical evaluation
Working precision: 123 bits, 49 series terms, 95 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
A large value gets an exponent:
#cas [N 20] (exp 100)
first 20 significant digits, truncated
2.6881171418161354484 × 10^43- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
26881171418161354484 * 10 ^ 24 ≤ Real.exp 100 ∧ Real.exp 100 < (26881171418161354484 + 1) * 10 ^ 24
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
26881171418161354484 * 10 ^ 24 ≤ Real.exp 100 ∧ Real.exp 100 < (26881171418161354484 + 1) * 10 ^ 24
The computation
Certified numerical evaluation
Working precision: 106 bits, 44 series terms, 84 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
The error function and a Bessel function have their own series. The report gives a decimal enclosure of width at most and the number of terms of the series:
#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
#cas [N 10] (BesselJ 0 1)
decimal enclosure of width at most 10^-10, with 8 terms of the series
[0.76519768655, 0.76519768656]- Domain
Bessel function J_n at a rational point
Checked by Lean’s kernel: Enclosure of BesselJ 0 1
∃ r, Complex.besselJ ↑0 ↑1 = ↑r ∧ ↑(15303953731 / 20000000000) ≤ r ∧ r ≤ ↑(4782485541 / 6250000000) ∧ ↑(4782485541 / 6250000000) - ↑(15303953731 / 20000000000) ≤ 1 / 10 ^ 10
The certificate: 1 checked step
Enclosure of BesselJ 0 1
∃ r, Complex.besselJ ↑0 ↑1 = ↑r ∧ ↑(15303953731 / 20000000000) ≤ r ∧ r ≤ ↑(4782485541 / 6250000000) ∧ ↑(4782485541 / 6250000000) - ↑(15303953731 / 20000000000) ≤ 1 / 10 ^ 10
An orthogonal polynomial at a rational point has an exact value, and you get it together with its digits:
#cas [N 10] (ChebyshevT 5 (1/3))
exact rational value and its first 10 significant digits, truncated
241/243 ≈ 0.9917695473- Domain
ChebyshevT polynomial at a rational point
Checked by Lean’s kernel: Exact value and digits of ChebyshevT 5
Polynomial.eval (1 / 3) (Polynomial.Chebyshev.T ℝ 5) = 241 / 243 ∧ 9917695473 / 10 ^ 10 ≤ Polynomial.eval (1 / 3) (Polynomial.Chebyshev.T ℝ 5) ∧ Polynomial.eval (1 / 3) (Polynomial.Chebyshev.T ℝ 5) < (9917695473 + 1) / 10 ^ 10
The certificate: 1 checked step
Exact value and digits of ChebyshevT 5
Polynomial.eval (1 / 3) (Polynomial.Chebyshev.T ℝ 5) = 241 / 243 ∧ 9917695473 / 10 ^ 10 ≤ Polynomial.eval (1 / 3) (Polynomial.Chebyshev.T ℝ 5) ∧ Polynomial.eval (1 / 3) (Polynomial.Chebyshev.T ℝ 5) < (9917695473 + 1) / 10 ^ 10
Applications (2)
Digits in a proof. cega proves a bound that the printed digits of imply. Only the three standard axioms are used:
theorem digits_sqrt_two : Real.sqrt 2 ≤ 1.415 := by cega #print axioms digits_sqrt_two
digits_sqrt_two depends on the axioms propext, Classical.choice, Quot.sound.
A constant from a closed form. Here is to 40 digits:
#cas [N 40] (atan (1 / 3) + log 3 + sqrt 5)
first 40 significant digits, truncated
3.656430820564541581205823520012463259108- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
3656430820564541581205823520012463259108 / 10 ^ 39 ≤ Real.arctan (1 / 3) + Real.log 3 + √5 ∧ Real.arctan (1 / 3) + Real.log 3 + √5 < (3656430820564541581205823520012463259108 + 1) / 10 ^ 39
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
3656430820564541581205823520012463259108 / 10 ^ 39 ≤ Real.arctan (1 / 3) + Real.log 3 + √5 ∧ Real.arctan (1 / 3) + Real.log 3 + √5 < (3656430820564541581205823520012463259108 + 1) / 10 ^ 39
The computation
Certified numerical evaluation
Working precision: 172 bits, 64 series terms, 128 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
Properties and Relations (2)
enclose gives an interval with rational endpoints instead of digits. Its precision is set by (prec := n):
#cas [enclose] (sqrt 2)
certified interval in ℝ
[181/128, 5793/4096]- Domain
closed real expression- Upper bound
5793/4096- Absolute bound
5793/4096- Center and radius
11585/8192 ± 1/8192
Checked by Lean’s kernel: Enclosure of the input
181 / 128 ≤ √2 ∧ √2 ≤ 5793 / 4096
from CAS.Tactic.BoxInequality.mem_of_enclosedOn_box
The certificate: 8 checked steps
Enclosure of the input
181 / 128 ≤ √2 ∧ √2 ≤ 5793 / 4096
Upper bound of the input
√2 ≤ 5793 / 4096
Absolute bound of the input
|√2| ≤ 5793 / 4096
Center and radius of the input
|√2 - 11585 / 8192| ≤ 1 / 8192
Certified enclosure
CAS.Certificate.EnclosedOn (CAS.Exact.exprFn (CAS.Verified.Expr.nat 2).sqrt) (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦ [].get coordinate) (↑181 / ↑128) (↑5793 / ↑4096)
Certified upper bound
CAS.Certificate.BoundOn (CAS.Exact.exprFn (CAS.Verified.Expr.nat 2).sqrt) (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦ [].get coordinate) (↑5793 / ↑4096)
Certified absolute bound
CAS.Certificate.BoundOn (fun x ↦ |CAS.Exact.exprFn (CAS.Verified.Expr.nat 2).sqrt x|) (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦ [].get coordinate) (↑5793 / ↑4096)
Certified center and radius
CAS.Certificate.ApproxOn (CAS.Exact.exprFn (CAS.Verified.Expr.nat 2).sqrt) (fun x ↦ ↑11585 / ↑8192) (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦ [].get coordinate) (↑1 / ↑8192)
The computation
Coordinates: none Certified domain: closed real expression
Certified numerical guarantee
Guarantee: the real value lies in the output interval
#cas (prec := 16) [enclose] (sqrt 2)
certified interval in ℝ
[92681/65536, 46341/32768]- Domain
closed real expression- Upper bound
46341/32768- Absolute bound
46341/32768- Center and radius
185363/131072 ± 1/131072
Checked by Lean’s kernel: Enclosure of the input
92681 / 65536 ≤ √2 ∧ √2 ≤ 46341 / 32768
from CAS.Tactic.BoxInequality.mem_of_enclosedOn_box
The certificate: 8 checked steps
Enclosure of the input
92681 / 65536 ≤ √2 ∧ √2 ≤ 46341 / 32768
Upper bound of the input
√2 ≤ 46341 / 32768
Absolute bound of the input
|√2| ≤ 46341 / 32768
Center and radius of the input
|√2 - 185363 / 131072| ≤ 1 / 131072
Certified enclosure
CAS.Certificate.EnclosedOn (CAS.Exact.exprFn (CAS.Verified.Expr.nat 2).sqrt) (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦ [].get coordinate) (↑92681 / ↑65536) (↑46341 / ↑32768)
Certified upper bound
CAS.Certificate.BoundOn (CAS.Exact.exprFn (CAS.Verified.Expr.nat 2).sqrt) (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦ [].get coordinate) (↑46341 / ↑32768)
Certified absolute bound
CAS.Certificate.BoundOn (fun x ↦ |CAS.Exact.exprFn (CAS.Verified.Expr.nat 2).sqrt x|) (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦ [].get coordinate) (↑46341 / ↑32768)
Certified center and radius
CAS.Certificate.ApproxOn (CAS.Exact.exprFn (CAS.Verified.Expr.nat 2).sqrt) (fun x ↦ ↑185363 / ↑131072) (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦ [].get coordinate) (↑1 / ↑131072)
The computation
Coordinates: none Certified domain: closed real expression
Certified numerical guarantee
Guarantee: the real value lies in the output interval Precision policy: exp order 16, sqrt digits 16, log terms 16, subdivision depth 2
The value has a short decimal expansion, and the report gives an enclosure. Every interval around that the evaluator finds holds numbers starting with 0.4 and numbers starting with 0.5, so no truncated digit can be proved:
#cas [N 20] (cos (pi / 3))
certified decimal enclosure
[0.49999999999999999999, 0.50000000000000000001]- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal enclosure
49999999999999999999 / 10 ^ 20 ≤ Real.cos (Real.pi / 3) ∧ Real.cos (Real.pi / 3) ≤ 50000000000000000001 / 10 ^ 20
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal enclosure
49999999999999999999 / 10 ^ 20 ≤ Real.cos (Real.pi / 3) ∧ Real.cos (Real.pi / 3) ≤ 50000000000000000001 / 10 ^ 20
The computation
Certified numerical evaluation
Working precision: 106 bits, 44 series terms, 84 logarithm terms Guarantee: the real value lies in the printed decimal enclosure
Possible Issues (4)
N evaluates closed expressions only. For an expression with a variable, enclose works on a box:
#cas [N 15] (x + 1)
Error
N needs a closed expression; free symbols: x
At least one digit, and at most cas.maxDigits:
#cas [N 0] (pi)
Error
N accepts between 1 and 2000 digits
set_option cas.maxDigits 10 in #cas [N 20] (pi)
Error
N accepts between 1 and 10 digits
The series of erf and BesselJ stop at 30 digits:
#cas [N 31] (erf 1)
Error
erf accepts at most 30 digits
Lean defines Real.log 0 = 0, but N evaluates a logarithm only when it has certified that the argument is positive:
#cas [N 10] (log 0)
Error
N could not enclose this expression: a logarithm or square root of a value not certified positive, a quotient by an interval containing zero, or a real power with a base not certified positive
Neat Examples (1)
A thousand digits of , each one proved:
#cas [N 1000] (pi)
first 1000 significant digits, truncated
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195909216420198- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195909216420198 / 10 ^ 999 ≤ Real.pi ∧ Real.pi < (3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195909216420198 + 1) / 10 ^ 999
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195909216420198 / 10 ^ 999 ≤ Real.pi ∧ Real.pi < (3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195909216420198 + 1) / 10 ^ 999
The computation
Certified numerical evaluation
Working precision: 3362 bits, 1024 series terms, 2240 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
See Also
enclose · nintegrate · findRoot · cega · Options
