# Integral of a weird trigonometric function

I'm been trying to figure this out for hours, but no success. Can anyone take a look at it? Thanks a lot!

$$\int\frac{1}{\sin2x + \cos2x}dx\qquad\text{Hint: start by evaluating }\int\frac{1}{\sin x + \cos x}dx$$

-

HINT: $$\sin x+\cos x=\sqrt2\left(\sin x\cos\frac{\pi}4+\cos x\sin\frac{\pi}4\right)=\sqrt2\sin\left(x+\frac{\pi}4\right)$$

-
how did you get this identity? – user42624 Feb 17 '13 at 5:02
@user42624: It’s just the formula for the sine of the sum of two angles, plus the fact that $\sin\frac{\pi}4=\cos\frac{\pi}4=\frac1{\sqrt2}$: $\sin(x+y)=\sin x\cos y+\cos x\sin y$. – Brian M. Scott Feb 17 '13 at 5:03
@Brain M.Scott Hi, I solved the integral, it gives 1/(2*sqrt(2))ln|csc(2*x+pi/4)-cot(2*x+pi/4)|. Wolfram Alpha gives an another integral, so to check if they are equal, I plugged x=3 in both equations and see if they both give the same answer.. but it didn't, do you know why? – user42624 Feb 17 '13 at 8:06
@user42624: You have a pair of sign errors in your integral: it should be $$-\frac1{2\sqrt2}\ln\left|\csc\left(2x+\frac{\pi}4\right)+\cot\left(2x+ \frac{\pi}4\right)\right|\;.$$ – Brian M. Scott Feb 17 '13 at 10:56

We could multiply top and bottom by $\cos x+\sin x$. Note that by the Pythagorean Identity, we have
$$(\cos x+\sin x)^2=2-(\sin x-\cos x)^2.$$ Thus $$\int \frac{dx}{\cos x+\sin x}=\int \frac{(\cos x +\sin x) \,dx}{(\cos x+\sin x)^2}= \int \frac{(\cos x +\sin x) \,dx}{2-(\sin x-\cos x)^2}.$$ Finally, let $u=\sin x-\cos x$. Since $du=(\cos x+\sin x)\,dx$, our integral is $$\int \frac{du}{2-u^2},$$ a routine integral that can be handled by partial fractions, and in various other ways.

-