Indefinite Integration

Evaluate $\displaystyle \int e^{-x/2} \; \cos^2 x \; dx$

Let $I = \displaystyle \int e^{-x/2} \; \cos^2 x \; dx$ $\;\;\; \cdots (1)$

Let $\dfrac{- x}{2} = p$ $\;\;\; \cdots (2a)$

Differentiating equation $(2a)$ $\;$ w.r.t x gives

$\dfrac{- 1}{2} \; dx = dp$ $\implies$ $dx = - 2 \; dp$ $\;\;\; \cdots (2b)$

From equation $(2a)$, we have $x = - 2 p$

$\therefore$ $\;$ $\cos x = \cos \left(-2 p\right) = \cos \left(2 p\right)$ $\;\;\; \cdots (2c)$

$\therefore$ $\;$ In view of equations $(2a)$, $(2b)$ and $(2c)$, equation $(1)$ can becomes

$\begin{aligned} I & = - 2 \int e^p \; \cos^2 \left(2 p\right) \; dp \\\\ & = - 2 \int e^p \left(\dfrac{1 + \cos \left(4 p\right)}{2}\right) \; dp \;\;\; \left[\text{Note: } \cos^2 \theta = \dfrac{1 + \cos \left(2 \theta\right)}{2}\right] \\\\ & = - \int e^p \; dp - \int e^p \; \cos \left(4 p\right) \; dp \;\;\; \cdots (3) \end{aligned}$

$\left[\text{Note: } \displaystyle \int u \; v \; dx = u \int v \; dx - \int \left\{\int v \; dx \times \dfrac{d}{dx} \left(v\right) \right\} \; dx \right]$

Consider $I_1 = \displaystyle \int e^p \; \cos \left(4 p\right) \; dp$

Here $u = \cos \left(4 p\right)$ and $v = e^p$

$\begin{aligned} \therefore \; I_1 & = \cos \left(4 p\right) \int e^p \; dp - \int \left\{\int e^p \; dp \times \dfrac{d}{dp} \left[\cos \left(4 p\right)\right] \right\} \; dp \\\\ & = e^p \; \cos \left(4 p\right) + 4 \int e^p \; \sin \left(4 p\right) \; dp \\\\ & = e^p \; \cos \left(4 p\right) + 4 \left[\sin \left(4 p\right) \int e^p \; dp - \int \left\{\int e^p \; dp \times \dfrac{d}{dp} \left[\sin \left(4 p\right)\right] \right\} \; dp\right] \\\\ & \left[\text{Note: Here } u = \sin \left(4 p\right) \text{ and } v = e^p \right] \\\\ & = e^p \; \cos \left(4 p\right) + 4 \left[e^p \sin \left(4 p\right) - 4 \int e^p \; \cos \left(4 p\right) \; dp \right] \\\\ & = e^p \; \cos \left(4 p\right) + 4 \; e^p \; \sin \left(4 p\right) - 16 \int e^p \; \cos \left(4 p\right) \; dp \\\\ \text{i.e.} \; 17 \; I_1 & = e^p \; \cos \left(4 p\right) + 4 \; e^p \; \sin \left(4 p\right) + c_1 \\\\ \therefore \; I_1 & = \dfrac{1}{17} \left[e^p \; \cos \left(4 p\right) + 4 \; e^p \; \sin \left(4 p\right)\right] + \dfrac{c_1}{17} \;\;\; \cdots (4) \end{aligned}$

$\therefore$ $\;$ In view of equation $(4)$, equation $(3)$ becomes

$\begin{aligned} I & = - e^p - \dfrac{1}{17} \left[e^p \; \cos \left(4 p\right) + 4 \; e^p \; \sin \left(4 p\right)\right] + c \;\;\; \left[\text{where } c = \dfrac{-c_1}{17}\right] \\\\ & = -e^{-x/2} - \dfrac{e^{-x/2}}{17} \left[\cos \left(\dfrac{-4 x}{2}\right) + 4 \sin \left(\dfrac{-4 x}{2}\right)\right] + c \;\;\; \left[\text{From equation (2a)}\right] \\\\ & = -e^{-x/2} - \dfrac{e^{-x/2}}{17} \left[\cos \left(2x\right) - 4 \sin \left(2x\right)\right] + c \end{aligned}$