\(I=\int\limits^{\frac{\pi}{2}}_0\left(2x-1\right)\cos^2xdx=\int\limits^{\frac{\pi}{2}}_0\left(2x-1\right)\left(\frac{1+\cos2x}{2}\right)dx=\int\limits^{\frac{\pi}{2}}_0\left(x-\frac{1}{2}\right)dx+\frac{1}{2}\int\limits^{\frac{\pi}{2}}_0\left(2x-1\right)\cos2xdx\)
\(=\left(\frac{1}{2}x^2-\frac{1}{2}x\right)|^{\frac{\pi}{2}}_0+\frac{1}{2}\int\limits^{\frac{\pi}{2}}_0\left(2x-1\right)d\left(\sin2x\right)=\frac{\pi^2}{8}-\frac{\pi}{4}+\frac{1}{2}\left[\left(2x-1\right)\sin2x|^{\frac{\pi}{2}}_0-\int\limits^{^{\frac{\pi}{2}}_0}_0\sin2x.2dx\right]\)
\(=\frac{\pi^2}{8}-\frac{\pi}{4}+\left(0+\cos2x|^{\frac{\pi}{2}}_0\right)=\frac{\pi^2}{8}-\frac{\pi}{4}-1\)