Is there an elegant way to solve $\int \frac{(\sin^2(x)\cdot \cos(x))}{\sin(x)+\cos(x)}dx$? The integral is:
$$\int \frac{(\sin^2(x)\cdot \cos(x))}{\sin(x)+\cos(x)}dx$$
I used weierstraß substitution 
$$t:=\tan(\frac{x}{2})$$
$$\sin(x)=\frac{2t}{1+t^2}$$
$$\cos(x)=\frac{1-t^2}{1+t^2}$$
$$dx=\frac{2}{1+t^2}dt$$
Got this:
$$\int \frac{8t^4-8t^2}{t^8−2t^7+2t^6−6t^5−6t^3−2t^2−2t−1}dt$$
and with partial fraction expansion the final answer is:
$$\frac{1}{4}[\ln(\sin(x)+\cos(x))-\cos(x)*(\sin(x)+\cos(x))]+C$$
It is a long way and I am very convinced, there is a shorter way, maybe you know one? Thanks
 A: \begin{align}
\int\frac{\sin^2 x\cos x}{\sin x+\cos x}\,\mathrm dx
&=
\int\frac{\sin^2 x\sin\left(\frac\pi2-x\right)}{\sin x+\sin\left(\frac\pi2-x\right)}\,\mathrm dx
\\
&=
\int\frac{\sin^2\left(\frac\pi4+u\right)\sin\left(\frac\pi4-u\right)}{\sin \left(\frac\pi4+u\right)+\sin\left(\frac\pi4-u\right)}\,\mathrm d\left(\frac\pi4+u\right)
\\
&=
\int\frac{\left(\sin\frac\pi4\cos u+\cos\frac\pi4\sin u\right)^2\left(\sin\frac\pi4\cos u-\cos\frac\pi4\sin u\right)}{\left(\sin\frac\pi4\cos u+\cos\frac\pi4\sin u\right)+\left(\sin\frac\pi4\cos u-\cos\frac\pi4\sin u\right)}\,\mathrm d\left(\frac\pi4+u\right)
\\
&=
\frac14\int\frac{\left(\cos u+\sin u\right)^2\left(\cos u-\sin u\right)}{\cos u}\,\mathrm d\left(\frac\pi4+u\right)
\\
&=
\frac14\int\frac{\left(\cos u+\sin u\right)\left(\cos^2 u-\sin^2 u\right)}{\cos u}\,\mathrm d\left(\frac\pi4+u\right)
\\
&=
\frac14\int\left(\cos2u+\sin2u-\tan u\right)\,\mathrm d\left(\frac\pi4+u\right)
\\
&=
\frac14\left(\frac12\sin\left(2x-\frac\pi2\right)-\frac12\cos\left(2x-\frac\pi2\right)+\log\cos\left(x-\frac\pi4\right)\right)+\textsf{const.}
\\
&=
\frac14\left(\log\cos\left(x-\frac\pi4\right)-\frac12\left(\sin2x+\cos2x\right)\right)+\textsf{const.}
\\
&=
\frac14\left(\log\cos\left(x-\frac\pi4\right)-\frac1{\sqrt2}\cos\left(2x-\frac\pi4\right)\right)+\textsf{const.}
\end{align}
A: $\sin(x)+\cos(x)=\sqrt2\cos\left(x-\frac\pi4\right)$. Let $u=x-\frac\pi4$, then
$$
\begin{align}
\frac{\sin^2(x)\cos(x)}{\sin(x)+\cos(x)}
&=\frac{(\cos(u)+\sin(u))^2}2\frac{\cos(u)-\sin(u)}{\sqrt2}\frac1{\sqrt2\cos(u)}\\
&=\frac{\cos(u)-\sin(u)+2\sin(u)\cos^2(u)-2\sin^2(u)\cos(u)}{4\cos(u)}\\
&=\frac14\left(1-\frac{\sin(u)}{\cos(u)}+2\sin(u)\cos(u)-2\sin^2(u)\right)\\
&=\frac14\left(\sin(2u)+\cos(2u)-\frac{\sin(u)}{\cos(u)}\right)
\end{align}
$$
Integrating gives
$$
\begin{align}
\int\frac{\sin^2(x)\cos(x)}{\sin(x)+\cos(x)}\mathrm{d}x+C
&=-\frac18\cos(2u)+\frac18\sin(2u)+\frac14\log(\cos(u))+C\\
&=-\frac18\cos\left(2x-\frac\pi2\right)+\frac18\sin\left(2x-\frac\pi2\right)+\frac14\log\left(\cos\left(x-\frac\pi4\right)\right)+C\\
&=-\frac18\sin(2x)-\frac18\cos(2x)+\frac14\log(\cos(x)+\sin(x))+C-\frac{\log(2)}8
\end{align}
$$
A: If you multiply numerator and denominator by $\cos x-\sin x$, the numerator can be rewritten as
$$
\sin x\cos x(\sin x\cos x-\sin^2x)
$$
Now use $\sin x\cos x=\frac{1}{2}\sin 2x$ and
$$
\sin^2x=\frac{1-\cos2x}{2}
$$
so finally we get
$$
\frac{1}{4}\sin2x(\sin2x-1+\cos2x)=
\frac{1}{4}(1-\cos^22x-\sin2x+\sin2x\cos2x)
$$
and the integral becomes
$$
\frac{1}{4}\int\left(
  \frac{1}{\cos2x}-\frac{\sin2x}{\cos2x}-\cos2x+\sin2x
\right)\,dx
$$
that should pose little problems.
