Given $S = \Sigma a_k + b_k$ and $I = \int^{\pi}_{-\pi} f^2 dx$, determine if $S=I$ . Function $f=\|cos x|$

So, the first part of the task was to find the Fourier series for the function $$f=\left|\cos x\right|$$ and now I have to tell whether $$\sum a_k + b_k = \int^{\pi}_{-\pi} f^2 \,dx$$. The coefficients $$a_k, b_k$$ are the coefficients for Fourier series.

I computed Fourier series representation of the function: $$f(x) = -\frac{1}{2\pi}$$. For some reason I got a negative coefficient $$a_0 = \frac{1}{2\pi}\int^{-\pi}{\pi} \left|\cos x\right| = \frac{1}{2\pi}\int^{-\pi}_{\pi} \left|\cos x\right|\,dx = -\frac{1}{2\pi}\int_{-\pi}^{-\frac{\pi}{2}} \cos x \,dx + \frac{1}{2\pi}\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}}\cos x \,dx- \frac{1}{2\pi}\int^{\pi}_{\frac{\pi}{2}}\cos x \,dx = -\frac{1}{\pi}$$. The middle term cancels out so I'm left with: $$-\frac{1}{2\pi}\int_{-\pi}^{-\frac{\pi}{2}}\cos x \,dx- \frac{1}{2\pi}\int^{\pi}_{\frac{\pi}{2}}\cos x \,dx = \frac{1}{2\pi}\left[\sin x \right]^{-\frac{\pi}{2}}_{-\pi}+\frac{1}{2\pi}\left[\sin x \right]^{\pi}_{\frac{\pi}{2}}= -\frac{1}{2\pi}-\frac{1}{2\pi}= -\frac{1}{\pi}$$ I know this cannot be true as $$f(x)$$ should be positive and all the rest of the coefficients for Fourier series cancel out. Anyway in the result I get that Fourier representation for the given function is: $$f(x) = -\frac{1}{2\pi}$$ Then I calculate the given integral $$I: \int^{\pi}_{-\pi} f^2 \,dx = \int^{\pi}_{-\pi}\cos^2 x \,dx =\pi$$ But I am not sure about the sum $$\sum a_k +b_k$$. Is it just a sum of all the coefficients, in this case: $$a_0 + a_n + b_n = -\frac{1}{\pi}$$? So, I get that $$S \neq I$$, but I know I am wrong about the $$a_0$$ coefficient.

$$\int_{-\pi}^{\pi} \cos^2{x} \; dx$$ is not equal to $$-\frac{1}{3}\sin^3{x} \big\rvert_{-\pi}^{\pi}$$, you should actually use the power reduction formula: $$\cos^2{x}=\frac{1}{2}\left(1+\cos{2x}\right)$$. So the integral is equal to $$\frac{x}{2}+\frac{1}{4}\sin{2x} \big\rvert_{-\pi}^{\pi}=\pi$$. Just differentiate $$-\frac{1}{3}\sin^3{x}$$ with respect to $$x$$ to see that the integrand is not equivalent.