<s>[INST] Is there another simple way to solve this integral $I=\int\frac{\sin{x}}{\sin{x}+\cos{x}}dx$? The integral I want to find is$$I=\int\frac{\sin{x}}{\sin{x}+\cos{x}}dx$$
The way I learnt is to introduce$$J=\int\frac{\cos{x}}{\sin{x}+\cos{x}}dx$$
Then $J+I=x+C_1$ and $J-I=\ln|\sin{x}+\cos{x}|+C_2$.
Is there some simple way to solve this integral $I$? For example, do not introduce other integrals?
Any hints will be appreciated. Thank you.
 [/INST] As the given
$$I=\int \frac{sinx}{sinx+cosx}dx$$
$$= \int \frac{tanx}{tanx+1}dx$$
Put $ tanx=t \implies sec^2x.dx=dt$
$\implies (1+tan^2x)dx=dt \implies dx=\frac{dt}{1+t^2}$
So we have
$$I=\int\frac{t}{t+1}.\frac{dt}{1+t^2} \to (1)$$
Now by using partial fraction
$$\frac{t}{(1+t)(1+t^2)}=\frac{A}{1+t}+\frac{Bt+C}{1+t^2} \to (2) $$
$$t=A(1+t^2)+(Bt+C)(1+t) \to(3)$$
Put $1+t=0 \implies t=-1$ in above eq
$$-1=A(1+1)+0 \implies A=\frac{-1}{2}$$
Now from eq $(3)$
$$t=A+At^2+Bt+Bt^2+C+Ct$$
Comparing coefficients of $t^2$ and $t$.
Coefficient of $t^2$
$$0=A+B \implies B=-A$$
$$B=\frac{1}{2}$$
Coefficient of $t$
$$1=B+C \implies C=1-B $$
$$C=1-\frac{1}{2} \implies C=\frac{1}{2} $$
Putting these values in eq $(2)$
$$\frac{t}{(1+t)(1+t^2)} = \frac{\frac{-1}{2}}{1+t} + \frac{\frac{1}{2}t+\frac{1}{2}}{1+t^2}$$
Putting this value in eq $(1)$
$$I=\int (\frac{\frac{-1}{2}}{1+t} + \frac{\frac{1}{2}t+\frac{1}{2}}{1+t^2})dt $$
$$I= \frac{1}{2} \int \frac{-1}{1+t}dt + \frac{1}{2} \int \frac{t+1}{t^2+1}dt $$
$$I= - \frac{1}{2} \ln (1+t) + \frac{1}{4}\int \frac{2t}{t^2+1}dt + \frac{1}{2} \int \frac{1}{t^2+1}dt$$
$$I= - \frac{1}{2} \ln (1+t) + \frac{1}{4} \ln (t^2+1) + \frac{1}{2} \arctan(t)+C $$
As $t=tanx$. So we have
$$I= - \frac{1}{2} \ln (1+tanx) + \frac{1}{4} \ln (tan^2x+1) + \frac{1}{2} \arctan(tanx)+C $$
$$I= - \frac{1}{2} \ln (1+tanx) + \frac{1}{4} \ln (tan^2x+1) + \frac{1}{2} x +C$$
$$=-\frac{1}{2}\ln(1+tanx)-\frac{1}{2}\ln(cosx)+\frac{1}{2}x+C$$
$$=\frac{1}{2}x-\frac{1}{2}\ln(sinx+cosx)+C$$
</s>