Integrating $f(x)=\int|\cos(x)|dx$ and then solving $f(x)=\frac {2x}{\pi}$? I realised the other day that by applying absolute value signs to the cosine function and then integrating, I would get an almost sine function that doesn't have negative slope.
And then I also noticed that it would probably stay close to the line $$g(x)=\frac {2x}{\pi}$$
So could someone integrate $$f(x)=\int|\cos(x)|dx,$$
then set it equal to $g(x)$ and solve?
 A: Consider that $\left|\,\cos(x)\,\right|$ has a not-so-terrible Fourier cosine series. In particular:
$$\begin{eqnarray*} \left|\,\cos(x)\,\right| &=& \frac{2}{\pi}+\frac{4}{3\pi}\cos(2x)-\frac{4}{15\pi}\cos(2x)+\frac{4}{35\pi}\cos(4x)-\ldots\\&=&\frac{2}{\pi}-\frac{4}{\pi}\sum_{n\geq 1}\frac{(-1)^n}{4n^2-1}\,\cos(2n x)\tag{1}\end{eqnarray*}$$
hence $\int_{0}^{z}\left|\,\cos(x)\,\right|dx$ can be written as a fast-converging series:
$$\int_{0}^{z}\left|\,\cos(x)\,\right|dx = \frac{2z}{\pi}-\frac{4}{\pi}\sum_{n\geq 1}\frac{(-1)^n}{(2n-1)(2n)(2n+1)}\sin(2nz)\tag{2} $$
and the difference between the LHS and $\frac{2z}{\pi}$, in absolute value, is obviously bounded by:
$$ \frac{4}{\pi}\sum_{n\geq 1}\frac{1}{(2n-1)(2n)(2n+1)}=\frac{2}{\pi}\left(\log 4-1\right)<\frac{1}{4}.\tag{3}$$
That gives that the only solutions of $\int_{0}^{z}\left|\,\cos(x)\,\right|dz = \frac{z}{\pi}$ have to lie quite close to the origin, for sure in the region $|z|<\frac{\pi}{2}$. In such a case, however, the absolute value appearing inside the integral is completely useless, we are just solving $\sin(z)=\frac{z}{\pi}$, with the only solution $z=0$ inside the given domain.
A: Your integral (from $0$) may be represented in form
$$\lim_{N\to\infty}\left( \sin(x)\operatorname{sgn}(\cos(x))+
\sum _{n=1}^N\left(2\operatorname{H}\left(x-\frac{\pi }{2}+n\pi\right)-2\right)+
\sum _{n=0}^{N-1}2\operatorname{H}\left(x-\frac{\pi }{2}-n\pi\right)\right)$$
Where $\operatorname{H}$ is the Heaviside step function. You can see the plot here. It is close to the line $y=2x/\pi$ and the functions are equal at points $$\left(\frac{k\pi }{2},k\right),\quad k\in\mathbb{Z}$$
A: Assume $x\in\mathbb{R}$:
$$\int\left|\cos(x)\right|\space\text{d}x=\sin(x)\text{sgn}(\cos(x))+\text{C}$$
