banner
IWSR

IWSR

我永远喜欢志喜屋梦子!

From Fourier Series to Fourier Transform

Lecture 6 of Games101 covers content related to Fourier transforms. After class, I spent some time understanding this topic (although I studied it in college, I had mostly forgotten it), so I wrote this article to record my learning insights.

I strongly recommend the series "Purely Practical Mathematical Derivations" by Teacher DR_CAN in the reference materials! Most of this article consists of notes from his course.

This article will derive from the following aspects in order:

  • Orthogonality of trigonometric functions
  • Fourier series expansion for functions with a period of 2 π\pi
  • Fourier series expansion for functions with a period of T
  • Complex form of Fourier series
  • Fourier series expansion for non-periodic functions

It should be noted that due to my limited knowledge, I cannot provide a proof for the Fourier series expansion formula, just like I cannot prove why G=mg. For truths, it may be simpler to use them directly. However, for readers who feel uncomfortable not understanding it, I recommend the article written by Teacher Wang Jiliang, which provides a detailed introduction to how Fourier derived the Fourier series from the heat conduction equation.

Fourier series expansion: f(x)=a02+Σn=1+(ancosnx+bnsinnx)f(x) = \frac{a_0}{2} + \varSigma_{n=1}^{+\infty}(a_{n}\cos nx + b_{n}\sin nx)

Orthogonality of Trigonometric Functions#

If there exist functions f(x) and g(x) such that abf(x)g(x)dx=0\int_{a}^{b} f(x)g(x) dx = 0, then we say that the functions f(x) and g(x) are orthogonal on the interval [a, b].

For the trigonometric functions 0(sin0),1(cos0),sinx,cosx,sin2x,cos2x.....sinnx,cosnx0(\sin 0), 1(\cos 0), \sin x, \cos x, \sin 2x, \cos 2x..... \sin nx, \cos nx, they are orthogonal on the interval [- π\pi, π\pi].

{ππcos(nx)sin(mx)dx=0,ππcos(nx)cos(mx)dx=0,nmππsin(nx)sin(mx)dx=0nm\begin{cases} \int_{-\pi}^{\pi} \cos (nx) \sin (mx) dx = 0, \\ \int_{-\pi}^{\pi} \cos (nx) \cos (mx) dx = 0, & n \neq m \\ \int_{-\pi}^{\pi} \sin (nx) \sin (mx) dx = 0 & n \neq m \end{cases}

The above integrals can be proven using the product-to-sum identities of trigonometric functions. Here, only one calculation process is provided for reference.

ππcos(nx)sin(mx)dx=12ππsin(n+m)xdx12ππsin(nm)xdx=12[1n+mcos(n+m)xππ+1nmcos(nm)xππ]=0\int_{-\pi}^{\pi} \cos (nx) \sin (mx) dx = \frac{1}{2} \int_{-\pi}^{\pi} \sin(n+m)x dx - \frac{1}{2} \int_{-\pi}^{\pi} \sin(n-m)x dx \\ = \frac{1}{2} [-\frac{1}{n+m} \cos (n+m)x |_{-\pi}^{\pi} + \frac{1}{n-m} \cos (n-m)x |_{-\pi}^{\pi}] \\ = 0

So what happens if n = m? For combinations like sin and cos, it doesn't matter, but for cos and cos or sin and sin, it is equivalent to integrating the product of two identical trigonometric functions. Below is the solution for the combination of cosmx\cos mx and cosmx\cos mx.

ππcos(mx)cos(mx)dx=ππ1+cos(2m)x2dx=12(x+12msin2mx)ππ=π\int_{-\pi}^{\pi} \cos (mx) \cos (mx) dx = \int_{-\pi}^{\pi} \frac{1 + \cos (2m)x}{2} dx \\ = \frac{1}{2} (x + \frac{1}{2m} \sin{2mx})|_{-\pi}^{\pi} = \pi

Remember the results derived here, as they will be used in the next section.

Fourier Series Expansion for Functions with a Period of 2 π\pi#

At the beginning, the relevant formulas for Fourier series were directly given. Next, I will introduce how to combine the orthogonality of trigonometric functions to find the coefficients in the formula.

Finding a0a_{0}#

Integrate both sides of the Fourier series expansion formula from π-\pi to π\pi.

ππf(x)dx=ππ(a02+Σn=1+(ancosnx+bnsinnx))dx=ππa02dx+anππΣn=1+1cosnxdx+bnππΣn=1+1sinnxdx\int_{-\pi}^{\pi} f(x) dx \\ = \int_{-\pi}^{\pi} (\frac{a_0}{2} + \varSigma_{n=1}^{+\infty}(a_{n}\cos nx + b_{n}\sin nx)) dx \\ = \int_{-\pi}^{\pi} \frac{a_0}{2} dx + a_{n} \int_{-\pi}^{\pi} \varSigma_{n=1}^{+\infty} 1 \cos nx dx + b_{n} \int_{-\pi}^{\pi} \varSigma_{n=1}^{+\infty} 1 \sin nx dx

After integrating both sides, it is evident that the combinations of 1, cosnx\cos nx and 1, sinnx\sin nx will yield results of 0 based on the orthogonality of trigonometric functions. Thus, we can directly eliminate them to obtain the following equality:

ππf(x)dx=ππa02dx=a02ππ1dx=a02xππ=a0π\int_{-\pi}^{\pi} f(x) dx = \int_{-\pi}^{\pi} \frac{a_0}{2} dx \\ = \frac{a_0}{2} \int_{-\pi}^{\pi} 1 dx \\ = \frac{a_0}{2} x|_{-\pi}^{\pi} \\ = a_{0} \pi

Thus, we have a0a_{0} as:

a0=12ππf(x)dxa_{0} = \frac{1}{2}\int_{-\pi}^{\pi} f(x) dx

Finding ana_{n}#

Multiply both sides of the Fourier series expansion by cosmx\cos mx and integrate.

ππf(x)cosmxdx=ππ(a02cosmx+Σn=1+(ancosnxcosmx+bnsinnxcosmx))dx=a02ππ1cosmxdx+anππΣn=1+cosnxcosmxdx+bnππΣn=1+sinnxcosmxdx\int_{-\pi}^{\pi} f(x) \cos mx dx \\ = \int_{-\pi}^{\pi} (\frac{a_0}{2} \cos mx + \varSigma_{n=1}^{+\infty}(a_{n}\cos nx \cos mx + b_{n}\sin nx \cos mx)) dx \\ = \frac{a_0}{2} \int_{-\pi}^{\pi} 1 \cos mx dx + a_{n} \int_{-\pi}^{\pi} \varSigma_{n=1}^{+\infty} \cos nx \cos mx dx + b_{n} \int_{-\pi}^{\pi} \varSigma_{n=1}^{+\infty} \sin nx \cos mx dx

At this point, we can directly eliminate a02ππ1cosmxdx\frac{a_0}{2} \int_{-\pi}^{\pi} 1 \cos mx dx and bnππΣn=1+sinnxcosmxdxb_{n} \int_{-\pi}^{\pi} \varSigma_{n=1}^{+\infty} \sin nx \cos mx dx based on the orthogonality of trigonometric functions, as they will both yield 0. However, we cannot eliminate the middle term anππΣn=1+cosnxcosmxdxa_{n} \int_{-\pi}^{\pi} \varSigma_{n=1}^{+\infty} \cos nx \cos mx dx entirely, because when m=nm = n, its integral result is π\pi.

Thus, we obtain:

ππf(x)cosmxdx=anπ\int_{-\pi}^{\pi} f(x) \cos mx dx = a_{n} \pi

Rearranging gives:

an=1πππf(x)cosmxdxa_{n} = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos mx dx

Finding bnb_{n}#

Multiply both sides of the Fourier series expansion by sinmx\sin mx and integrate.

ππf(x)sinmxdx=ππ(a02sinmx+Σn=1+(ancosnxsinmx+bnsinnxsinmx))dx\int_{-\pi}^{\pi} f(x) \sin mx dx = \int_{-\pi}^{\pi} (\frac{a_0}{2} \sin mx + \varSigma_{n=1}^{+\infty}(a_{n}\cos nx \sin mx + b_{n}\sin nx \sin mx)) dx

The proof process is omitted here, as it follows the same reasoning as above, yielding:

bn=1πππf(x)sinmxdxb_{n} = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \sin mx dx

Fourier Series Expansion for Functions with a Period of T#

The method for expanding functions with a period of T is somewhat clever. In general, it involves transforming parameters to force the expression into the form of π\pi.

Let T = 2L, then we have f(t) = f(t + 2L).

Let x = πL\frac{\pi}{L} t, then t = Lxπ\frac{Lx}{\pi}, thus f(t) = f( Lxπ\frac{Lx}{\pi}).

tx
00
2L2 π\pi
4L4 π\pi

If we consider g(x) as f( Lπ\frac{L}{\pi} (x)), from the correspondence in the above table, the graph of g(x) can correspond to f(t). For example, f(2L) = g(2 π\pi). The period of g(x) is 2 π\pi, but we have already obtained the coefficients for the Fourier expansion of functions with a period of 2 π\pi in the previous section.

{a0=12ππg(x)dxan=1πππg(x)cosnxdxbn=1πππg(x)sinnxdx\begin{cases} a_{0} = \frac{1}{2}\int_{-\pi}^{\pi} g(x) dx \\ a_{n} = \frac{1}{\pi} \int_{-\pi}^{\pi} g(x) \cos nx dx \\ b_{n} = \frac{1}{\pi} \int_{-\pi}^{\pi} g(x) \sin nx dx \end{cases}

Next, we just need to substitute x = πL\frac{\pi}{L} t into the equations:

{cosnx=cosnπLtsinnx=sinnπLtππ1dx=LL1dπtLg(x)=f(t)\begin{cases} \cos nx = \cos \frac{n \pi}{L}t \\ \sin nx = \sin \frac{n \pi}{L}t \\ \int_{-\pi}^{\pi} 1 dx = \int_{-L}^{L} 1 d\frac{\pi t}{L} \\ g(x) = f(t) \end{cases}

Thus, we obtain the Fourier series expansion for functions with a period of T:

f(t)=a02+Σn=1+(ancosnπLt+bnsinnπLt)f(t) = \frac{a_0}{2} + \varSigma_{n=1}^{+\infty}(a_{n}\cos \frac{n \pi}{L}t + b_{n}\sin \frac{n \pi}{L}t)

Where (omitting the calculation process, the method is consistent with the previous section):

{a0=1LLLf(t)dtan=1LLLf(t)cosnπLtdtbn=1LLLf(t)sinnπLtdt\begin{cases} a_{0} = \frac{1}{L}\int_{-L}^{L} f(t) dt \\ a_{n} = \frac{1}{L} \int_{-L}^{L} f(t) \cos \frac{n \pi}{L} t dt \\ b_{n} = \frac{1}{L} \int_{-L}^{L} f(t) \sin \frac{n \pi}{L} t dt \end{cases}

If we replace L with T, it will become:

f(t)=a02+Σn=1+(ancos2nπTt+bnsin2nπTt)f(t) = \frac{a_0}{2} + \varSigma_{n=1}^{+\infty}(a_{n}\cos \frac{2n \pi}{T}t + b_{n}\sin \frac{2n \pi}{T}t)
{a0=2T0Tf(t)dtan=2T0Tf(t)cos2nπTtdtbn=2T0Tf(t)sin2nπTtdt\begin{cases} a_{0} = \frac{2}{T}\int_{0}^{T} f(t) dt \\ a_{n} = \frac{2}{T} \int_{0}^{T} f(t) \cos \frac{2 n \pi}{T} t dt \\ b_{n} = \frac{2}{T} \int_{0}^{T} f(t) \sin \frac{2 n \pi}{T} t dt \end{cases}

Complex Form of Fourier Series#

This section will use Euler's formula. I will write another article later to prove Euler's formula (the proof requires Taylor expansion, although Euler himself did not use this method to derive it).

eiθ=cosθ+isinθe^{i\theta} = \cos \theta + i \sin \theta
{eiθ=cosθ+isinθeiθ=cosθ+isinθ=cosθisinθ\begin{cases} e^{i\theta} = \cos \theta + i \sin \theta \\ e^{i-\theta} = \cos -\theta + i \sin -\theta = \cos \theta - i \sin \theta \end{cases}

From the above, we can derive:

{sinθ=eiθeiθ2i=ieiθeiθ2cosθ=eiθ+eiθ2\begin{cases} \sin \theta = \frac{e^{i \theta} - e^{-i \theta}}{2i} = -i \frac{e^{i \theta} - e^{-i \theta}}{2} \\ \cos \theta = \frac{e^{i \theta} + e^{- i \theta}}{2} \end{cases}

Let x=2πtTx = \frac{2 \pi t}{T} and substitute this into the Fourier series to obtain:

f(x)=a02+Σn=1+(aneinx+einx2ibneinxeinx2)=a02+Σn=1+anibn2einx+Σn=1+an+ibn2einxf(x) = \frac{a_0}{2} + \varSigma_{n=1}^{+\infty}(a_{n} \frac{e^{i nx} + e^{- i nx}}{2} -i b_{n} \frac{e^{i nx} - e^{-i nx}}{2}) \\ = \frac{a_0}{2} + \varSigma_{n=1}^{+\infty} \frac{a_{n} - i b_{n}}{2} e^{i nx} + \varSigma_{n=1}^{+\infty} \frac{a_{n}+i b_{n}}{2} e^{-i nx}

The subsequent transformations may be a bit confusing, but once understood, it will seem quite straightforward.

Treating a02\frac{a_{0}}{2} as Σn=00a02einx\varSigma_{n=0}^{0} \frac{a_{0}}{2} e^{i nx} makes sense, as when n = 0, einxe^{i nx} also equals 1, thus it holds.

The transformation of Σn=1+einx\varSigma_{n=1}^{+\infty} e^{-i nx} is also interesting; treating n as -1 to - \infty, the expression becomes Σn=1einx\varSigma_{n=-1}^{-\infty} e^{i nx}.

Thus, we obtain:

f(x)=Σn=+Cneinxf(x) = \varSigma_{n = -\infty}^{+\infty} C_{n} e^{i nx}

Replacing x gives:

f(t)=Σn=+Cnei2nπTtf(t) = \varSigma_{n = -\infty}^{+\infty} C_{n} e^{i \frac{2 n \pi}{T} t}

Where:

Cn={a02,n=0anibn2n=1,2,3...an+ibn2n=1,2,3...Cn = \begin{cases} \frac{a_{0}}{2}, & n = 0 \\ \frac{a_{n} - i b_{n}}{2} & n = 1,2,3... \\ \frac{a_{-n}+i b_{-n}}{2} & n = -1, -2, -3... \end{cases}

Since we have already derived the Fourier series expansion for functions with a period of T in the previous section:

{a0=2T0Tf(t)dtan=2T0Tf(t)cos2nπTtdtbn=2T0Tf(t)sin2nπTtdt\begin{cases} a_{0} = \frac{2}{T}\int_{0}^{T} f(t) dt \\ a_{n} = \frac{2}{T} \int_{0}^{T} f(t) \cos \frac{2 n \pi}{T} t dt \\ b_{n} = \frac{2}{T} \int_{0}^{T} f(t) \sin \frac{2 n \pi}{T} t dt \end{cases}

Substituting gives:

Cn={1T0Tf(t)dt,n=01T0Tf(t)(cos2nπTtisin2nπTt)dtn>01T0Tf(t)(cos2nπTtisin2nπTt)dtn<0Cn = \begin{cases} \frac{1}{T}\int_{0}^{T} f(t) dt, & n = 0 \\ \frac{1}{T} \int_{0}^{T} f(t) (\cos \frac{2n\pi}{T} t - i \sin \frac{2n\pi}{T} t) dt & n > 0 \\ \frac{1}{T} \int_{0}^{T} f(t) (\cos \frac{2n\pi}{T} t - i \sin \frac{2n\pi}{T} t) dt & n < 0 \end{cases}

However, the expression is somewhat unwieldy, so we simplify using Euler's formula:

cos2nπTisin2nπT=cos2nπT+isin2nπT=ei2nπT\cos \frac{2n\pi}{T} - i \sin \frac{2n\pi}{T} = \cos -\frac{2n\pi}{T} + i \sin -\frac{2n\pi}{T} = e^{-i \frac{2n\pi}{T}}
Cn={1T0Tf(t)dt,n=01T0Tf(t)ei2nπTtdtn>01T0Tf(t)ei2nπTtdtn<0Cn = \begin{cases} \frac{1}{T}\int_{0}^{T} f(t) dt, & n = 0 \\ \frac{1}{T} \int_{0}^{T} f(t) e^{-i \frac{2n\pi}{T} t} dt & n > 0 \\ \frac{1}{T} \int_{0}^{T} f(t) e^{-i \frac{2n\pi}{T} t} dt & n < 0 \end{cases}

Notice that the results for n > 0 and n < 0 are the same. Also, for n = 0, we can see that its expression is also the same as for n > 0 and n < 0 (substituting n=0 gives ei2nπTe^{-i \frac{ 2n \pi }{T}} resulting in 1).

Thus, the expression for CnC_{n} can be unified as:

Cn=1T0Tf(t)ei2nπTtdtC_{n} = \frac{1}{T} \int_{0}^{T} f(t) e^{-i \frac{ 2n \pi }{T} t} dt

At this point, we define ω0\omega_{0} as 2πT\frac{ 2 \pi }{T} (the angular frequency in engineering), yielding:

Cn=1T0Tf(t)einω0tdtC_{n} = \frac{1}{T} \int_{0}^{T} f(t) e^{-i n \omega_{0} t} dt

Thus, we have obtained the complex form of the Fourier series:

{f(t)=Σn=+Cneinω0tCn=1T0Tf(t)einω0tdt\begin{cases} f(t) = \varSigma_{n = -\infty}^{+\infty} C_{n} e^{i n \omega_{0} t} \\ C_{n} = \frac{1}{T} \int_{0}^{T} f(t) e^{-i n \omega_{0} t} dt \end{cases}

Next, let's make a small transformation.

Replace the limits of integration with [-T/2, T/2], then substituting into the original expression gives (the definite integral of periodic functions only needs the difference to be one period for the results to be the same):

{f(t)=Σn=+Cneinω0tCn=1TT2T2f(t)einω0tdt\begin{cases} f(t) = \varSigma_{n = -\infty}^{+\infty} C_{n} e^{i n \omega_{0} t} \\ C_{n} = \frac{1}{T} \int_{-\frac{T}{2}}^{\frac{T}{2}} f(t) e^{-i n \omega_{0} t} dt \end{cases}

Fourier Series Expansion for Non-Periodic Functions#

The treatment of Fourier series expansion for non-periodic functions is also quite clever. The general idea is to treat the non-periodic function as a periodic function with infinite period, and then use the expansion formula for periodic functions to transform it.

Let 1T\frac{1}{T} be ff, and since T = \infty, ff approaches zero, thus we obtain:

f(t)=Σn=+(f(t)einω0tdt)einω0tff(t) = \varSigma_{n = -\infty}^{+\infty} (\int_{-\infty}^{\infty} f(t) e^{-i n \omega_{0} t} dt) e^{i n \omega_{0} t} f

Looks familiar, doesn't it (the definition of definite integrals)? Since ff approaches 0 infinitely, and ω0=2πT=2πf\omega_{0} = \frac{ 2 \pi }{T} = 2 \pi f, we can obtain it through summing to integration.

f(t)=(f(t)ei2πftdt)ei2πftdff(t) = \int_{-\infty}^{\infty} (\int_{-\infty}^{\infty} f(t) e^{-i 2 \pi f t} dt) e^{i 2 \pi f t} df

However, I think everyone is probably more familiar with the following form:

f(t)=12π(f(t)eiωtdt)eiωtdωf(t) = \frac{1}{ 2 \pi } \int_{-\infty}^{\infty} (\int_{-\infty}^{\infty} f(t) e^{-i \omega t} dt) e^{i \omega t} d \omega

Both expressions are essentially the same, one from frequency and the other from angular frequency.

Where:

F(ω)=f(t)eiωtdtF(\omega) = \int_{-\infty}^{\infty} f(t) e^{-i \omega t} dt

is the Fourier transform.

And:

f(t)=12πF(ω)eiωtdωf(t) = \frac{1}{ 2 \pi } \int_{-\infty}^{\infty} F(\omega) e^{i \omega t} d \omega

is the inverse Fourier transform.

Reference Materials#

Purely Practical Mathematical Derivations - Fourier Series and Fourier Transform - Part 5: Deriving Fourier Transform from Fourier Series

Frontier Practices in IoT - Fourier Series

First Release on Bilibili! A Explanation of "Fourier Transform" That Even Paramecia Can Understand, Tsinghua University Teacher Li Yongle Teaches You How to Understand Fourier Transform and Distinguish Beauty and Voice Change Principles...

Visual Representation of Fourier Transform

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.