Integrate the expression $\int\frac{x}{1+\sin x}\ \text dx$ 
Integrate the expression $\int\frac{x}{1+\sin x}\ \text dx$

I really do not see any identity working here. I tried rewriting in terms of $\cos x$ and got $$\int\frac{\frac{x}{\cos x}}{\frac{1}{\cos x}+\frac{\sin x}{\cos x}}\ \text dx$$
 A: $$
\begin{align}
\int\frac1{1+\sin(x)}\,\mathrm{d}x
&=\int\frac{1-\sin(x)}{\cos^2(x)}\,\mathrm{d}x\\[6pt]
&=\tan(x)-\sec(x)+C
\end{align}
$$
Therefore, we can integrate by parts
$$
\begin{align}
\int\frac{x}{1+\sin(x)}\,\mathrm{d}x
&=\int x\,\mathrm{d}(\tan(x)-\sec(x))\\
&=x(\tan(x)-\sec(x))-\int(\tan(x)-\sec(x))\,\mathrm{d}x\\[6pt]
&=x(\tan(x)-\sec(x))+\log(\cos(x))+\log(\sec(x)+\tan(x))+C\\[12pt]
&=x(\tan(x)-\sec(x))+\log(1+\sin(x))+C\\[6pt]
&=-\frac{x\cos(x)}{1+\sin(x)}+\log(1+\sin(x))+C
\end{align}
$$
A: \begin{align}
I&=\int\frac{xdx}{1+\sin x}=\int x d\left(\frac{-\cos x}{1+\sin x}\right)=\frac{-x\cos x}{1+\sin x}+\int \frac{\cos x}{1+\sin x}dx\\
&=\frac{-x\cos x}{1+\sin x}+\ln |1+\sin x|+C
\end{align}
A: $$I = \int\frac{x}{1+\sin x}\, dx$$
Multiply by the conjugate of $1 + \sin x$
$$\int\frac{x}{1+\sin x}\cdot \frac{1-\sin x}{1-\sin x}\, dx = $$
$$\int\frac{x}{1+\sin x}\cdot \frac{1-\sin x}{1-\sin x}\, dx =  \int\frac{x-x\sin x}{1-\sin^2 x}\, dx$$
$$\int\frac{x-x\sin x}{\cos^2 x}\, dx$$
$$\int\frac{x}{\cos^2 x}\, dx- \int\frac{x\sin x}{\cos^2 x}\, dx$$
Apply Integration by Parts $$\int f(x)g(x)'\,dx = f(x)g(x) - \int f'(x)g(x)\, dx$$
where 
$$\int\frac{x}{\cos^2 x}\, dx$$
$f(x) = x,\implies f'(x) = 1$
$g(x) = \tan x \implies g'(x) = \frac{1}{\cos^2x}$ 
$$x\tan(x) - \int\tan(x)$$
$$x\tan(x) + \ln(\cos x) +C\tag1$$

And
$$\int\frac{x\sin x}{\cos^2 x}\, dx$$
$f(x) = x\sin x,\implies f'(x) = \sin x + x\cos x$
$g(x) = \tan x \implies g'(x) = \frac{1}{\cos^2x}\tan x$ 
$$x\sin x \tan x - \int(\sin x + x\cos x)\tan x\, dx$$
$$x\sin x \tan x - \int \sin x\tan x + x\cos x\tan x\, dx$$
$$x\sin x \tan x - \int x\sin x + \sin x\tan x\, dx$$
$$x\sin x \tan x - \left(\int x\sin x \, dx + \int \sin x\tan x\, dx\right)$$
$$x\sin x \tan x - \left(-x\cos x + \sin x + \int \sin x\tan x\, dx\right)$$

$\int\sin x\tan x\, dx = \int \frac{\sin^2 x}{\cos x}\, dx = \int \frac{1 - \cos^2 x}{\cos x}\, dx = \int \frac{1}{\cos x} - \cos x \, dx = \int \frac{1}{\cos x}\, dx - \int \cos x \, dx =$

$ \ln\left(\tan(x) + \sec(x)\right) - \sin(x) +C$

$$x\sin x \tan x - \left( -x\cos x + \sin x + \ln\left(\tan(x) + \sec(x)\right) - \sin(x)\right) + C$$
$$x\sin x \tan x + x\cos x - \ln\left(\tan(x) + \sec(x)\right) + C\tag2$$

Also...


$$I = \big(x\tan(x) + \ln(\cos x)\big) + \big(x\sin x \tan x + x\cos x - \ln\left(\tan(x) + \sec(x)\right)\big) + C$$

