I am working on this problem:
Let $f$ be a periodic function of period $12$ defined by
$$f(x)=$$\begin{cases} 1 & \text{ if }-6<x\leq0\\ x & \text{ if }0<x\leq 6 \end{cases}
Then the Fourier series of $f$ is
$a_0+\sum_{n=1}^{\infty}a_n\cos\frac{n\pi x}{6}+b_n\sin\frac{n\pi x}{6}$
find $a_0 , a_n , b_n$
I've solved for $a_0$ and $a_n$ already, but I'm having trouble getting a good answer for my $b_n$
I'm taking the integrals $$\int_{-6}^{0} {\sin(\frac{n\pi x}{6})} dx + \int_{0}^{6} {x\sin(\frac{n \pi x}{6})}dx $$
For the first integral, I'm getting $$(\frac{-1}{n\pi} - (-1)^n)$$ with $(-1)^n$ being an alternative form of $\cos(n\pi)$
And for the second integral, I'm getting $$\frac{-36}{n\pi} (-1)^n$$
which put together, my final answer should be: $$\frac{-1}{n\pi} - (-1)^n + \frac{-36}{n\pi} (-1)^n$$
But that's incorrect. Any idea where I'm going wrong? Thank you in advance
It appears you have lost a few factors of $\frac{1}{6}$ and a term in your $b_n$. Since I don't know what you obtained for $a_n$, here is a worked derivation.
The Fourier series is given by $$f(x) = \frac{a_0}{2} + \sum_{n=1}^\infty a_n\cos(n\pi x/6) + b_n\sin(n\pi x/6)$$ where $$a_0 = \frac{1}{6}\int_{-6}^0dx + \frac{1}{6}\int_{0}^6 xdx = 1 + \frac{1}{6} \times \frac{1}{2} \times 6^2 = 4$$ and for $n > 0$ \begin{align*} a_n &= \frac{1}{6}\int_{-6}^0 \cos(n\pi x/6)dx + \frac{1}{6}\int_0^6 x\cos(n\pi x/6)dx \\ &= \frac{1}{n\pi}\left[\sin(n\pi x/6)\right]_{-6}^0 + \frac{1}{n\pi}\left[x\sin(n\pi x/6)\right]_0^6 - \frac{1}{n\pi}\int_0^6 \sin(n\pi x/6)dx \\ &= -\frac{1}{n^2\pi^2}[-\cos(n\pi x/6)]_0^6 \\ &= \frac{6}{n^2\pi^2}((-1)^n-1) \end{align*}
\begin{align*} b_n &= \frac{1}{6}\int_{-6}^0 \sin(n\pi x/6)dx + \frac{1}{6}\int_0^6 x\sin(n\pi x/6)dx \\ &= \frac{1}{n\pi}\left[-\cos(n\pi x/6)\right]_{-6}^0 + \frac{1}{n\pi}\left[-x\cos(n\pi x/6)\right]_0^6 + \frac{1}{n\pi}\int_0^6 \cos(n\pi x/6)dx \\ &= -\frac{1}{n\pi}(-1-(-1)^n) -\frac{1}{n\pi}(6(-1)^n-1) \\ &= \frac{1}{n\pi}(-5(-1)^n) \end{align*}
Hence the Fourier series for $f(x)$ is
$$f(x) = 2 + \sum_{n=1}^\infty\left[ \frac{6((-1)^n-1)}{n^2\pi^2}\cos(n\pi x/6) -\frac{5(-1)^n}{n\pi}\sin(n\pi x/6)\right]$$