To solve the integral \( I = \int_{0}^{\frac{\pi}{2}} x \left| \sin^2 x - \frac{1}{2} \right| dx \), we need to first determine where the expression inside the absolute value changes sign.
### Step 1: Determine the points where \( \sin^2 x = \frac{1}{2} \)
The equation \( \sin^2 x = \frac{1}{2} \) gives us:
\[
\sin x = \frac{1}{\sqrt{2}} \quad \Rightarrow \quad x = \frac{\pi}{4}
\]
Thus, we have two intervals to consider for the integral: \( [0, \frac{\pi}{4}] \) and \( [\frac{\pi}{4}, \frac{\pi}{2}] \).
### Step 2: Evaluate the integral on the intervals
1. **For \( x \in [0, \frac{\pi}{4}] \)**:
- Here, \( \sin^2 x < \frac{1}{2} \), so \( \left| \sin^2 x - \frac{1}{2} \right| = \frac{1}{2} - \sin^2 x \).
- Therefore, the integral becomes:
\[
I_1 = \int_{0}^{\frac{\pi}{4}} x \left( \frac{1}{2} - \sin^2 x \right) dx
\]
2. **For \( x \in [\frac{\pi}{4}, \frac{\pi}{2}] \)**:
- Here, \( \sin^2 x > \frac{1}{2} \), so \( \left| \sin^2 x - \frac{1}{2} \right| = \sin^2 x - \frac{1}{2} \).
- Therefore, the integral becomes:
\[
I_2 = \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} x \left( \sin^2 x - \frac{1}{2} \right) dx
\]
### Step 3: Combine the integrals
The total integral is:
\[
I = I_1 + I_2 = \int_{0}^{\frac{\pi}{4}} x \left( \frac{1}{2} - \sin^2 x \right) dx + \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} x \left( \sin^2 x - \frac{1}{2} \right) dx
\]
### Step 4: Evaluate \( I_1 \)
For \( I_1 \):
\[
I_1 = \int_{0}^{\frac{\pi}{4}} \left( \frac{x}{2} - x \sin^2 x \right) dx
\]
This can be split into two separate integrals:
\[
I_1 = \frac{1}{2} \int_{0}^{\frac{\pi}{4}} x \, dx - \int_{0}^{\frac{\pi}{4}} x \sin^2 x \, dx
\]
Calculating the first integral:
\[
\frac{1}{2} \int_{0}^{\frac{\pi}{4}} x \, dx = \frac{1}{2} \cdot \left[ \frac{x^2}{2} \right]_{0}^{\frac{\pi}{4}} = \frac{1}{2} \cdot \frac{(\frac{\pi}{4})^2}{2} = \frac{\pi^2}{32}
\]
For the second integral, we can use integration by parts:
Let \( u = x \) and \( dv = \sin^2 x \, dx \).
Then, \( du = dx \) and \( v = \frac{x}{2} - \frac{\sin(2x)}{4} \).
### Step 5: Evaluate \( I_2 \)
For \( I_2 \):
\[
I_2 = \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} \left( x \sin^2 x - \frac{x}{2} \right) dx
\]
This can also be split into two integrals:
\[
I_2 = \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} x \sin^2 x \, dx - \frac{1}{2} \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} x \, dx
\]
### Step 6: Combine results and simplify
After evaluating both \( I_1 \) and \( I_2 \), we will sum them up to find \( I \).
### Final Step: Express \( I \) in the form \( \frac{a \pi}{b} \)
After evaluating the integrals and simplifying, we will find \( I = \frac{a \pi}{b} \) where \( a \) and \( b \) are coprime integers. Finally, we will calculate \( a \cdot b \).