Fourier Transform of Given the quantum state function $\psi_1(x)=\sqrt{\dfrac{2}{a}} \sin{\dfrac{\pi x}{a}}$ , calculate it´s Fourier Trabsform for the momentum, defined as: $$\phi_1(p)=\dfrac{1}{\sqrt{2\pi \hbar}}\int_{-\infty}^{\infty}  e^{-ipx/\hbar}\cdot\psi_1(x)dx$$

What i´ve done is to express the $\sin$ function into his complex form and opearte with the nucleus of the transform:
$$\phi_1(p)=\dfrac{1}{\sqrt{2\pi \hbar}}\int_{-\infty}^{\infty}  e^{-ipx/\hbar}\cdot(\sqrt{\dfrac{2}{a}} \sin{\dfrac{\pi x}{a}})dx=$$
$$=\dfrac{1}{\sqrt{\pi \hbar a}}\dfrac{1}{2i}\int  e^{-ipx/\hbar}\cdot (e^{i\pi x/a}-e^{-i\pi x/a})  dx=$$
And after solving the integral, i´ve got:
$$\dfrac{1}{\sqrt{\pi \hbar a}}\dfrac{1}{2i}(-\dfrac{ie^{-ix(\pi/a+p/\hbar)}}{\pi/a+p/\hbar}-\dfrac{ie^{ix(\pi/a-p/\hbar)}}{\pi/a-p/\hbar})$$
And here is where the problems begin, because i´ve been told that the integration limits change from $-\infty,\infty$ to $0, a$, and i can´t see why.
And the supposed solution to the transformation is:
$$\phi_1(p)=e^{-pa/2\hbar}\dfrac{(2\pi /a)\cos{(pa/2\hbar)}}{\sqrt{\pi \hbar a}(\pi/a)^2-(p/\hbar)^2}$$
And i can´t connect my integration result to the given solution.
 A: Firstly, why do we have $[0, a]$, well these are the walls that the system is defined within. Thus, integrating becomes integrating between $0$ and $a$.
Now on to your integral.
$$
\int_0^a \mathrm{e}^{-ipx\hbar}\cdot\left(\mathrm{e}^{i\frac{\pi}{a}x} - \mathrm{e}^{-i\frac{\pi}{a}x}\right)dx = \int_0^a \mathrm{e}^{-i(p\hbar -\frac{\pi}{a})x} - \mathrm{e}^{-i(p\hbar +\frac{\pi}{a})x}dx
$$
which becomes
$$
\left[\frac{\mathrm{e}^{-i(p\hbar -\frac{\pi}{a})x}}{-i(p\hbar -\frac{\pi}{a})}-\frac{\mathrm{e}^{-i(p\hbar +\frac{\pi}{a})x}}{-i(p\hbar +\frac{\pi}{a})}\right]_0^a
$$
or
$$
\left[\mathrm{e}^{-ip\hbar x}\left(\frac{\mathrm{e}^{i\frac{\pi}{a}x}}{-i(p\hbar -\frac{\pi}{a})}-\frac{\mathrm{e}^{-i\frac{\pi}{a}x}}{-i(p\hbar +\frac{\pi}{a})}\right)\right]_0^a
$$
this becomes
$$
\mathrm{e}^{-ip\hbar a}\left(\frac{\mathrm{e}^{i\pi}}{-i(p\hbar -\frac{\pi}{a})}-\frac{\mathrm{e}^{-i\pi}}{-i(p\hbar +\frac{\pi}{a})}\right) - \left(\frac{1}{-i(p\hbar -\frac{\pi}{a})}-\frac{1}{-i(p\hbar +\frac{\pi}{a})}\right)
$$
now we have Euler identity $\mathrm{e}^{i\pi} = -1 = \mathrm{e}^{-i\pi}$
$$
\mathrm{e}^{-ip\hbar a}\left(\frac{-1}{-i(p\hbar -\frac{\pi}{a})}-\frac{-1}{-i(p\hbar +\frac{\pi}{a})}\right) - \left(\frac{1}{-i(p\hbar -\frac{\pi}{a})}-\frac{1}{-i(p\hbar +\frac{\pi}{a})}\right)
$$
This becomes
$$
\frac{-1}{-i(p\hbar -\frac{\pi}{a})}-\frac{-1}{-i(p\hbar +\frac{\pi}{a})} = \frac{1}{i}\frac{(p\hbar +\frac{\pi}{a}) - (p\hbar -\frac{\pi}{a})}{(p\hbar -\frac{\pi}{a})(p\hbar +\frac{\pi}{a})} = i\frac{2\pi/a}{(p\hbar)^2 - \left(\frac{\pi}{a}\right)^2}
$$
and noticing there is just a minus sign difference.
$$
\frac{1}{-i(p\hbar -\frac{\pi}{a})}-\frac{1}{-i(p\hbar +\frac{\pi}{a})} = -i\frac{2\pi/a}{(p\hbar)^2 - \left(\frac{\pi}{a}\right)^2}
$$
This leads to
$$
i\mathrm{e}^{-ip\hbar a}\frac{2\pi/a}{(p\hbar)^2 - \left(\frac{\pi}{a}\right)^2}+i\frac{2\pi/a}{(p\hbar)^2 - \left(\frac{\pi}{a}\right)^2}
$$
or
$$
i\frac{2\pi/a}{(p\hbar)^2 - \left(\frac{\pi}{a}\right)^2}(1+\mathrm{e}^{-ip\hbar a}) 
$$
Combine this with the rest of the integral we have
$$
\frac{1}{\sqrt{\pi \hbar a}}\frac{1}{2i}\cdot i\frac{2\pi/a}{(p\hbar)^2 - \left(\frac{\pi}{a}\right)^2}(1+\mathrm{e}^{-ip\hbar a}) = \frac{1}{\sqrt{\pi \hbar a}}\cdot \frac{\pi/a}{(p\hbar)^2 - \left(\frac{\pi}{a}\right)^2}(1+\mathrm{e}^{-ip\hbar a}) 
$$
The final part is, we want real part of the above
$$
\mathcal{Re}(1+\mathrm{e}^{-ip\hbar a}) = 1 + \cos(p\hbar a) = 2\cos^2\left(\frac{p\hbar a}{2}\right)
$$
so I get
$$
\phi_1(p) = \frac{1}{\sqrt{\pi \hbar a}}\cdot \frac{2\pi/a}{(p\hbar)^2 - \left(\frac{\pi}{a}\right)^2}\cos^2\left(\frac{p\hbar a}{2}\right)
$$
Not sure how they got the solution. But you made a couple of mistakes, namely the itegral evaulated at $0$ is not zero.
