<s>[INST] 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$$
 [/INST] $$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$$

</s>