<s>[INST] Half Range Sine Series Question:
It is known that $f(x)=(x−4)^2$ for all $x\in [0,4]$.
Compute the half range sine series expansion for $f(x)$.
My answer :
Half range series: $p=8$, $l=4$, $a_0=a_n=0$.
$$b_n=\frac{2}{L}\int_{0}^{L}f(x)\sin\left(\frac{n\pi x}L\right)d(x)=\frac{2}{4}\int_{0}^{4}(x-4)^2\sin\left(\frac{n\pi x}4\right)d(x)$$
Partial Differentiation
Let $u=(x-4)^2$; $du=2(x-4)dx$;  $v=\frac{-4}{n\pi}\cos(\frac{n\pi x}4)$
\begin{align}
b_n&=\frac{1}{2}[\frac{-4}{n\pi}cos(\frac{n\pi x}4)(x-4)^2+\frac{8}{n\pi}\int(x-4)\cos(\frac{n\pi x}4)d(x)]|^4_0\\
&=\frac{1}{2}[\frac{-4}{n\pi}\cos(\frac{n\pi x}4)(x-4)^2+\frac{8}{n\pi}[\frac{4}{n\pi}\sin(\frac{n\pi x}4)(x-4)-\frac{4}{n\pi}\int\sin(\frac{n\pi x}4)d(x)]]|^4_0\\
&=\frac{1}{2}[\frac{-4}{n\pi}\cos(\frac{n\pi x}4)(x-4)^2$+$\frac{8}{n\pi}[\frac{4}{n\pi}\sin(\frac{n\pi x}4)(x-4)-\frac{4}{n\pi}(\frac{-4}{n\pi}\cos\frac{n\pi x}4)]|^4_0\\
&=\frac{1}{2}[\frac{-4}{n\pi}\cos(\frac{n\pi x}4)(x-4)^2$+$\frac{8}{n\pi}(\frac{16}{n^2\pi^2}\cos\frac{n\pi x}4)]|^4_0
\end{align}
we know $cosn\pi=(-1)^n$
$\frac{1}{2}[(0+\frac{128(-1)^n}{n^3\pi^3})-(-\frac{64}{n\pi}+\frac{128}{n^3\pi^3})$
$b_n=\frac{64(-1)^n}{n^3\pi^3}-\frac{64}{n^3\pi^3}+\frac{32}{n\pi}$
My teacher told me my $b_n$ is wrong and it seems that my working also looks like wrong. Can someone please help me to recalculate my $b_n$ please. Just help me once only guys.If I get this right I would able to get full marks.I would be very very grateful to you guys if you guys able to help me. If can suggest me any ideas or simpler way to solve it if you can.Thanks 
 [/INST] The integral defining your $b_n$ is correct, but the final answer is wrong. It differs from mine by ${64\over n\pi}$. 
Here's my work from Mathematica:

Here's graphical verification that we are indeed computing the series correctly (I took the 5th, 10th, and 50th partial sum, respectively):

</s>