# Conceptual/Graphical understanding of the Fourier Series.

I've been reading about how the Fourier Series works, so like how the orthogonality cancels out all but the one that we're looking for. I've read derivations of the Fourier Series. What I would like is, a more pictorial/conceptual understanding of what is physically going on in my head so that this all seems more logical to me. $$a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cdot \cos(nx)\,\mathrm{d}x\ \forall\ n\ge 0$$

I would like to pictorially understand this equation. I can see that the equation is basically saying that the average value of multiplying a function, $f(x)$, by $\cos(nx)$ will give the amplitude of $\cos(nx)$. Now here's my specific question: why is this so? Why does finding that average value give the amplitude that the cosine should have? (In a geometric/pictorial/graphical sense.)

I hope what I'm saying makes sense.

Thanks for you time.

-
Do you have any intuition why Fourier transform of some signal (like audio wave) gives the histogram of used frequencies? –  dtldarek Mar 17 '12 at 11:10
I think so. If you multiply two cos waves together that have different frequencies, you'll get an envelope/AM type signal, and the integral of that over a period will always be zero; however, of the cos waves are these, the cos wave squares and you don't get zero. –  user968243 Mar 17 '12 at 12:43
Then this is very similar. Think of $f$ as the sum of many cosine waves (just like audio) with different frequencies. The $n$ inside the cosine denotes the appropriate frequency, and as in the Fourier transform, this particular formula will "resonate" (i.e. will not cancel to zero) with amplitude proportional to the strength of $\cos(nx)$ in $f(x)$. Hope that helps ;-) –  dtldarek Mar 17 '12 at 15:53

I answered a related question on dsp.SE in which I pointed out that the Fourier coefficient $a_n$ is the number that minimizes the squared error $$\int_{-\pi}^{\pi} (f(x) - a_n\cos (nx))^2 \ \mathrm dx$$ between the function $f(x)$ and its approximation in terms of a multiple of $\cos (nx)$. The notation is slightly different and more engineering-oriented, though.

-
I like your interpretation, perhaps because I'm studying Electrical Engineering and it makes more sense. Though I don't understand why nobody else neither here, nor in any other online explanation I've read uses the idea of the $\it{least\,squared\, error}$. Most other responses revolve around vectors; I'm yet to see a graph of the actual vectors being multiplied be cosine and canceling. –  user968243 Mar 18 '12 at 8:21

I think the most naturally visual interpretation of Fourier series is in a complex setting. The most basic example would be the vanishing of the integral of integer-scaled complex exponentials:

$$\int_{-\pi}^\pi e^{inx}dx=\oint_{\gamma}zdz=\delta_n.$$

The reason this is zero is simple: it traces out the unit circle in the complex plane ($n$ times), having symmetry in both reflection and rotation and thus must evaluate to the origin, geometrically speaking. When we create a linear combination of these functions, we can pinpoint the coefficient of $e^{inx}$ by multipling by its complex conjugate and then integrating (and normalizing): if we regard the function as a system of "clockwork," this process is calibrated to merely "delay" all the "pieces" of the system by the equivalent of what the $e^{inx}$ "gear" contributes to the clock; all of the other pieces will still be turning around and thus will evaluate to zero by the exact same considerations of symmetry, while the actual $e^{inx}$ gear will come to a standstill and thus we measure its coefficient.

This works because the "clockwork system" is a formal linear combination of "gears," and the act of integration is also linear and thus can distinguish between "running" versus "stopped" gears.

To bring this understanding down to the real setting, we project down by intermittently making the coefficients of the $e^{inx}$ gear and its conjugate $e^{-inx}$ the same. Conjugation reverses the direction of rotation, and when we add the effect of two gears rotating in opposite directions, their imaginary parts cancel out and we are left with a "real" gear: one that is a sinusoidal wave on $[-1,1]$ (after we average, anyway). This type of gear always decomposes into complex gears that are mirror images of each other, so there is the same visual picture at work as before, but it has "collapsed" down, like a fold-up tent into existing purely on the real line.

That works for $\cos (nx)$, but $\sin(nx)$ is created a little differently: one complex exponential minus another. Negation has the effect of reflection on a gear, so geometrically $e^{inx}-e^{-inx}$ will be a gear plus its "mirror image" again, but this time the "mirror" is the imaginary axis instead of the real axis. When we divide out by $2i$ we turn it onto the real line. Going from a complex Fourier series to a trig one is effectively decomposing its gears into real and imaginary sinusoids, then situating these sinusoids onto the same subspace of $\mathbb{C}$ by rotating the imaginary one onto it (and compensating by rotating the coefficients of these waves in the opposite direction, so that we represent the same function throughout). Going from the cosine-sine expansion to the complex one is therefore the exact reverse of this process: sieving out waves and putting up their corresponding tents.

Finally, how is it that we glean the coefficients of the sinusoids the same way we do it with complex exponentials? The explanation is simple: linearity. Obtaining the coefficients of the sinusoids is equivalent to obtaining the coefficients of the mirrored complex exponentials they decompose into and then putting them together. When we write the latter, we can put the two integrals together and get a single trigonometric one, i.e. the former.

Note that this graphical perspective interprets $x$ as "time." I'm also uncertain of how to "see" that complex exponentials or sinusoidal waves form a complete basis for $L^2\big([-\pi,\pi]\big)$...

-

Let's try a (possibly) original approach and show that Fourier series are not so much about regularities than about discontinuities of different orders. With this method the $a_n$ coefficients will be obtained without integration at all (at least for most common functions) !

The discontinuity of first order or jump discontinuity of the function $f$ at point $x$ is given, when the limit exists and is not zero, by : $\ \displaystyle \delta f(x)=\lim_{h\to 0}\ f\left(x+\frac h2\right)-f\left(x-\frac h2\right)$.

More generally the discontinuity of order $m$ (with $m>0$) will be given by : $$\delta f^{(m-1)}(x)=\lim_{h\to 0}\ f^{(m-1)}\left(x+\frac h2\right)-f^{(m-1)}\left(x-\frac h2\right)$$

Let's consider a function $f$ of period $2\pi$. To simplify we'll suppose that $f$ is of class $C^\infty$ in $(-\pi,\pi]$ except at a finite number of points $x_1,x_2,\dotsc,x_l$ with discontinuities of orders $m_1,m_2,\dotsc,m_l$.

Then the Fourier series is obtained directly as a sum of contributions : one for each discontinuity of order $m_k$ at $x_k$ plus a constant term $C$ : $$f(x)=C+ \frac 1{\pi}\sum_{n=1}^{\infty} \sum_{k=1}^l \delta f^{(m_k-1)}(x_k)\times \Bigl\{\text{}m_k\text{-th integral}\int \cos(n(x-x_k)) dx\Bigr\}$$

( this result is a direct application of the formal 'Dirac comb' formula : $$\sum_{n=-\infty}^\infty \delta(x-x_k-2\pi n)=\frac 1{2\pi}+\frac 1{\pi}\sum_{n=1}^\infty \cos\left(n(x-x_k)\right)$$ with $\delta$ the Dirac delta distribution because the integral of $\delta(x)$ is $\operatorname{H}(x)$ the Heaviside step function, which integral is the ramp function and so on... )

Let's rewrite $f(x)$ as : $$f(x)=C+ \frac 1{\pi} \sum_{k=1}^l \delta f^{(m_k-1)}(x_k)\times\sum_{n=1}^{\infty} \frac{\cos\left(n(x-x_k)-m_k \frac{\pi}2\right)}{n^{m_k}}$$

To get the $a_n$ and $b_n$ coefficients for $\cos(nx)$ and $\sin(n)$ it remains only to use $\cos(a-b)=\cos(a)\cos(b)+\sin(a)\sin(b)$.

The constant term will be the reference, the $\displaystyle \frac 1n$ terms reveal the jump discontinuities of the original function (often at the transition $\pi\to -\pi$ but not only!), the $\displaystyle \frac 1{n^2}$ terms reveal the discontinuities of the derivative of $f(x)$ and so on...

Let's see this on simple examples :

• Sawtooth wave : there is only a first order discontinuity of $f(x)=x$ in $(-\pi,\pi]$ at point $x=\pi$ with a jump of $\delta f(\pi)=-\pi-\pi=-2\pi\$ so that : $$f(x)=C+ \frac {-2\pi}{\pi}\sum_{n=1}^{\infty}\frac{\cos\left(n(x-\pi)-1\frac{\pi}2\right)}{n}=-2\sum_{n=1}^{\infty}\frac{\sin(n(x-\pi))}{n}$$ $$=-2\sum_{n=1}^{\infty}\frac{(-1)^n\sin(nx)}{n}$$
• parabola : $f(x)=x^2$ in $(-\pi,\pi]$ with a second-order discontinuity at $x=\pi$ : $\delta f'(x)= -2\pi-2\pi\$ giving : $$f(x)=C- 4\sum_{n=1}^{\infty} \frac{\cos\left(n(x-\pi)-2\frac{\pi}2\right)}{n^2}=C+4\sum_{n=1}^{\infty} \frac{(-1)^n\cos\left(nx\right)}{n^2}$$ (with $C=\frac{\pi^2}3$ to get $f(0)=0$)
• 'third order' : $f(x)=x^3$ in $(-\pi,\pi]$ has a first and third order discontinuity at $x=\pi$ : $\delta f(x)= -\pi^3-\pi^3$ and $\delta f''(x)= -6\pi-6\pi\$ so that : $$f(x)=C+ \frac {-2\pi^3}{\pi}\sum_{n=1}^{\infty}\frac{\cos\left(n(x-\pi)-\frac{\pi}2\right)}{n}+\frac {-12\pi}{\pi}\sum_{n=1}^{\infty}\frac{\cos\left(n(x-\pi)-3\frac{\pi}2\right)}{n^3}$$ $$=-2\pi^2\sum_{n=1}^{\infty}\frac{(-1)^n\sin(nx)}n+12\sum_{n=1}^{\infty}\frac{(-1)^n\sin(nx)}{n^3}$$
-

I never try to think what the integral form of the coefficients mean. The way I think of it is that the Fourier series is trying to make your function from sin/cos waves (possibly using infinitely many to get straight lines).

The integral used in working out the coefficients is really just a neat trick that works (using orthogonality). There probably is a nice geometrical meaning to it but I don't think it is needed to understand the theory of Fourier series.

-

(Integrable or Fourier-representable) functions form an infinite-dimensional vector space. The different frequencies are the orthonormal basis vectors. The integrals in question (the Fourier operator) are like the dot products with $e_k$, or projection onto each axis.

Also, have a look at some of the related topics to get some idea to the vast landscape of context to these concepts: Fourier Analysis, Integral Transforms, Digital Signal Processing, Harmonic Analysis, Hilber Space, Operator Theory, Functional Analysis.

-
Sounds like in order to see the following, "The integrals in question (the Fourier operator) are like the dot products with ek, or projection onto each axis" I just need to do more maths. Currently, I'm second year Electrical Engineering... It's be nice to see how "the different frequencies are the orthonormal basis vectors". I look at a function and I don't really see any vectors... Also, isn't there ever a time when the angle between the two dotted vectors is not $\frac{\pi}{2}$ or $0$? Maybe that what a non integer frequency would give... Thanks for the answer! –  user968243 Mar 18 '12 at 8:00

Computing the Fourier coefficient $$c_k\ :=\ {1\over2\pi}\int_{-\pi}^\pi f(t)\ e^{-ikt}\ dt$$ for a given frequency $k$ means taking a "probe" of the (periodic) function $f$: In a way we are measuring the "interference" between $f$ and the pure harmonic $\chi_k:\ t\mapsto e^{ikt}$. When the argument $\arg\bigl(f(t)\bigr)$ behaves more or less in step with the argument of the pure harmonic $\chi_k$ then there will be little cancellation in the above integral, and $|c_k|$ will be large. In particular, if $f(t)=a e^{ikt}$ for some $a\in{\mathbb C}$ then $c_k=a$.

If, on the other hand, $\arg\bigl(f(t)\bigr)$ is more or less randomly distributed with respect to $\arg(\chi_k)$, or $\arg(\chi_k)$ more or less randomly distributed with respect to $\arg\bigl(f(t)\bigr)$ then there is a lot of cancellation in the integral, and $|c_k|$ will be small. The latter will, e.g., be the case when $f$ is a "lethargic" function and $|k|$ is very large.

-
Thanks for the answer. I can see that in order to get the coefficient at a particular frequency, all the other harmonics must cancel. In the integral though, where do they actually cancel? Is there somewhere that shows the harmonics actually canceling when I take the integral? –  user968243 Mar 17 '12 at 13:11
@user968243: Yes, $\sin x$ and $\cos x$ cancel with $\sin (x+\pi)$ and $\cos(x+\pi)$, and elementary addition formulas show that multiplying sines and cosines produces another linear combination of sines/cosines. I submit that this becomes intuitively geometrically obvious with the "formal sums of gears tracing out circles" clockwork interpretation in my answer. –  anon Mar 17 '12 at 14:12

The average value of $\cos^2 t$ over $[0,2\pi]$ equals the average value of $x^2$ over the unit circle. But due to symmetry, that equals the average of $y^2$ over the unit circle. Since $x^2+y^2=1$ on the unit circle, their common average has to be $1/2$. More analytically, this is borne out by the formula $$\cos^2t=\frac{1+\cos 2t}{2},$$ which is clearly $1/2$ plus something which averages to zero. Replacing $t$ by $nt$ does change any of this.

-
The Fourier series expresses a $2 \pi$ periodic function as a trigonometric sum:
$$f(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty}\left[a_n \cos(n x) + b_n \sin(n x) \right]$$
$$a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cdot \cos(nx)\,\mathrm{d}x\ \forall\ n \ge 1$$
(for the sake of simplicity, let's suppose for a while that only the cosine terms $a_1,$a_2 \cdots$are nonzero). In the Fourier series context (and Fourier transform, and related transforms) the first equation of this pair is often regarded as the synthesis (the 'anti-transform') and the second one as the analysis (the 'transform'). Indeed, it's a little more easy to grasp intuitively the first: the signal is expressed (synthesised) as a sum of cosines, with appropiate weights coefficients. But, once of accept/grasp that one, the second (the analysis, which provides as those coefficients) is not far away. Because, seeing that the function is equal to a sum of cosines, you can see that$\int \cos(n x) f(x) dx $can be similarly decomposed (because of linearity of integral), and that all terms of the resultin sum are zero except that of the same cosine (because of the orthonormality of$cos(n x)$family), and so we are left with the coefficient$a_n\$