Indefinite Integration

Evaluate $\displaystyle \int e^x \left(\dfrac{1 - \sin x}{1 - \cos x}\right) \; dx$


$\left[\begin{aligned} \text{Note: } & \sin x = 2 \sin \left(\dfrac{x}{2} \right) \cos \left(\dfrac{x}{2}\right) \\\\ & 1 - \cos x = 2 \sin^2 \left(\dfrac{x}{2}\right) \end{aligned}\right]$

$\begin{aligned} \text{Let } I & = \int e^x \left\{\dfrac{1 - \sin x}{1 - \cos x}\right\} \; dx \\\\ & = \int e^x \left\{\dfrac{1 - 2 \sin \left(\dfrac{x}{2}\right) \cos \left(\dfrac{x}{2}\right)}{2 \sin^2 \left(\dfrac{x}{2}\right)}\right\} \; dx \\\\ & = \int e^x \left\{\dfrac{1}{2 \sin^2 \left(\dfrac{x}{2}\right)} - \dfrac{\cos \left(\dfrac{x}{2}\right)}{\sin \left(\dfrac{x}{2}\right)}\right\} \; dx \\\\ & = \int e^x \left\{\dfrac{1}{2} \text{cosec}^2 \left(\dfrac{x}{2}\right) - \cot \left(\dfrac{x}{2}\right)\right\} \; dx \\\\ & \left[\text{Note: } \int e^x \left[f \left(x\right) + f'\left(x\right) \; dx\right] = e^x f\left(x\right) + c\right] \\\\ & \text{Here, if } f\left(x\right) = - \cot \left(\dfrac{x}{2}\right), \text{ then } f'\left(x\right) = \dfrac{1}{2} \text{cosec}^2 \left(\dfrac{x}{2}\right) \\\\ \therefore \; I & = \int e^x \left\{- \cot \left(\dfrac{x}{2} \right) + \dfrac{d}{dx} \left[- \cot \left(\dfrac{x}{2}\right)\right] \right\} \; dx \\\\ & = - e^x \cot \left(\dfrac{x}{2}\right) + c \end{aligned}$