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] f
gives the coefficients a0 and an of the cosine series of f on the interval from 0 to L, as exact functions of n for n≥1, and proves the integrals.

The cosine series on [0,L] is the one that comes up for heat flow in a rod with insulated ends, and fourierCos computes its coefficients. The series is a0/2+∑n≥1ancos(nπx/L). The theorem is about Mathlib’s interval integrals over [0,L], with one statement for a0 and one for an that holds at every n≥1.

Each term cxjeax of f is integrated by parts, and then sinnπ=0 and cosnπ=(−1)n 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.

Details and Options

  • For the printed coefficients, the theorem is 2 / L * ∫ x in 0..L, f = a₀ and, for every n : ℕ with 0 < n, 2 / L * ∫ x in 0..L, f * Real.cos (n * Real.pi * x / L) = aₙ. It is printed in simplified form, such as 2 * ∫ x in 0..1, f for L=1.
  • f is a sum of terms c * x ^ j * exp (a * x) with rational a, and π may appear in the coefficients c, as in x * (pi - x). Sines, cosines and other functions are refused.
  • L is a positive rational number or a positive rational multiple of π, such as 2 * pi / 3.
  • When the proof of the coefficients fails, the command is refused.
  • There are no options. In a proof, cas proves the integral behind a single coefficient, as under Applications.

Examples (9)#

Basic Examples (2)

The cosine series of x on [0,1], with the theorem for every n≥1:

In[1]:=
#cas [fourierCos x n 1] (x)
Out[1]=

cosine series coefficients

a0=1,an=−2(1−(−1)n)n2π2
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
  1. 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)

    Checked by Lean’s kernel


On [0,π], with π in the function:

In[2]:=
#cas [fourierCos x n pi] (x * (pi - x))
Out[2]=

cosine series coefficients

a0=13π2,an=−2(1+(−1)n)n2
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
  1. 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

    Checked by Lean’s kernel

Scope (1)

Any positive rational length. On [0,2] the frequencies are nπ/2:

In[3]:=
#cas [fourierCos x n 2] (x ^ 2)
Out[3]=

cosine series coefficients

a0=83,an=16(−1)nn2π2
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
  1. 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)

    Checked by Lean’s kernel

Applications (1)

The integral behind a1=−4/π2 of x on [0,1], in a proof. cas proves it, and only the three standard axioms are used:

In[4]:=
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
Out[4]=

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

Properties and Relations (2)

The cosine series on [0,π] is the Fourier series on [−π,π] of the even extension of f. For the even function x2, the cosine series has the coefficients that fourier gives, π2/4 times those on [0,2] above:

In[5]:=
#cas [fourier x n] (x^2)
Out[5]=

Fourier coefficients

a0=23π2,an=4(−1)nn2,bn=0
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
  1. 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

    Checked by Lean’s kernel


The sine series of x(π−x) decays faster than its cosine series. The odd extension to [−π,π] has a continuous derivative, and bn is of order 1/n3. The even extension has corners, and an above is of order 1/n2:

In[6]:=
#cas [fourierSin x n pi] (x * (pi - x))
Out[6]=

sine series coefficients

bn=4(1−(−1)n)n3π
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
  1. 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)

    Checked by Lean’s kernel

Possible Issues (3)

Sines and cosines are refused on [0,L]. fourier takes them on [−π,π]:

In[7]:=
#cas [fourierCos x n pi] (sin x)
Out[7]=

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:

In[8]:=
#cas [fourierCos x n (sqrt 2)] (x)
Out[8]=

Error

fourierCos: L must be a positive rational number or a rational multiple of π

The length must be positive:

In[9]:=
#cas [fourierCos x n 0] (x)
Out[9]=

Error

fourierCos: L must be positive

See Also

fourierSin · fourier · fourierTransform · integrate