Confusion regarding a definite integral in a solution While following this solution for warping functions, there is a part that I would need some clarification on. The author has stated that using orthogonality of terms in the sine series $\int_{-a}^a{\sin(k_nx)\sin(k_mx)dx}=a$ if $m=n$ then
$$
\int_{-a}^a{B_n\sin(k_nx)\sin(k_mx)dx}=\int_{-a}^a{2x\sin(k_mx)dx}
$$
is
$$
B_ma=\frac{4\sin(k_ma)}{ak_m^2}
$$
where $B_n$ is a constant and $k_n=k_m=\frac{(2n+1)\pi}{2a}$ where $m=n=0,1,2,3...$. I don't have problems with the left side of that equation, what I do have a problem with is the right side. According to Matlab,
$$
\int_{-a}^a{2x\sin(k_mx)dx}=\frac{4(\sin(ak_m) - ak_m\cos(ak_m))}{k_m^2}
$$
and I can't understand why the two answers are different, in the solution there is no $\cos$ term and there's $1/a$. I'm following the solution because I have a slightly different equation where $G$ is a constant and according to Matlab
$$
\int_{-b}^b{2y\sin(\sqrt{G}k_my)dy}=\frac{4(\sin(\sqrt{G}bk_m) - \sqrt{G}bk_m\cos(\sqrt{G}bk_m))}{Gk_m^2}
$$
I don't see how $\cos(\sqrt{G}bk_m)$ is supposed to disappear to leave only the sine term, plus there's no $1/b$.
 A: Let's calculate $$\int_{-a}^a2x\sin(x)dx$$ by hand using integration by parts. Recall that $\int fdg=fg-\int gdf$. We of course set $f=2x$.
$$\int_{-a}^a2x\sin(x)dx=\left[\frac{-2x\cos(k_mx)}{k_m}\right]_{x=-a}^a+\frac{2}{k_m}\int_{-a}^a \cos(k_mx)dx\\ =\frac{-2a\cos(k_ma)-2a\cos(-k_ma)}{k_m}+\frac{2}{k_m}\left[\frac{\sin(k_mx)}{k_m}\right]_{x=-a}^a\\ = \frac{-2a\cos(k_ma)-2a\cos(-k_ma)}{k_m}+\frac{2}{k_m}\frac{\sin(k_ma)-\sin(-k_ma)}{k_m}.$$
Since $\cos(k_ma)=\cos(-k_ma)$ and $\sin(-k_ma)=-\sin(k_ma)$ we obtain $$=\frac{-4\cos(k_ma)}{k_m}+\frac{2}{k_m}\frac{2\sin(k_ma)}{k_m}=\frac{4\sin(k_ma)}{k_m^2},$$ where we used that $$\cos(k_ma)=\cos\left(\frac{2n+1}{2}\pi\right)=0.$$ (Recall that $\cos(n\pi/2)=0$ for all $n$, thus in particular for odd $n$.)
I guess the missing factor $\frac{1}{a}$ is a typo in your question or the book. At least I can't find any error in my calculation at the moment.
NB: Note that $$\sin(k_ma)=(-1)^n$$ so you obtain in the end $$\frac{4\sin(k_ma)}{k_m^2}=\frac{4(-1)^n(2a)^2}{(2n+1)^2\pi^2}=\frac{16(-1)^na^2}{(4n^2+2n+1)\pi^2}.$$
