To prove that
\[
\int_0^{\frac{\pi}{2}} \sqrt{1 - \sin 2x} \, dx = 2(\sqrt{2} - 1),
\]
we will follow these steps:
### Step 1: Define the Integral
Let
\[
I = \int_0^{\frac{\pi}{2}} \sqrt{1 - \sin 2x} \, dx.
\]
### Step 2: Rewrite the Expression
We know that
\[
\sin 2x = 2 \sin x \cos x.
\]
Thus, we can rewrite \(1 - \sin 2x\) as:
\[
1 - \sin 2x = 1 - 2 \sin x \cos x.
\]
Using the identity \(1 = \sin^2 x + \cos^2 x\), we can express \(1\) as:
\[
1 = \sin^2 x + \cos^2 x.
\]
So we have:
\[
1 - \sin 2x = \sin^2 x + \cos^2 x - 2 \sin x \cos x = (\sin x - \cos x)^2.
\]
### Step 3: Substitute Back into the Integral
Now substituting this back into the integral, we get:
\[
I = \int_0^{\frac{\pi}{2}} \sqrt{(\sin x - \cos x)^2} \, dx.
\]
Since \(\sqrt{a^2} = |a|\), we have:
\[
I = \int_0^{\frac{\pi}{2}} |\sin x - \cos x| \, dx.
\]
### Step 4: Determine the Sign of the Expression
To evaluate this integral, we need to determine where \(\sin x\) is greater than \(\cos x\) and vice versa.
- At \(x = \frac{\pi}{4}\), \(\sin x = \cos x\).
- For \(0 \leq x < \frac{\pi}{4}\), \(\cos x > \sin x\).
- For \(\frac{\pi}{4} < x \leq \frac{\pi}{2}\), \(\sin x > \cos x\).
Thus, we can split the integral:
\[
I = \int_0^{\frac{\pi}{4}} (\cos x - \sin x) \, dx + \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} (\sin x - \cos x) \, dx.
\]
### Step 5: Evaluate Each Integral
1. **First Integral:**
\[
\int_0^{\frac{\pi}{4}} (\cos x - \sin x) \, dx = \left[ \sin x + \cos x \right]_0^{\frac{\pi}{4}} = \left(\sin \frac{\pi}{4} + \cos \frac{\pi}{4}\right) - \left(\sin 0 + \cos 0\right).
\]
Calculating this gives:
\[
= \left(\frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}}\right) - (0 + 1) = \sqrt{2} - 1.
\]
2. **Second Integral:**
\[
\int_{\frac{\pi}{4}}^{\frac{\pi}{2}} (\sin x - \cos x) \, dx = \left[-\cos x - \sin x \right]_{\frac{\pi}{4}}^{\frac{\pi}{2}} = \left(-\cos \frac{\pi}{2} - \sin \frac{\pi}{2}\right) - \left(-\cos \frac{\pi}{4} - \sin \frac{\pi}{4}\right).
\]
Calculating this gives:
\[
= (0 - 1) - \left(-\frac{1}{\sqrt{2}} - \frac{1}{\sqrt{2}}\right) = -1 + \sqrt{2} = \sqrt{2} - 1.
\]
### Step 6: Combine the Results
Now, combining both parts:
\[
I = (\sqrt{2} - 1) + (\sqrt{2} - 1) = 2(\sqrt{2} - 1).
\]
### Conclusion
Thus, we have shown that:
\[
\int_0^{\frac{\pi}{2}} \sqrt{1 - \sin 2x} \, dx = 2(\sqrt{2} - 1).
\]