TITLE: Evaluate integral with trigonometric functions in denominator
QUESTION [6 upvotes]: $$ \int \frac {1}{\sin x + \cos x} dx$$
How would I go about solving this?

REPLY [4 votes]: The easiest way is to proceed as @AymanHourieh has suggested. Another approach is using Weierstrass substitution. Let $t = \tan(x/2)$. Note that
$$\sin(x) = \dfrac{2 \tan(x/2)}{1+\tan^2(x/2)} = \dfrac{2t}{1+t^2}; \,\,\,\,\, \cos(x) = \dfrac{1-\tan^2(x/2)}{1+\tan^2(x/2)} = \dfrac{1-t^2}{1+t^2}$$
$$dt = \dfrac{\sec^2(x/2) dx}2 \implies dx = \dfrac{2dt}{1+t^2}$$
Hence,
$$I = \int \dfrac{dx}{\sin(x) + \cos(x)} = \int \dfrac{2dt}{1-t^2 + 2t} = \int\dfrac{2dt}{2-(t-1)^2}$$
Now use partial fractions to write $\dfrac{2}{2-(t-1)^2}$ as
$$\dfrac2{2-(t-1)^2} = \dfrac1{\sqrt{2}(t+\sqrt{2}-1)} - \dfrac1{\sqrt{2}(t-\sqrt{2}-1)}$$
Now integrate this out by, recalling that
$$\int \dfrac{dt}{t+c} = \log(\vert t+c \vert) + \text{ constant}$$