Integrating $\int \frac{\cos x}{\sin x+\cos x}dx$. so I've just had my first exam (went pretty well) but I ran into this thing as the first part of the last question.
$$\int \frac{\cos x}{\sin x+\cos x}dx$$
I had a look on wolfram after the exam and it advised to multiply top and bottom by $\sec^3x$. 
Is there another way to tackle this if you didn't know that trick? I find it hard to believe I was meant to know this and it was disproportionately harder than any type of integration question I've come across when practicing.
I couldn't get anywhere when trying to solve this.
Thanks.
 A: Note that $\cos x = \frac{1}{2} ( 2 \cos x + \sin x - \sin x)$.
So then
$$ \int \frac{\cos x}{\sin x + \cos x} dx = \frac{1}{2} \int \frac{\cos x - \sin x}{\cos x + \sin x}dx + \frac{1}{2}\int \frac{\cos x + \sin x}{\cos x + \sin x} dx.$$
The second is easy to integrate, and the first is now just a $u$-substituteion as the numerator is the derivative of the denominator.
A: Hint: $\sin(x)+\cos(x)=\sqrt{2}\sin(x+\pi/4)$ Then substitute $u=x+\pi/4$.
A more general approach would be the following. Replace $\cos(x)$ and $\sin(x)$ by Euler's formula.
$$\int \frac{f(\cos(x),\sin(x))}{g(\cos(x),\sin(x))}dx=\int \frac{f(\exp(ix),\exp(-ix))}{g(\exp(ix),\exp(-ix))}dx.$$
Now, substitute $u=\exp(ix) \implies du=iudx$.
$$\int \frac{f(u,u^{-1})}{g(u,u^{-1})}\frac{du}{iu}=\int \frac{f(u)}{g(u)}\frac{du}{iu}.$$
If $f$ and $g$ are simple polynomials the resulting integral can always be solved by partial fractions.
A: Method 1:-$$\frac{cosx}{cosx+sinx}=\frac{cos(x-π/4 +π/4)}{\sqrt {2}cos(x-π/4)}=\frac{cos(x-π/4)-sin(x-π/4)}{2cos(x-π/4)}$$
Method 2:- Write the numerator
$cosx=A(cosx+sinx)+B\frac{d}{dx}(cosx+sinx)$
to find $A$ and $B$ then the answer will be $Ax+Blog|cosx+sinx|+c$
A: HINT:
For $I=\displaystyle\int\dfrac{a\cos x+b\sin x}{c\cos x+d\sin x}dx,$
write $a\cos x+b\sin x=A(c\cos x+d\sin x)+B\cdot\dfrac{d(c\cos x+d\sin x)}{dx}$  where $A,B$ are arbitrary constants so that
$I=\displaystyle A\int\ dx+B\int\dfrac{d(c\cos x+d\sin x)}{c\cos x+d\sin x}$
Compare the coefficients of $\cos x,\sin x$ to find $A,B$
A: Dividing numerator and denominator by $\cos x$ yields
$$\frac{dx}{\tan x+1}$$
Now substitute $x=\tan^{-1}t,dx=\dfrac{dt}{1+t^2}$ to get
$$\int\frac{dt}{(t+1)(t^2+1)}$$
which can now be solved with partial fractions.  Similar to the other method but hopefully easier to see.
