Question #98482

Jun 5, 2017

$\int \frac{{\sin}^{2} \left(\frac{x}{2}\right) + {\cos}^{2} \left(\frac{x}{2}\right)}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} \mathrm{dx} = \sqrt{2} \ln \left\mid \frac{\tan \left(\frac{x}{4}\right) + 1 - \sqrt{2}}{\tan \left(\frac{x}{4}\right) + 1 + \sqrt{2}} \right\mid + C$

Explanation:

Based on the fundamental trigonometric identity:

${\sin}^{2} \alpha + {\cos}^{2} \alpha = 1$

we have that:

$\int \frac{{\sin}^{2} \left(\frac{x}{2}\right) + {\cos}^{2} \left(\frac{x}{2}\right)}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} \mathrm{dx} = \int \frac{\mathrm{dx}}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)}$

Use now the parametric fomulas:

$\sin \left(\frac{x}{2}\right) = \frac{2 \tan \left(\frac{x}{4}\right)}{1 + {\tan}^{2} \left(\frac{x}{4}\right)}$

$\cos \left(\frac{x}{2}\right) = \frac{1 - {\tan}^{2} \left(\frac{x}{4}\right)}{1 + {\tan}^{2} \left(\frac{x}{4}\right)}$

substituting:

$t = \tan \left(\frac{x}{4}\right)$

$x = 4 \arctan \left(t\right)$

$\mathrm{dx} = \frac{4 \mathrm{dt}}{1 + {t}^{2}}$

we have:

$\int \frac{\mathrm{dx}}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} = \int \frac{1}{\frac{2 t}{1 + {t}^{2}} - \frac{1 - {t}^{2}}{1 + {t}^{2}}} \frac{4 \mathrm{dt}}{1 + {t}^{2}}$

$\int \frac{\mathrm{dx}}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} = 4 \int \frac{\mathrm{dt}}{{t}^{2} + 2 t - 1}$

Complete the square at the denominator:

$\int \frac{\mathrm{dx}}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} = 4 \int \frac{\mathrm{dt}}{{\left(t + 1\right)}^{2} - 2} = 2 \int \frac{\mathrm{dt}}{{\left(\frac{t + 1}{\sqrt{2}}\right)}^{2} - 1}$

Substitute again:

$u = \frac{t + 1}{\sqrt{2}}$

$\mathrm{dt} = \sqrt{2} \mathrm{du}$

so:

$\int \frac{\mathrm{dx}}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} = 2 \sqrt{2} \int \frac{\mathrm{du}}{{u}^{2} - 1}$

factorize the denominator and perform partial fractions decompositions:

$\frac{1}{{u}^{2} - 1} = \frac{1}{\left(u - 1\right) \left(u + 1\right)} = \frac{1}{2} \left(\frac{1}{u - 1} - \frac{1}{u + 1}\right)$

Then:

$\int \frac{\mathrm{dx}}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} = \sqrt{2} \left(\int \frac{\mathrm{du}}{u - 1} - \int \frac{\mathrm{du}}{u + 1}\right)$

$\int \frac{\mathrm{dx}}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} = \sqrt{2} \left(\ln \left\mid u - 1 \right\mid - \ln \left\mid u + 1 \right\mid\right) + C$

using the properties of logarithms:

$\int \frac{\mathrm{dx}}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} = \sqrt{2} \ln \left\mid \frac{u - 1}{u + 1} \right\mid + C$

undoing the substitutions:

$u = \frac{\tan \left(\frac{x}{4}\right) + 1}{\sqrt{2}}$

$\frac{u - 1}{u + 1} = \frac{\frac{\tan \left(\frac{x}{4}\right) + 1}{\sqrt{2}} - 1}{\frac{\tan \left(\frac{x}{4}\right) + 1}{\sqrt{2}} + 1} = \frac{\tan \left(\frac{x}{4}\right) + 1 - \sqrt{2}}{\tan \left(\frac{x}{4}\right) + 1 + \sqrt{2}}$

Finally:

$\int \frac{\mathrm{dx}}{\sin \left(\frac{x}{2}\right) - \cos \left(\frac{x}{2}\right)} = \sqrt{2} \ln \left\mid \frac{\tan \left(\frac{x}{4}\right) + 1 - \sqrt{2}}{\tan \left(\frac{x}{4}\right) + 1 + \sqrt{2}} \right\mid + C$