\(I=-\frac{1}{2}\int_0^{\frac{\pi}{4}}\left(x^2-4x+3\right)d\cos2x\)
\(=-\frac{1}{2}\left[\left(x^2-4x+3\right)\cos2x\right]_0^{\frac{\pi}{4}}-\int^{^{\frac{\pi}{4}}}_0\cos2xd\left(x^2-4x+\right)\)
\(=\frac{3}{2}+\int^{^{\frac{\pi}{4}}}_0\left(x-2\right)\cos2xd=\frac{3}{2}+\frac{1}{2}\int^{^{\frac{\pi}{4}}}_0\left(x-2\right)\sin2x\)
\(=\frac{3}{2}+\frac{1}{2}\left[\left(x-2\right)\sin2x_0^{\frac{\pi}{4}}-\int^4_0\sin2dx\left(x-2\right)\right]\)
\(=\frac{3}{2}+\frac{1}{2}\left[\frac{\pi}{4}-2+\frac{1}{2}\cos2x_0^{\frac{\pi}{4}}\right]\)
\(=\frac{3}{2}+\frac{1}{2}\left[\frac{\pi}{4}-2-\frac{1}{2}\right]=\frac{\pi}{8}+\frac{1}{4}\)