How do you find the integral of ##int 1/(1 + cot(x))##?

##-1/2(ln(abs(sin(x)+cos(x)))-x)+C##

Another method is to write this using all tangents:

##I=int1/(1+cot(x))dx=inttan(x)/(tan(x)(1+cot(x)))=inttan(x)/(tan(x)+1)dx##

Now, since all we have are tangents, we need a ##sec^2(x)## in order to substitute. We can multiply the fraction by ##sec^2(x)## in the numerator, but express it as ##tan^2(x)+1## in the denominator (they’re equal through the Pythagorean identity).

##I=int(tan(x)sec^2(x))/((tan(x)+1)(tan^2(x)+1))dx##

Letting ##u=tan(x)## so that ##du=sec^2(x)dx##, we see that:

##I=intu/((u+1)(u^2+1))du##

Now, we have to perform partial fraction decomposition:

##u/((u+1)(u^2+1))=A/(u+1)+(Bu+C)/(u^2+1)##

Multiplying through:

##u=A(u^2+1)+(Bu+C)(u+1)##

##u=Au^2+A+Bu^2+Bu+Cu+C##

Factor in three groups: those with ##u^2##, those with ##u##, and constants.

##u=u^2(A+B)+u(B+C)+(A+C)##

##color(purple)0u^2+color(red)1u+color(brown)0=u^2color(purple)((A+B))+ucolor(red)((B+C))+color(brown)((A+C))##

Comparing the two sides, we see that:

##{(A+B=0),(B+C=1),(A+C=0):}##

Subtracting the second equation from the third, we see that ##A-B=-1##. Adding this to the first equation shows that ##2A=-1## and ##A=-1/2##. It then follows that:

##{(A=-1/2),(B=1/2),(C=1/2):}##

So:

##u/((u+1)(u^2+1))=1/2(1/(u+1))+1/2((u+1)/(u^2+1))##

Returning to the integral now:

##I=-1/2int1/(u+1)du+1/2int(u+1)/(u^2+1)du##

##I=-1/2int1/(u+1)du+1/2intu/(u^2+1)du+1/2int1/(u^2+1)du##

Modifying the second integral slightly:

##I=-1/2int1/(u+1)du+1/4int(2u)/(u^2+1)du+1/2int1/(u^2+1)du##

Now all three integrals can be integrated rather painlessly:

##I=-1/2ln(abs(u+1))+1/4ln(abs(u^2+1))+1/2arctan(u)##

##I=-1/2ln(abs(tan(x)+1))+1/4ln(tan^2(x)+1)+1/2arctan(tan(x))##

##color(blue)(I=-1/2ln(abs(tan(x)+1))+1/4ln(sec^2(x))+1/2x##

This is a fine final answer, once the constant of integration is added, but we can fiddle around a little more to achieve some fun simplification.

##I=-1/2ln(abs((sin(x)+cos(x))/cos(x)))+1/2(1/2ln(sec^2(x)))+1/2x##

Rather sneakily, bring one of the ##1/2##s outside the ##ln(sec^2(x))## in, effectively using the ##log(a^b)=blog(a)## rule in reverse. (Absolute value bars will be added since we’ve just taken the square root:)

##I=-1/2ln(abs((sin(x)+cos(x))/cos(x)))+1/2ln(abs(sec(x)))+1/2x##

Now we can bring a ##-1## in as a ##-1## power to make ##sec(x)## into ##cos(x)##:

##I=-1/2ln(abs((sin(x)+cos(x))/cos(x)))-1/2ln(abs(cos(x)))+1/2x##

Factor ##-1/2## and use the rule that ##log(A)+log(B)=log(AB)##:

##I=-1/2(ln(abs((sin(x)+cos(x))/cos(x)))+ln(abs(cos(x)))-x)##

##color(green)(I=-1/2(ln(abs(sin(x)+cos(x)))-x)+C##