We have our function: $$f(x)=|\cos x|$$ We have to find the Fourier transformation for it:
Solution: First we have to find where it is defined. I think it is defined in $[-\dfrac{\pi}{2}, \dfrac{\pi}{2}]$. If I am wrong, where is it defined and why ?
Second we have to find a0:
$\displaystyle a_0=\dfrac{1}{\dfrac{\pi}{2}}\int_{}^{}\cos x\cos0 \,dx=2$ Right?
than for b0 we have:
$\displaystyle b_0=\dfrac{1}{\dfrac{\pi}{2}}\int_{}^{}\cos x\sin 0\,dx=0$ Right?
after that we have to find an:
$\displaystyle a_n=\dfrac{1}{\dfrac{\pi}{2}}\int_{}^{}\cos x\cos n\,dx$ which turned out to be very ugly as a result => I am making a mistake somewhere
My question is what have I mistaked so far and what do I have to do after
It's defined on the interval $[13, 42]$ because I decided so. This is an arbitrary choice: you pick an interval and restrict the function $\lvert\cos x\rvert$ to it.
But usually in exercises on Fourier series the interval is $[-\pi,\pi]$ so I'd stick with that by default.
Then you should calculate the coefficients. The function is even, so all sine coefficients are zeros. For cosine coefficients, we get
$$ a_n = \frac{1}{\pi} \int_{-\pi}^\pi \lvert\cos x\rvert\cos nx\,dx = \frac{2}{\pi} \int_{0}^\pi \lvert\cos x\rvert\cos nx\,dx $$ which can be evaluated by splitting the integral at $\pi/2$, where $\cos x$ changes sign: $$ a_n = \frac{2}{\pi} \int_{0}^{\pi/2} \cos x\cos nx\,dx - \frac{2}{\pi} \int_{\pi/2}^\pi \cos x\cos nx\,dx \\ = \frac{2}{\pi}\left( \frac{\cos(\pi n/2)}{1-n^2}- \frac{\cos(\pi n/2)}{n^2-1} \right) = \frac{4}{\pi}\frac{\cos(\pi n/2)}{1-n^2} $$ except for $n=1$, when the computation goes differently, producing $$a_1 = \frac{2}{\pi}\left( \frac{\pi}{4} + \frac{\pi}{4}\right) = 1$$