# An integral that needs subtitution to be solved.

I have this excercise. The hint is that it's solved by the substitution method, but I'm not able to find the right one, or even get close to something.

$$\int\frac{\sec(x)}{\sin(x)+\cos(x)}dx$$

Using identities, I have arrived to things like this:

$$-\int\frac{\tan(x)-1}{\cos(2x)}dx$$

But, well, the thing above doesn't help too much. I'd appreciate any help on this subject.

• There are already a lot of good answers, but how does one know how to recale the fraction? A useful rule of thumb: if a trigonometric integrand has period $2\pi/n$, substitute $t=\tan\frac{nx}{2}$. In this case $n=2$, so $\sec xdx=\cos xdt$. The rest writes itself.
– J.G.
Jul 7, 2019 at 19:07
• @J.G. Yep, that's the "universal trigonometric substitution": given $\int F(\sin x, \cos x) dx$, substitute $t=\tan\frac x2$. Although it's for some reason usually called "Weierstrass substitution" in English, IIRC? Jul 8, 2019 at 8:01
• @Joker_vD That's the one. As I say, though, the optimal form of the substitution depends on the integrand period.
– J.G.
Jul 8, 2019 at 8:43

Here's a solution using a substitution.

In particular, observe that $$\frac{\sec x}{\sin x+\cos x}\cdot\frac{\sec x}{\sec x}=\frac{\sec^2 x}{\tan x+1}.$$ This is useful because $$\frac{d}{dx}\tan x=\sec^2x$$, so substituting $$u=\tan x$$ tells us that $$\int\frac{\sec x}{\sin x+\cos x}dx=\int\frac{1}{u+1}du=\ln(|u+1|)=\ln(|\tan x+1|).$$

Since $$\tan x=\frac{\sin x}{\cos x}$$, we find that this is simply equal to $$\ln\left(\frac{\sin x+\cos x}{\cos x}\right)=\ln\left(|\sin x+\cos x|\right)-\ln\left(|\cos x|\right).$$

• (+1) Nice! Your approach is better than mine. Jul 7, 2019 at 19:28
• Is this missing some absolute value operators? $u+1 = \tan x + 1$ can be negative. Jul 8, 2019 at 4:19
• Thanks—I’ve fixed it! Jul 8, 2019 at 13:48

I hope that you don't mind if I don't use a substitution. Note that\begin{align}\int\frac{\sec(x)}{\sin(x)+\cos(x)}\,\mathrm dx&=\int\frac1{\sin(x)\cos(x)+\cos^2(x)}\,\mathrm dx\\&=\int\frac{\cos(x)-\sin(x)}{\cos(x)+\sin(x)}+\frac{\sin(x)}{\cos(x)}\,\mathrm dx\\&=\log\bigl(\lvert\cos(x)+\sin(x)\rvert\bigr)-\log\bigl(\lvert\cos(x)\rvert\bigr).\end{align}

You can observe that $$\frac{\sec x}{\sin x+\cos x}=\frac{1}{\cos x(\sin x+\cos x)}= \frac{\sin^2x+\cos^2x}{\cos x(\sin x+\cos x)}= \frac{\tan^2x+1}{\tan x+1}$$ A rational function in the tangent can be integrated via $$u=\tan x$$ so $$du=(1+\tan^2x)\,dx$$ or $$dx=\frac{1}{u^2+1}\,du$$ and the integral is now elementary.