1

$$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 $$

  • 1
    You need to be careful with $n=0$ in the last term. – Thomas Jun 14 '15 at 15:23
  • 1
    To give you one more hint: note that $\lim_{x\rightarrow 0} \frac{\sin(x)}{x} $ exists but does not equal $0$. Your evaluation of the Wolfram Alpha Formula with $n=0$ is not correct. Btw, why did'nt you ask Wolfram Alpha about the $k=0$ case explicitly? – Thomas Jun 14 '15 at 15:41
  • Thanks, I did ask Wolfram Alpha directly, but the answer was "indeterminate" ;-). I also never thought about limits when evaluating a definite integral, I usually just "plug the limits in", so to speak. But actually that's good news then, because that means then that the general form for $a_n$ is actually also valid for $a_0$. – Reto Höhener Jun 14 '15 at 19:26

2 Answers2

2

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) $$

Thomas
  • 22,361
2

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.

GEdgar
  • 111,679
  • 1
    This depends on how you write the Fourier series, and the OP does not tell which convention he uses. Some authors prefer to have the $a_k$ all look the same, and use a factor $1/2$ for the $a_0$ term in the Fourier series. Others prefer to work with norm $1$ functions from the outset and use a $1/\sqrt(\pi)$ for $k\neq 0$ and $1/(\sqrt(2\pi))$ factor (which is a convention I also prefer). – Thomas Jun 14 '15 at 12:41
  • We learned the convention $a_0/2$ for the first term. – Reto Höhener Jun 14 '15 at 13:38