$\int_{0}^{\frac{\pi}{4}} e^{\sec x} \frac{\sin( x + \frac{\pi}{4})}{(1 - \sin x) \cos x}\, dx$? How do I find the value of
$$
  \int_{0}^{\frac{\pi}{4}} e^{\sec x} \dfrac{\sin\Big( x + \dfrac{\pi}{4}\Big)}{(1 - \sin x) \cos x} \;\mathrm{d}x
$$
 A: First of all, note that
$$\frac{d}{dx}(e^{g(x)}f(x)) = e^{g(x)} \{g'(x)f(x) + f'(x)\}$$
Consequently,
$$\int e^{g(x)} \{g'(x)f(x) + f'(x)\} dx = e^{g(x)}f(x) $$
Our aim is to reduce the given integral to the above form.
We already have $g(x) = \sec(x)$
Let
$$I = \int_{0}^{\frac{\pi}{4}} e^{\sec x} {\frac{\sin (x+\frac{\pi}{4})}{(1-\sin x)(\cos x)}} dx$$
Expanding $\sin (x+\frac{\pi}{4})$,
$$I = \frac{1}{\sqrt2}\int_{0}^{\frac{\pi}{4}} e^{\sec x} {\frac{\sin x+\cos x}{(1-\sin x)(\cos x)}} dx$$
Dividing Numerator and denominator by $\cos^2 x$ we have
$$I = \frac{1}{\sqrt2}\int_{0}^{\frac{\pi}{4}} e^{\sec x} {\frac{\tan x\sec x+\sec x}{(\sec x-\tan x)}}dx$$
$$\Rightarrow I = \frac{1}{\sqrt2}\int_{0}^{\frac{\pi}{4}} e^{\sec x} \Big \{{\frac{\tan x\sec x}{(\sec x-\tan x)}} + \frac{\sec x}{(\sec x-\tan x)}\Big\}dx$$
$$\Rightarrow I = \frac{1}{\sqrt2}\int_{0}^{\frac{\pi}{4}} e^{\sec x} \Big \{\tan x\sec x\Big({\frac{1}{(\sec x-\tan x)}\Big)} + \frac{\sec x(\sec x-\tan x)}{(\sec x-\tan x)^2}\Big\}dx$$
Comparing with the form above,
$$f(x) = \frac{1}{(\sec x-\tan x)}$$
Thus,
$$I = \frac{1}{\sqrt2}\frac{e^{\sec x}}{(\sec x-\tan x)}\Big|_0^\frac{\pi}{4}$$
Putting the limits, we have
$$ I = \frac{1}{\sqrt2}\Big( \frac{e^{\sqrt2}}{\sqrt2 - 1} - e\Big)$$
$$ \Rightarrow I = \frac{(1+\sqrt2)e^{\sqrt2} - e}{\sqrt2}$$
