Show that the Fourier transform of $f(x)$ is given by $\widetilde{f}(k)=\frac{2}{k^2}[cos(kb)-cos(ka)]$ 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
My definition of fourier transformation:

 A: Function $f$ is a rather classical convolution of 2 "rectangular pulse" functions with the following result given under the graphical form of Fig. 1.

Fig. 1: The case $A \ge B$. In this case $a=\frac12(A+B)$ and $b=\frac12(A-B)$ which is equivalent to $A=a+b$ and $B=a-b$.
In order to find which "rect" functions are into play, let us start from the solution which can be written :
$$\widetilde{f}(k)=-\frac{2}{k^2}[\cos(ka)-\cos(kb)]=2\frac{2}{k^2}[\sin(\tfrac{k(a+b)}{2})\sin(\tfrac{k(a-b)}{2})]$$
which can be written in this way:
$$(a+b)(a-b)\left(\frac{\sin(\tfrac{k(a+b)}{2})}{\tfrac{k(a+b)}{2}}\right)\left(\frac{\sin(\tfrac{k(a-b)}{2})}{\tfrac{k(a-b)}{2}}\right)$$
where we recognize a product of cardinal sine (i.e., sinc) functions:
This $\color{red}{product}$ can be "inverted" as expected as the $\color{red}{convolution}$ of $2$ rectangular pulses.
Knowing that the Fourier Transform of the standard sinc function is the standard $\Pi_1$ function, and that the Fourier transform of $f(k\alpha)$ is $\dfrac{1}{|\alpha|}\widetilde{f}(\tfrac{x}{\alpha})$, we obtain:
$$(a+b)(a-b)\left(\tfrac{2}{a+b}\Pi_1(\tfrac{2}{a+b}x)\right) \star \left(\tfrac{2}{a-b}\Pi_1(\tfrac{2}{a-b}x)\right)$$
which is exactly what was desired...
A: *

*You've to use Integral by parts (or u-v method) for the first and third parts as they has product $\color{blue}{\exp(ikx)(a\pm x)}$.

*As pointed by @KaviRamaMurthy, you can't have $\exp(ik\color{red}x)$ after evaluating a definite integral.

$$\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)$
