Number of integral values of $x\in (\frac{\pi}{2},5\frac{\pi}{2})$ such that $\max(x^2+\cos x-1,1-x^2-\cos x)=\max(\cos x+x^2-1,x^2-1-\cos x)$ The number of integral values of $x\in(\frac{\pi}{2},5\frac{\pi}{2})$ such that
$$\max(x^2+\cos x-1,1-x^2-\cos x)=\max(\cos x+x^2-1,x^2-1-\cos x)$$ is satisfied is... ?
I understand that $\max(x,-x)=|x|$ but I could not simplify the right hand side of the equation.Please help me in this regard. Thanks.

For $x\in (\frac{\pi}{2},\frac{5}{2}\pi)$, we have that
$$\begin{align}(x^2+\cos x-1)-(1-x^2-\cos x)&=2(x^2+\cos x-1)\\\\&\ge 2(x^2-2)\\\\&\gt 2\left(\left(\frac{\pi}{2}\right)^2-2\right)\\\\&=\frac{1}{2}(\pi^2-8)\\\\&\gt 0\end{align}$$
and that
$$(\cos x+x^2-1)-(x^2-1-\cos x)=2\cos x\begin{cases}
\lt 0 & \text{if}\ x\in (\frac{\pi}{2},\frac{3}{2}\pi)\\[2ex]
\ge 0  & \text{if}\ x\in[\frac{3}{2}\pi,\frac{5}{2}\pi) 
\end{cases}
$$
For $x\in (\frac{\pi}{2},\frac{3}{2}\pi)$, the equation can be written as
$$x^2+\cos x-1=x^2-1-\cos x,$$
i.e.
$$\cos x=0$$
which does not hold.
For $x\in[\frac{3}{2}\pi,\frac{5}{2}\pi)$, the equation can be written as
$$x^2+\cos x-1=\cos x+x^2-1$$
which always holds.
Therefore, the answer is $\color{red}{3}$. ($x=5,6,7$)
