From the given #int (1/(1+cot x)) dx#
If an integrand is a rational function of the trigonometric functions, the substitution #z=tan (x/2)#, or its equivalent
#sin x=(2z)/(1+z^2)# and #cos x=(1-z^2)/(1+z^2)# and
#dx=(2dz)/(1+z^2)#
The solution:
#int (1/(1+cot x)) dx#
#int (1/(1+cos x/sin x)) dx#
#int (sin x/(sin x+cos x)) dx#
#int ((2z)/(1+z^2))/(((2z)/(1+z^2)+(1-z^2)/(1+z^2))) *((2dz)/(1+z^2))#
Simplify
#int ((2z)/(1+z^2))/(((2z)/(1+z^2)+(1-z^2)/(1+z^2))) *((2dz)/(1+z^2))#
#int (4z)/((-z^2+2z+1)(z^2+1))*dz#
#int (-4z)/((z^2+1)(z^2-2z-1))*dz#
At this point, use Partial Fractions then integrate
#int (-4z)/((z^2+1)(z^2-2z-1))*dz=int ((Az+B)/(z^2+1)+(Cz+D)/(z^2-2z-1))dz#
We do the Partial Fractions first
#(-4z)/((z^2+1)(z^2-2z-1))= (Az+B)/(z^2+1)+(Cz+D)/(z^2-2z-1)#
#(-4z)/((z^2+1)(z^2-2z-1))= ((Az+B)(z^2-2z-1)+(Cz+D)(z^2+1))/((z^2+1)(z^2-2z-1))#
Expand the right side of the equation
#(-4z)/((z^2+1)(z^2-2z-1))= #
#(Az^3-2Az^2-Az+Bz^2-2Bz-B+Cz^3+Dz^2+Cz+D)/((z^2+1)(z^2-2z-1))#
Set up the equations
#(0*z^3+0*z^2-4*z+0*z^0)/((z^2+1)(z^2-2z-1))=#
#((A+C)*z^3+(-2A+B+D)*z^2+(-A-2B+C)*z+(-B+D)*z^0)/((z^2+1)(z^2-2z-1))#
The equations are
#A+C=0#
#-2A+B+D=0#
#-A-2B+C=-4#
#-B+D=0#
Simultaneous solution results to
#A=1# and #B=1# and #C=-1# and #D=1#
We can now do the integration
#int (-4z)/((z^2+1)(z^2-2z-1))*dz=int ((Az+B)/(z^2+1)+(Cz+D)/(z^2-2z-1))dz=int ((z+1)/(z^2+1)+(-z+1)/(z^2-2z-1))dz=#
#1/2 int (2z)/(z^2+1) dz+int dz/(z^2+1)-1/2int (2z-2)/(z^2-2z-1)dz#
#=1/2*ln (z^2+1)+tan^-1 z-1/2*ln(z^2-2z-1)#
#=1/2*ln((z^2+1)/(z^2-2z-1))+tan^-1 z#
We will return it to its original variable #x# using #z=tan (x/2)# for the final answer.
#color(blue)(int (1/(1+cot x)) dx=)#
#color(blue)(1/2*ln((tan^2 (x/2)+1)/(tan^2 (x/2)-2*tan (x/2)-1))+x/2+K)#
where #K=# constant of integration
God bless...I hope the explanation is useful.