Mode of #cas
fourierCos
The coefficients of the cosine series on [0, L] as exact functions of n, with a theorem about the integrals.
#cas [fourierCos x n L] fThe cosine series on is the one that comes up for heat flow in a rod with insulated ends, and fourierCos computes its coefficients. The series is . The theorem is about Mathlib’s interval integrals over , with one statement for and one for that holds at every .
Each term of f is integrated by parts, and then and turn the result into a closed form. For the sine series on the same interval, use fourierSin, and for the full series on , use fourier.
Examples (9)#
Basic Examples (2)
The cosine series of on , with the theorem for every :
#cas [fourierCos x n 1] (x)
cosine series coefficients
a₀ = 1, aₙ = -(2*(1 - (-1)^n)/(n^2*pi^2))- Domain
x ∈ [0, 1], n ≥ 1
Checked by Lean’s kernel: The cosine coefficients on [0, L]
2 * ∫ (x : ℝ) in 0..1, x = 1 ∧ ∀ (n : ℕ), 0 < n → 2 * ∫ (x : ℝ) in 0..1, x * Real.cos (↑n * Real.pi * x) = -(2 * (1 - (-1) ^ n)) / (↑n ^ 2 * Real.pi ^ 2)
The certificate: 1 checked step
The cosine coefficients on [0, L]
2 * ∫ (x : ℝ) in 0..1, x = 1 ∧ ∀ (n : ℕ), 0 < n → 2 * ∫ (x : ℝ) in 0..1, x * Real.cos (↑n * Real.pi * x) = -(2 * (1 - (-1) ^ n)) / (↑n ^ 2 * Real.pi ^ 2)
On , with in the function:
#cas [fourierCos x n pi] (x * (pi - x))
cosine series coefficients
a₀ = 1/3*pi^2, aₙ = -(2*(1 + (-1)^n)/n^2)- Domain
x ∈ [0, pi], n ≥ 1
Checked by Lean’s kernel: The cosine coefficients on [0, L]
2 / Real.pi * ∫ (x : ℝ) in 0..Real.pi, x * (Real.pi - x) = 1 / 3 * Real.pi ^ 2 ∧ ∀ (n : ℕ), 0 < n → 2 / Real.pi * ∫ (x : ℝ) in 0..Real.pi, x * (Real.pi - x) * Real.cos (↑n * x) = -(2 * (1 + (-1) ^ n)) / ↑n ^ 2
The certificate: 1 checked step
The cosine coefficients on [0, L]
2 / Real.pi * ∫ (x : ℝ) in 0..Real.pi, x * (Real.pi - x) = 1 / 3 * Real.pi ^ 2 ∧ ∀ (n : ℕ), 0 < n → 2 / Real.pi * ∫ (x : ℝ) in 0..Real.pi, x * (Real.pi - x) * Real.cos (↑n * x) = -(2 * (1 + (-1) ^ n)) / ↑n ^ 2
Scope (1)
Any positive rational length. On the frequencies are :
#cas [fourierCos x n 2] (x ^ 2)
cosine series coefficients
a₀ = 8/3, aₙ = 16*(-1)^n/(n^2*pi^2)- Domain
x ∈ [0, 2], n ≥ 1
Checked by Lean’s kernel: The cosine coefficients on [0, L]
2 / 2 * ∫ (x : ℝ) in 0..2, x ^ 2 = 8 / 3 ∧ ∀ (n : ℕ), 0 < n → 2 / 2 * ∫ (x : ℝ) in 0..2, x ^ 2 * Real.cos (↑n * Real.pi / 2 * x) = 16 * (-1) ^ n / (↑n ^ 2 * Real.pi ^ 2)
The certificate: 1 checked step
The cosine coefficients on [0, L]
2 / 2 * ∫ (x : ℝ) in 0..2, x ^ 2 = 8 / 3 ∧ ∀ (n : ℕ), 0 < n → 2 / 2 * ∫ (x : ℝ) in 0..2, x ^ 2 * Real.cos (↑n * Real.pi / 2 * x) = 16 * (-1) ^ n / (↑n ^ 2 * Real.pi ^ 2)
Applications (1)
The integral behind of on , in a proof. cas proves it, and only the three standard axioms are used:
theorem fourierCos_a_one : ∫ x in (0 : ℝ)..1, x * Real.cos (Real.pi * x) = -(2 / Real.pi ^ 2) := by cas #print axioms fourierCos_a_one
fourierCos_a_one depends on the axioms propext, Classical.choice, Quot.sound.
Properties and Relations (2)
The cosine series on is the Fourier series on of the even extension of f. For the even function , the cosine series has the coefficients that fourier gives, times those on above:
#cas [fourier x n] (x^2)
Fourier coefficients
a₀ = 2/3*pi^2, aₙ = 4*(-1)^n/n^2, bₙ = 0- Domain
x ∈ [-π, π], n ≥ 1
Checked by Lean’s kernel: The Fourier coefficients on [-π, π], by integration by parts
1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x ^ 2 = 2 / 3 * Real.pi ^ 2 ∧ (∀ (n : ℕ), 0 < n → 1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x ^ 2 * Real.cos (↑n * x) = 4 * (-1) ^ n / ↑n ^ 2) ∧ ∀ (n : ℕ), 0 < n → 1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x ^ 2 * Real.sin (↑n * x) = 0
The certificate: 1 checked step
The Fourier coefficients on [-π, π], by integration by parts
1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x ^ 2 = 2 / 3 * Real.pi ^ 2 ∧ (∀ (n : ℕ), 0 < n → 1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x ^ 2 * Real.cos (↑n * x) = 4 * (-1) ^ n / ↑n ^ 2) ∧ ∀ (n : ℕ), 0 < n → 1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x ^ 2 * Real.sin (↑n * x) = 0
The sine series of decays faster than its cosine series. The odd extension to has a continuous derivative, and is of order . The even extension has corners, and above is of order :
#cas [fourierSin x n pi] (x * (pi - x))
sine series coefficients
bₙ = 4*(1 - (-1)^n)/(n^3*pi)- Domain
x ∈ [0, pi], n ≥ 1
Checked by Lean’s kernel: The sine coefficients on [0, L]
∀ (n : ℕ), 0 < n → 2 / Real.pi * ∫ (x : ℝ) in 0..Real.pi, x * (Real.pi - x) * Real.sin (↑n * x) = 4 * (1 - (-1) ^ n) / (↑n ^ 3 * Real.pi)
The certificate: 1 checked step
The sine coefficients on [0, L]
∀ (n : ℕ), 0 < n → 2 / Real.pi * ∫ (x : ℝ) in 0..Real.pi, x * (Real.pi - x) * Real.sin (↑n * x) = 4 * (1 - (-1) ^ n) / (↑n ^ 3 * Real.pi)
Possible Issues (3)
Sines and cosines are refused on . fourier takes them on :
#cas [fourierCos x n pi] (sin x)
Error
fourierCos: on [0, L] the function must be a sum of terms c x ^ j e ^ (a x)
The length is a positive rational number or a positive rational multiple of , such as 2 * pi / 3:
#cas [fourierCos x n (sqrt 2)] (x)
Error
fourierCos: L must be a positive rational number or a rational multiple of π
The length must be positive:
#cas [fourierCos x n 0] (x)
Error
fourierCos: L must be positive
