Mode of #cas
series
A Taylor or Laurent expansion at a rational point, with exact coefficients and a little-o remainder theorem.
#cas [series x a n] eseries computes the first terms of an expansion from the derivatives at the expansion point, with exact rational coefficients. The theorem is a little-o statement about Mathlib’s Asymptotics.IsLittleO. It is the precise form of what we usually write as “”.
Examples (18)#
Basic Examples (2)
The exponential at 0, with the theorem about the remainder:
#cas [series x 0 6] (exp x)
Taylor polynomial with exact coefficients
1 + x + 1/2*x^2 + 1/6*x^3 + 1/24*x^4 + 1/120*x^5 + 1/720*x^6 + o(x^6)- Domain
x → 0
Checked by Lean’s kernel: Taylor expansion with a little-o remainder
(fun x ↦ Real.exp x - (1 + x + 1 / 2 * x ^ 2 + 1 / 6 * x ^ 3 + 1 / 24 * x ^ 4 + 1 / 120 * x ^ 5 + 1 / 720 * x ^ 6)) =o[nhds 0] fun x ↦ x ^ 6
The certificate: 1 checked step
Taylor expansion with a little-o remainder
(fun x ↦ Real.exp x - (1 + x + 1 / 2 * x ^ 2 + 1 / 6 * x ^ 3 + 1 / 24 * x ^ 4 + 1 / 120 * x ^ 5 + 1 / 720 * x ^ 6)) =o[nhds 0] fun x ↦ x ^ 6
The computation
Checked coefficients
Coefficients of (x - 0)^0, …, ^6: [1, 1, 1/2, 1/6, 1/24, 1/120, 1/720]
A Laurent series. has a pole of order 1 at 0:
#cas [series x 0 3] (1 / sin x)
Laurent series with a pole of order 1
1/x + 1/6*x + 7/360*x^3 + o(x^3)- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Laurent expansion with a little-o remainder
(fun x ↦ 1 / Real.sin x - (x⁻¹ + 1 / 6 * x + 7 / 360 * x ^ 3)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 3
The certificate: 1 checked step
Laurent expansion with a little-o remainder
(fun x ↦ 1 / Real.sin x - (x⁻¹ + 1 / 6 * x + 7 / 360 * x ^ 3)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 3
The computation
Series division
the denominator vanishes to order 1; numerator coefficients [1, 0, 0, 0, 0], denominator coefficients [0, 1, 0, -1/6, 0, 1/120]
Scope (8)
The sine, to order 7:
#cas [series x 0 7] (sin x)
Taylor polynomial with exact coefficients
x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + o(x^7)- Domain
x → 0
Checked by Lean’s kernel: Taylor expansion with a little-o remainder
(fun x ↦ Real.sin x - (x - 1 / 6 * x ^ 3 + 1 / 120 * x ^ 5 - 1 / 5040 * x ^ 7)) =o[nhds 0] fun x ↦ x ^ 7
The certificate: 1 checked step
Taylor expansion with a little-o remainder
(fun x ↦ Real.sin x - (x - 1 / 6 * x ^ 3 + 1 / 120 * x ^ 5 - 1 / 5040 * x ^ 7)) =o[nhds 0] fun x ↦ x ^ 7
The computation
Checked coefficients
Coefficients of (x - 0)^0, …, ^7: [0, 1, 0, -1/6, 0, 1/120, 0, -1/5040]
The logarithm at 1, where its value is rational:
#cas [series x 1 4] (log x)
Taylor polynomial with exact coefficients
x - 1 - 1/2*(x - 1)^2 + 1/3*(x - 1)^3 - 1/4*(x - 1)^4 + o((x - 1)^4)- Domain
x → 1
Checked by Lean’s kernel: Taylor expansion with a little-o remainder
(fun x ↦ Real.log x - (x - 1 - 1 / 2 * (x - 1) ^ 2 + 1 / 3 * (x - 1) ^ 3 - 1 / 4 * (x - 1) ^ 4)) =o[nhds 1] fun x ↦ (x - 1) ^ 4
The certificate: 1 checked step
Taylor expansion with a little-o remainder
(fun x ↦ Real.log x - (x - 1 - 1 / 2 * (x - 1) ^ 2 + 1 / 3 * (x - 1) ^ 3 - 1 / 4 * (x - 1) ^ 4)) =o[nhds 1] fun x ↦ (x - 1) ^ 4
The computation
Checked coefficients
Coefficients of (x - 1)^0, …, ^4: [0, 1, -1/2, 1/3, -1/4]
A composition:
#cas [series x 0 6] (exp (sin x))
Taylor polynomial with exact coefficients
1 + x + 1/2*x^2 - 1/8*x^4 - 1/15*x^5 - 1/240*x^6 + o(x^6)- Domain
x → 0
Checked by Lean’s kernel: Taylor expansion with a little-o remainder
(fun x ↦ Real.exp (Real.sin x) - (1 + x + 1 / 2 * x ^ 2 - 1 / 8 * x ^ 4 - 1 / 15 * x ^ 5 - 1 / 240 * x ^ 6)) =o[nhds 0] fun x ↦ x ^ 6
The certificate: 1 checked step
Taylor expansion with a little-o remainder
(fun x ↦ Real.exp (Real.sin x) - (1 + x + 1 / 2 * x ^ 2 - 1 / 8 * x ^ 4 - 1 / 15 * x ^ 5 - 1 / 240 * x ^ 6)) =o[nhds 0] fun x ↦ x ^ 6
The computation
Checked coefficients
Coefficients of (x - 0)^0, …, ^6: [1, 1, 1/2, 0, -1/8, -1/15, -1/240]
A negative rational center:
#cas [series x -1/2 2] (1 / (1 - x))
Taylor polynomial with exact coefficients
2/3 + 4/9*(x + 1/2) + 8/27*(x + 1/2)^2 + o((x + 1/2)^2)- Domain
x → -1/2
Checked by Lean’s kernel: Taylor expansion with a little-o remainder
(fun x ↦ 1 / (1 - x) - (2 / 3 + 4 / 9 * (x + 1 / 2) + 8 / 27 * (x + 1 / 2) ^ 2)) =o[nhds (-1 / 2)] fun x ↦ (x + 1 / 2) ^ 2
The certificate: 1 checked step
Taylor expansion with a little-o remainder
(fun x ↦ 1 / (1 - x) - (2 / 3 + 4 / 9 * (x + 1 / 2) + 8 / 27 * (x + 1 / 2) ^ 2)) =o[nhds (-1 / 2)] fun x ↦ (x + 1 / 2) ^ 2
The computation
Checked coefficients
Coefficients of (x + 1/2)^0, …, ^2: [2/3, 4/9, 8/27]
A center close to the singularity of the square root. The theorem only needs the derivatives at the point:
#cas [series x 1/10000 2] (sqrt x)
Taylor polynomial with exact coefficients
1/100 + 50*(x - 1/10000) - 125000*(x - 1/10000)^2 + o((x - 1/10000)^2)- Domain
x → 1/10000
Checked by Lean’s kernel: Taylor expansion with a little-o remainder
(fun x ↦ √x - (1 / 100 + 50 * (x - 1 / 10000) - 125000 * (x - 1 / 10000) ^ 2)) =o[nhds (1 / 10000)] fun x ↦ (x - 1 / 10000) ^ 2
The certificate: 1 checked step
Taylor expansion with a little-o remainder
(fun x ↦ √x - (1 / 100 + 50 * (x - 1 / 10000) - 125000 * (x - 1 / 10000) ^ 2)) =o[nhds (1 / 10000)] fun x ↦ (x - 1 / 10000) ^ 2
The computation
Checked coefficients
Coefficients of (x - 1/10000)^0, …, ^2: [1/100, 50, -125000]
A pole of order 2:
#cas [series x 0 2] (1 / sin x ^ 2)
Laurent series with a pole of order 2
1/x^2 + 1/3 + 1/15*x^2 + o(x^2)- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Laurent expansion with a little-o remainder
(fun x ↦ 1 / Real.sin x ^ 2 - ((x ^ 2)⁻¹ + 1 / 3 + 1 / 15 * x ^ 2)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 2
The certificate: 1 checked step
Laurent expansion with a little-o remainder
(fun x ↦ 1 / Real.sin x ^ 2 - ((x ^ 2)⁻¹ + 1 / 3 + 1 / 15 * x ^ 2)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 2
The computation
Series division
the denominator vanishes to order 2; numerator coefficients [1, 0, 0, 0, 0], denominator coefficients [0, 0, 1, 0, -1/3, 0, 2/45]
A pole away from 0. The answer is in powers of :
#cas [series x 1 2] (1 / (x^2 - 1))
Laurent series with a pole of order 1
1/(2*(x - 1)) - 1/4 + 1/8*(x - 1) - 1/16*(x - 1)^2 + o((x - 1)^2)- Domain
x → 1, x ≠ 1
Checked by Lean’s kernel: Laurent expansion with a little-o remainder
(fun x ↦ 1 / (x ^ 2 - 1) - (1 / 2 * (x - 1)⁻¹ - 1 / 4 + 1 / 8 * (x - 1) - 1 / 16 * (x - 1) ^ 2)) =o[nhdsWithin 1 {1}ᶜ] fun x ↦ (x - 1) ^ 2
The certificate: 1 checked step
Laurent expansion with a little-o remainder
(fun x ↦ 1 / (x ^ 2 - 1) - (1 / 2 * (x - 1)⁻¹ - 1 / 4 + 1 / 8 * (x - 1) - 1 / 16 * (x - 1) ^ 2)) =o[nhdsWithin 1 {1}ᶜ] fun x ↦ (x - 1) ^ 2
The computation
Series division
the denominator vanishes to order 1; numerator coefficients [1, 0, 0, 0], denominator coefficients [0, 2, 1, 0, 0]
A removable singularity gives a Taylor series:
#cas [series x 0 4] (sin x / x)
Taylor series of a removable singularity
1 - 1/6*x^2 + 1/120*x^4 + o(x^4)- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Laurent expansion with a little-o remainder
(fun x ↦ Real.sin x / x - (1 - 1 / 6 * x ^ 2 + 1 / 120 * x ^ 4)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 4
The certificate: 1 checked step
Laurent expansion with a little-o remainder
(fun x ↦ Real.sin x / x - (1 - 1 / 6 * x ^ 2 + 1 / 120 * x ^ 4)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 4
The computation
Series division
the denominator vanishes to order 1; numerator coefficients [0, 1, 0, -1/6, 0, 1/120], denominator coefficients [0, 1, 0, 0, 0, 0, 0]
Applications (1)
The little-o statement in a proof. From the printed theorem for to order 3, the quotient by tends to 0. Only the three standard axioms are used:
open Filter Topology in theorem series_sin_remainder (h : (fun x : ℝ ↦ Real.sin x - (x - 1 / 6 * x ^ 3)) =o[𝓝 0] fun x ↦ x ^ 3) : Tendsto (fun x : ℝ ↦ (Real.sin x - (x - 1 / 6 * x ^ 3)) / x ^ 3) (𝓝 0) (𝓝 0) := h.tendsto_div_nhds_zero #print axioms series_sin_remainder
series_sin_remainder depends on the axioms propext, Classical.choice, Quot.sound.
Properties and Relations (2)
The coefficient of in the series of is the limit of at 0, which limit proves:
#cas [limit x → 0] ((exp x - 1 - x) / x^2)
exact limit
1/2- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Limit from the leading terms of order 2
Filter.Tendsto (fun x ↦ (Real.exp x - 1 - x) / x ^ 2) (nhdsWithin 0 {0}ᶜ) (nhds (1 / 2))
The certificate: 1 checked step
Limit from the leading terms of order 2
Filter.Tendsto (fun x ↦ (Real.exp x - 1 - x) / x ^ 2) (nhdsWithin 0 {0}ᶜ) (nhds (1 / 2))
The computation
Leading terms
Numerator 1/2 (x - a)^2, denominator 1 (x - a)^2 (not proof)
The series of at 0 is the geometric series:
#cas [series x 0 5] (1 / (1 - x))
Taylor polynomial with exact coefficients
1 + x + x^2 + x^3 + x^4 + x^5 + o(x^5)- Domain
x → 0
Checked by Lean’s kernel: Taylor expansion with a little-o remainder
(fun x ↦ 1 / (1 - x) - (1 + x + x ^ 2 + x ^ 3 + x ^ 4 + x ^ 5)) =o[nhds 0] fun x ↦ x ^ 5
The certificate: 1 checked step
Taylor expansion with a little-o remainder
(fun x ↦ 1 / (1 - x) - (1 + x + x ^ 2 + x ^ 3 + x ^ 4 + x ^ 5)) =o[nhds 0] fun x ↦ x ^ 5
The computation
Checked coefficients
Coefficients of (x - 0)^0, …, ^5: [1, 1, 1, 1, 1, 1]
Possible Issues (3)
The expression must be smooth at the center. has no derivative at 0:
#cas [series x 0 3] (abs x)
Error
series: the domain checker did not certify that the expression and its derivatives through order 3 are defined at 0
The coefficients must be exact, and the logarithm has a known value at 1, not at 0. The message lists the known values:
#cas [series x 0 3] (log x)
Error
series: the derivative of order 0 at 0 is not an exact rational number (exact values are known for sin, cos, exp, atan, asin at 0, log at 1, and square roots of rational squares)
The order is at most 12:
#cas [series x 0 13] (sin x)
Error
series accepts orders up to 12
Neat Examples (2)
The coefficients of are the Bernoulli numbers divided by factorials:
#cas [series x 0 3] (1 / (exp x - 1))
Laurent series with a pole of order 1
1/x - 1/2 + 1/12*x - 1/720*x^3 + o(x^3)- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Laurent expansion with a little-o remainder
(fun x ↦ 1 / (Real.exp x - 1) - (x⁻¹ - 1 / 2 + 1 / 12 * x - 1 / 720 * x ^ 3)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 3
The certificate: 1 checked step
Laurent expansion with a little-o remainder
(fun x ↦ 1 / (Real.exp x - 1) - (x⁻¹ - 1 / 2 + 1 / 12 * x - 1 / 720 * x ^ 3)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 3
The computation
Series division
the denominator vanishes to order 1; numerator coefficients [1, 0, 0, 0, 0], denominator coefficients [0, 1, 1/2, 1/6, 1/24, 1/120]
The cotangent:
#cas [series x 0 3] (cos x / sin x)
Laurent series with a pole of order 1
1/x - 1/3*x - 1/45*x^3 + o(x^3)- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Laurent expansion with a little-o remainder
(fun x ↦ Real.cos x / Real.sin x - (x⁻¹ - 1 / 3 * x - 1 / 45 * x ^ 3)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 3
The certificate: 1 checked step
Laurent expansion with a little-o remainder
(fun x ↦ Real.cos x / Real.sin x - (x⁻¹ - 1 / 3 * x - 1 / 45 * x ^ 3)) =o[nhdsWithin 0 {0}ᶜ] fun x ↦ x ^ 3
The computation
Series division
the denominator vanishes to order 1; numerator coefficients [1, 0, -1/2, 0, 1/24], denominator coefficients [0, 1, 0, -1/6, 0, 1/120]
