To solve the integral
\[
\int \frac{\sin x - \cos x}{\sqrt{\sin 2x}} \, dx,
\]
we will follow these steps:
### Step 1: Rewrite the Denominator
First, we recognize that
\[
\sin 2x = 2 \sin x \cos x.
\]
Thus, we can rewrite the integral as:
\[
\int \frac{\sin x - \cos x}{\sqrt{2 \sin x \cos x}} \, dx.
\]
### Step 2: Simplify the Integral
Next, we can simplify the expression under the square root:
\[
\sqrt{2 \sin x \cos x} = \sqrt{2} \sqrt{\sin x \cos x}.
\]
So, the integral becomes:
\[
\int \frac{\sin x - \cos x}{\sqrt{2} \sqrt{\sin x \cos x}} \, dx = \frac{1}{\sqrt{2}} \int \frac{\sin x - \cos x}{\sqrt{\sin x \cos x}} \, dx.
\]
### Step 3: Use Substitution
Now, we can use the substitution \( t = \sin x + \cos x \). The derivative of \( t \) is:
\[
dt = (\cos x - \sin x) \, dx.
\]
Thus, we can express \( dx \) as:
\[
dx = \frac{dt}{\cos x - \sin x}.
\]
### Step 4: Express \(\sin x - \cos x\) in terms of \(t\)
Notice that:
\[
\sin x - \cos x = -(\cos x - \sin x).
\]
Now substituting into the integral, we have:
\[
\int \frac{\sin x - \cos x}{\sqrt{\sin x \cos x}} \, dx = -\int \frac{1}{\sqrt{\sin x \cos x}} \cdot \frac{dt}{\cos x - \sin x}.
\]
### Step 5: Rewrite \(\sqrt{\sin x \cos x}\)
Using the identity \(\sin x \cos x = \frac{1}{2} \sin 2x\), we can rewrite:
\[
\sqrt{\sin x \cos x} = \sqrt{\frac{1}{2} \sin 2x} = \frac{1}{\sqrt{2}} \sqrt{\sin 2x}.
\]
### Step 6: Substitute Back into the Integral
Now, substituting back into the integral gives:
\[
-\int \frac{1}{\sqrt{\frac{1}{2} \sin 2x}} \cdot \frac{dt}{\cos x - \sin x}.
\]
### Step 7: Solve the Integral
Using the formula for the integral of the form \(\int \frac{1}{\sqrt{x^2 - a^2}} \, dx\), we can solve the integral:
\[
-\log(t + \sqrt{t^2 - 1}) + C.
\]
### Step 8: Substitute Back for \(t\)
Finally, substituting back \(t = \sin x + \cos x\):
\[
-\log(\sin x + \cos x + \sqrt{(\sin x + \cos x)^2 - 1}) + C.
\]
### Final Answer
Thus, the final answer is:
\[
-\log(\sin x + \cos x + \sqrt{\sin^2 x + \cos^2 x}) + C = -\log(\sin x + \cos x + 1) + C.
\]