Definite Integration

Evaluate $\displaystyle \int \limits_{0}^{\frac{\pi}{2}} \dfrac{\sin^2 x}{\sin x + \cos x} \; dx$


$\begin{aligned} \text{Let } I & = \int \limits_{0}^{\frac{\pi}{2}} \dfrac{\sin^2 x}{\sin x + \cos x} \; dx \;\;\; \cdots \; (1) \\\\ & = \int \limits_{0}^{\frac{\pi}{2}} \dfrac{\left[\sin \left(\dfrac{\pi}{2} - x\right)\right]^2}{\sin \left(\dfrac{\pi}{2} - x\right) + \cos \left(\dfrac{\pi}{2} - x\right)} \; dx \\\\ & \hspace{3em} \left[\text{Note: } \int \limits_{0}^{a} f\left(x\right) \; dx = \int \limits_{0}^{a} f\left(x - a\right) \; dx\right] \\\\ & = \int \limits_{0}^{\frac{\pi}{2}} \dfrac{\cos^2 x}{\cos x + \sin x} \; dx \;\;\; \cdots \; (2) \end{aligned}$

Adding equations $(1)$ and $(2)$ gives

$2 I = \displaystyle \int \limits_{0}^{\frac{\pi}{2}} \dfrac{\sin^2 x + \cos^2 x}{\sin x + \cos x} \; dx$

i.e. $I = \dfrac{1}{2} \displaystyle \int \limits_{0}^{\frac{\pi}{2}} \dfrac{1}{\sin x + \cos x} \; dx$ $\;\;\; \cdots \; (3)$

Let $\tan \left(\dfrac{x}{2}\right) = u$ $\;\;\; \cdots \; (4)$

Differentiating equation $(4)$ gives

$\dfrac{1}{2} \sec^2 \left(\dfrac{x}{2}\right) \; dx = du$

i.e. $dx = \dfrac{2 \; du}{\sec^2 \left(\dfrac{x}{2}\right)} = \dfrac{2 \; du}{1 + \tan^2 \left(\dfrac{x}{2}\right)} = \dfrac{2 \; du}{1 + u^2}$ $\;\;\; \cdots \; (4a)$

Now, $\sin x = \dfrac{2 \tan \left(\dfrac{x}{2}\right)}{1 + \tan^2 \left(\dfrac{x}{2}\right)} = \dfrac{2 u}{1 + u^2}$ $\;\;\; \cdots \; (4b)$

and $\cos x = \dfrac{1 - \tan^2 \left(\dfrac{x}{2}\right)}{1 + \tan^2 \left(\dfrac{x}{2}\right)} = \dfrac{1 - u^2}{1 + u^2}$ $\;\;\; \cdots \; (4c)$

$\text{When } \begin{cases} x = 0, & u = \tan 0 = 0 \\ x = \dfrac{\pi}{2}, & u = \tan \left(\dfrac{\pi}{4}\right) = 1 \end{cases}$ $\;\;\; \cdots \; (4d)$

$\therefore$ $\;$ In view of equations $(4)$, $(4a)$, $(4b)$, $(4c)$ and $(4d)$, equation $(3)$ can be written as

$\begin{aligned} I & = \dfrac{1}{2} \int \limits_{0}^{1} \dfrac{\dfrac{2 \; du}{1 + u^2}}{\dfrac{2 u}{1 + u^2} + \dfrac{1 - u^2}{1 + u^2}} \\\\ & = \int \limits_{0}^{1} \dfrac{du}{1 + 2u - u^2} \\\\ & = - \int \limits_{0}^{1} \dfrac{du}{\left(u^2 - 2u + 1\right) -1 -1} \\\\ & = - \int \limits_{0}^{1} \dfrac{du}{\left(u - 1\right)^2 - 2} \\\\ & = \int \limits_{0}^{1} \dfrac{du}{\left(\sqrt{2}\right)^2 - \left(u - 1\right)^2} \\\\ & = \dfrac{1}{2 \sqrt{2}} \left[\log \left|\dfrac{\sqrt{2} + u - 1}{\sqrt{2} - u + 1}\right|\right]_{0}^{1} \hspace{3em} \left[\text{Note: } \int \dfrac{dx}{a^2 - x^2} = \dfrac{1}{2a} \log \left|\dfrac{a + x}{a - x}\right| + c\right] \\\\ & = \dfrac{1}{2 \sqrt{2}} \left[\log \left|\dfrac{\sqrt{2} + 1 - 1}{\sqrt{2} - 1 + 1}\right| - \log \left|\dfrac{\sqrt{2} + 0 - 1}{\sqrt{2} - 0 + 1}\right|\right] \\\\ & = \dfrac{1}{2 \sqrt{2}} \left[\log 1 - \log \left|\dfrac{\sqrt{2} - 1}{\sqrt{2} + 1}\right|\right] \\\\ & = \dfrac{1}{2 \sqrt{2}} \left[0 + \log \left|\dfrac{\sqrt{2} + 1}{\sqrt{2} - 1}\right|\right] \\\\ & = \dfrac{1}{2 \sqrt{2}} \log \left|\dfrac{\left(\sqrt{2} + 1\right)^2}{2 - 1}\right| \\\\ & = \dfrac{1}{2 \sqrt{2}} \log \left|\left(\sqrt{2} + 1\right)^2\right| \\\\ & = \dfrac{1}{2 \sqrt{2}} \times 2 \log \left|\sqrt{2} + 1\right| \\\\ & = \dfrac{1}{\sqrt{2}} \log \left|\sqrt{2} + 1\right| \end{aligned}$