Fourier series: Why is there a separate formula to determine $a_0$?

116 Views Asked by At

$$a_n = \frac 1 \pi \int_{-\pi}^{\pi} f(x) cos(nx) dx \quad\quad n\ge1 $$

Now I am wondering why there is a separate formula for $a_0$:

$$a_0 = \frac 1 \pi \int_{-\pi}^{\pi} f(x) dx$$

It looks equivalent to the formula for $a_n$, just with $n=0$:

$$\frac 1 \pi \int_{-\pi}^{\pi} f(x) cos(0\cdot x) dx = \frac 1 \pi \int_{-\pi}^{\pi} f(x) \cdot 1 dx = \frac 1 \pi \int_{-\pi}^{\pi} f(x) dx$$

So for a recent exercise I wanted to be clever and skipped the separate integral for $a_0$ and just calculated $a_n$, and then substituted $n=0$ to get the value for $a_0$.

But it turned out to give the wrong answer. Why is that?

P.S. the exercise was ("falls" = "if/when"):

Edit: I calculated $a_0$ like this:

$$a_0 = \frac 1 \pi \int_{-\pi}^{\pi} f(x) \, dx = \frac 1 \pi \int_{-\pi}^0 0 \, dx + \frac 1 \pi \int_0^\pi (e^x-1) \, dx = \frac 1 \pi [e^x - x]_0^\pi = \frac 1 \pi [e^\pi - \pi - 1] $$

For $a_n$ I just used Wolfram Alpha:

I evaluated the above result with $n=0$, multiplied by $\frac 1 \pi$ and got:

$$ \frac 1 \pi [e^\pi - 1] $$

Edit 2: Looks like I should have treated that last Wolfram Alpha term as a limit, to get that missing $-\pi$:

$$ \lim_{n \to 0} \left[-\frac{sin(\pi n)}{n}\right] = \lim_{n \to 0} \left[-\frac{\pi cos(\pi n)}{1}\right] = - \frac{\pi}{1} = - \pi $$

2

There are 2 best solutions below

1
On BEST ANSWER

Your observation is more or less correct ("it looks the same just with $n=0$"). The (nonconstant) trigonometric functions form an orthonormal system in a suitably chosen Hilbert space which becomes complete if you add the constant function $1$, which in fact is just a degree $0$ trigonometric polynomial. If you ended up with an error then you probably miscalculated the general case (some manipulation may be invalid if $n=0$?). For the $f$ in question the $\cos$ terms will probably not suffice, you need the $\sin$ terms, too, since this $f$ is not symmetric. Maybe that was the source of the wrong result?

Edit: depending on how you write the Fourier series, there may also be a missing factor $2$ in your definition of $a_0$. Some authors add that, while other write the Fourier series as $$\frac{a_0}{2} + \sum a_k \cos(kx) + b_k \sin(kx) $$

2
On

What is the orthonormal basis? Compute the norms: $$ \|1\|_2^2 = \int_{-\pi}^\pi 1^2\,dx = 2\pi $$ and for $n \ge 1$, $$ \|\cos nx\|_2^2 = \int_{-\pi}^\pi \cos^2 n\pi\,dx = \pi $$ So of course we need a factor $2$ for the $n=0$ term.