[Math] solving coefficients of a fourier series

fourier series

So I am just learning intro to fourier series and have a quick question regarding computation of the coefficients. Let our function be $$ f(x) = \sin{\frac{\pi x}{L}} $$

Recall that the fourier series coefficients are as follows
$$
a_0 = \frac{1}{2L} \int_{-L}^{L} f(x) dx
$$
$$
a_n = \frac{1}{L} \int_{-L}^{L} f(x) \cos{\frac{n\pi x}{L}}dx $$

$$
b_n = \frac{1}{L} \int_{-L}^{L} f(x) \sin{\frac{n\pi x}{L}} dx $$
The solution manual says that $b_n = 1 $ for $n = 1$ and $b_n = 0$ for all other $n$ by observation. Yes I see this is the case but when I manually do the integrals it doesn't make sense.

Lets believe me when I say that I have already simplified $a_0$ and $a_n$ and they are both zero. But when I integrate $b_n$ I get the following
$$\frac{\sin{(n-1)\pi}}{\pi (n-1)} $$ which is undefined for $n = 1$. The denominator is zero. I also noticed that it is $0$ for any $n$. But isn't this a contradiction? Shouldn't I get $1$ if I plug $n=1$ in there?

Note: If I plug in $n=1$ before i evaluate the integral then I get the desired answer. Plugging in $n=1$ before evaluating gives me $1$ AND $0$ for other $n$.
Generally how are you supposed to find these coefficients? Should I plug in values for $n$ before doing the integral or after?

edit: here is the wolfram integral:

integrate (1/L)* sin(Pi*x/L)*sin(Pi*x*n/L) from -L to L

Best Answer

My guess is that you are using a trig identity to get

$\displaystyle b_n= \frac{1}{L}\int_{-L}^L \sin\left(\frac{\pi x}{L}\right)\sin\left(\frac{\pi xn}{L}\right) dx = \frac{1}{2L}\int_{-L}^L \cos\left(\frac{(n-1)\pi x}{L}\right) - \cos\left(\frac{(n+1)\pi x}{L}\right) dx$

When you integrate this, you will get a different result when $n=1$ and $n\neq 1$ because you will have to divide by $n-1$. So the formula you got is only valid when $n\neq 1$. For $n=1$, you need to plug in $n=1$ before taking the antiderivative. Hope this helps.

Related Question