Mode of #cas

fourierSin

The coefficients of the sine series on [0, L] as exact functions of n, with a theorem about the integrals.

#cas [fourierSin x n L] f
gives the coefficients bn of the sine series of f on the interval from 0 to L, as exact functions of n for n≥1, and proves the integrals.

The sine series on [0,L] is the one that comes up for a vibrating string with fixed ends, and fourierSin computes its coefficients. The series is ∑n≥1bnsin(nπx/L), and the theorem is about Mathlib’s interval integrals over [0,L], one for every n≥1.

Each term cxjeax of f is integrated by parts, and cosnπ=(−1)n gives the factors (−1)n you see in the result. For the cosine series on the same interval, use fourierCos, and for the full series on [−π,π], use fourier.

Details and Options

  • For the printed bₙ, the theorem is that for every n : ℕ with 0 < n, 2 / L * ∫ x in 0..L, f * Real.sin (n * Real.pi * x / L) = bₙ. It is printed in simplified form, such as Real.sin (n * x) for L=π.
  • 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 sine series of x(π−x) on [0,π], with the theorem for every n≥1. The coefficients for even n are 0:

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

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


The sine series of x on [0,1]:

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

sine series coefficients

bn=2(−1)n+1nπ
bₙ = 2*(-1)^(n + 1)/(n*pi)
Domain
x ∈ [0, 1], n ≥ 1

Checked by Lean’s kernel: The sine coefficients on [0, L]

∀ (n : ℕ),
  0 < n → 2 * ∫ (x : ℝ) in 0..1, x * Real.sin (↑n * Real.pi * x) = 2 * (-1) ^ (n + 1) / (↑n * Real.pi)
The certificate: 1 checked step
  1. The sine coefficients on [0, L]

    ∀ (n : ℕ),
      0 < n → 2 * ∫ (x : ℝ) in 0..1, x * Real.sin (↑n * Real.pi * x) = 2 * (-1) ^ (n + 1) / (↑n * Real.pi)

    Checked by Lean’s kernel

Scope (1)

An exponential. The coefficients contain eπ:

In[3]:=
#cas [fourierSin x n pi] (exp x)
Out[3]=

sine series coefficients

bn=2n(1−(−1)neπ)π(n2+1)
bₙ = 2*n*(1 - (-1)^n*exp(pi))/(pi*(n^2 + 1))
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, Real.exp x * Real.sin (↑n * x) =
      2 * ↑n * (1 - (-1) ^ n * Real.exp Real.pi) / (Real.pi * (↑n ^ 2 + 1))
The certificate: 1 checked step
  1. The sine coefficients on [0, L]

    ∀ (n : ℕ),
      0 < n →
        2 / Real.pi * ∫ (x : ℝ) in 0..Real.pi, Real.exp x * Real.sin (↑n * x) =
          2 * ↑n * (1 - (-1) ^ n * Real.exp Real.pi) / (Real.pi * (↑n ^ 2 + 1))

    Checked by Lean’s kernel

Applications (1)

The integral behind b1=8/π of x(π−x), in a proof. cas proves it, and only the three standard axioms are used:

In[4]:=
theorem fourierSin_b_one : ∫ x in (0 : ℝ)..Real.pi, x * (Real.pi - x) * Real.sin x = 4 := by
  cas

#print axioms fourierSin_b_one
Out[4]=

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

Properties and Relations (2)

The sine series on [0,π] is the Fourier series on [−π,π] of the odd extension of f. For the odd function x, the sine series has the coefficients bn that fourier gives, π times those on [0,1] above:

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

Fourier coefficients

a0=0,an=0,bn=2(−1)n+1n
a₀ = 0, aₙ = 0, bₙ = 2*(-1)^(n + 1)/n
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 = 0 ∧
  (∀ (n : ℕ), 0 < n → 1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x * Real.cos (↑n * x) = 0) ∧
    ∀ (n : ℕ),
      0 < n → 1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x * Real.sin (↑n * x) = 2 * (-1) ^ (n + 1) / ↑n
The certificate: 1 checked step
  1. The Fourier coefficients on [-π, π], by integration by parts

    1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x = 0 ∧
      (∀ (n : ℕ), 0 < n → 1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x * Real.cos (↑n * x) = 0) ∧
        ∀ (n : ℕ),
          0 < n → 1 / Real.pi * ∫ (x : ℝ) in -Real.pi..Real.pi, x * Real.sin (↑n * x) = 2 * (-1) ^ (n + 1) / ↑n

    Checked by Lean’s kernel


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

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

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

Possible Issues (3)

The length must be positive:

In[7]:=
#cas [fourierSin x n 0] (x)
Out[7]=

Error

fourierSin: L must be positive

The length is a positive rational number or a positive rational multiple of π, such as 2 * pi / 3:

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

Error

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

Other functions are refused on [0,L], here ex2. fourier takes sines and cosines with integer frequencies on [−π,π]:

In[9]:=
#cas [fourierSin x n pi] (exp (x ^ 2))
Out[9]=

Error

fourierSin: on [0, L] the function must be a sum of terms c x ^ j e ^ (a x)

See Also

fourierCos · fourier · fourierTransform · integrate