Apply Leibniz rule for differentiation under the integral with variable limits. Let
\[
f(x) = \int_{x^2}^{\cos^2 x} g(x) dx
\]
Then
\[
f(x) = -\int_{\cos^2 x}^{x^2} g(x) dx = -x^3 \sin 2x + \pi
\]
using integral simplification and given boundary value.