Calculate the antiderivative of a given function Consider the function $f : \left[ 0, \frac{\pi}{4} \right)$, $f(x) = \frac{(\cos x + \sin x)^n}{(\cos x - \sin x)^{n + 2}}$, where $n \in \mathbb{N}^*$. Find the antiderivative $F$ of $f$ such that $F(0) = \frac{1}{2(n + 1)}$.
I've noticed that $(\cos x - \sin x)' = -(\cos x + \sin x)$, but I can't figure out how to use this in finding $F$.
Thank you!
 A: Noting
$$ \cos x+\sin x=\sqrt2\sin(x+\frac{\pi}{4}),\cos x-\sin x=\sqrt2\cos(x+\frac{\pi}{4}) $$
one has
\begin{eqnarray}
F(x)&=&\int \frac{(\cos x + \sin x)^n}{(\cos x - \sin x)^{n + 2}} dx\\
&=&\int \frac{(\sqrt2\sin(x+\frac{\pi}{4}))^n}{(\sqrt2\cos(x+\frac{\pi}{4}))^{n + 2}} dx\\
&=&\int \tan^n(x+\frac{\pi}{4})\frac{1}{2\cos^2(x+\frac{\pi}{4})} dx\\
&=&\frac12\int \tan^n(x+\frac{\pi}{4})\sec^2(x+\frac{\pi}{4}) dx\\
&=&\frac12\int \tan^n(x+\frac{\pi}{4})d\tan(x+\frac{\pi}{4})\\
&=&\frac1{2(n+1)}\tan^{n+1}(x+\frac{\pi}{4})+C.
\end{eqnarray}
Using $F(0)=\frac{1}{2(n+1)}$, it is easy to see $C=0$.
A: We're trying to integrate
$$ \int f(x) dx = \int \frac{(\cos x + \sin x)^n}{(\cos x - \sin x)^{n + 2}} dx,$$
Divide numerator and denominator by $\cos^{n+2}(x)$:
$$ \int \frac{1}{\cos^2(x)}\frac{(1 + \tan x)^n}{(1 - \tan x)^{n + 2}} dx,$$
Now substitute $t = \tan(x)$; $dt = \frac{1}{\cos^2(x)}dx$:
\begin{align} \int \frac{(1 + t)^n}{(1 - t)^{n + 2}} dt &= \frac{1}{2}\int \frac{(1 + t)^n(1-t+1+t)}{(1 - t)^{n + 2}}\\
& = \frac{1}{2}\int \frac{(1 + t)^n(1-t)^n((1-t)+(1+t))}{(1 - t)^{2n + 2}}dt\\
& = \frac{1}{2}\int \frac{(1-t)^{n+1}(1 + t)^n+(1+t)^{n+1}(1 - t)^n}{(1 - t)^{2n + 2}}dt\\
& = \frac{1}{2(n+1)}\int \frac{d}{dt}\left(\frac{1+t}{1-t}\right)^{n+1}dt\\
& = \frac{1}{2(n+1)}\left(\frac{1+t}{1-t}\right)^{n+1} + c\\
& = \frac{1}{2(n+1)}\left(\frac{1+\tan(x)}{1-\tan(x)}\right)^{n+1} + c
\end{align}
Since $\tan(0) = 0$, you'll want $c = 0$.
