I have this function:
$f(x)=\begin{cases} 0&x<-a\\ a+x & -a\leq x<-b\\ a-b& -b \leq x<b\\ a-x & b\leq x <a\\ 0 & x\geq a \end{cases}$
I have to show that the Fourier transform is given by $\widetilde{f}(k)=\frac{2}{k^2}[cos(kb)-cos(ka)]$
My solution:
i got $\widetilde{f}(k)=2 exp(ikx)[a^2-b^2]$
How do i obtain $\widetilde{f}(k)=\frac{2}{k^2}[cos(kb)-cos(ka)]$ from my solution



$$\begin{align}\tilde y(k) &= \int_{-a}^{-b}\exp(ikx)(a+x)dx +(a-b)\int_{-b}^b\exp(ikx)dx + \int_{b}^{a}\exp(ikx)(a-x)dx \\&= \left[\frac{(x+a)\exp(ikx)}{ik}-\frac{e^{ikx}}{-k^2}\right]_{-a}^{-b} + (a-b)\frac{\exp(ikb)-\exp(-ikb)}{ik}\\&+\left[-\frac{(x-a)\exp(ikx)}{ik} +\frac{e^{ikx}}{-k^2}\right]_{b}^{a}\end{align}$$
Now you can sub the limits for the first and third integrals. The terms with $ik$ in the denominator get cancelled, then use the fact that $2\cos(z) = \exp(iz)+\exp(-iz)$