lst:=[
# ::Package:: 

# ::Title:: 
#Integration Problems Involving Cotangents


# ::Subsection::Closed:: 
#Cot[a+b x]^n


# Integrands of the form Cot[a+b*x]^n where n is a positive integer 
[cot(a + b*x), x, 1, log(sin(a + b*x))/b],
[cot(a + b*x)^2, x, 1, -x - cot(a + b*x)/b],
[cot(a + b*x)^3, x, 2, -(cot(a + b*x)^2/(2*b)) - log(sin(a + b*x))/b],
[cot(a + b*x)^4, x, 2, x + cot(a + b*x)/b - cot(a + b*x)^3/(3*b)],
[cot(a + b*x)^5, x, 3, cot(a + b*x)^2/(2*b) - cot(a + b*x)^4/(4*b) + log(sin(a + b*x))/b],


# Integrands of the form Cot[a+b*x]^n where n is a half-integer 
[cot(a + b*x)^(1/2), x, 7, arctan(1 - sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b) - arctan(1 + sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b) - log(1 - sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b) + log(1 + sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b)],
[cot(a + b*x)^(3/2), x, 8, -(arctan(1 - sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b)) + arctan(1 + sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b) - (2*sqrt(cot(a + b*x)))/b - log(1 - sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b) + log(1 + sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b)],
[cot(a + b*x)^(5/2), x, 8, -(arctan(1 - sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b)) + arctan(1 + sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b) - (2*cot(a + b*x)^(3/2))/(3*b) + log(1 - sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b) - log(1 + sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b)],

[1/cot(a + b*x)^(1/2), x, 7, arctan(1 - sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b) - arctan(1 + sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b) + log(1 - sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b) - log(1 + sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b)],
[1/cot(a + b*x)^(3/2), x, 8, -(arctan(1 - sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b)) + arctan(1 + sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b) + 2/(b*sqrt(cot(a + b*x))) + log(1 - sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b) - log(1 + sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b)],
[1/cot(a + b*x)^(5/2), x, 8, -(arctan(1 - sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b)) + arctan(1 + sqrt(2)*sqrt(cot(a + b*x)))/(sqrt(2)*b) + 2/(3*b*cot(a + b*x)^(3/2)) - log(1 - sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b) + log(1 + sqrt(2)*sqrt(cot(a + b*x)) + cot(a + b*x))/(2*sqrt(2)*b)],

[cot(8*x)^(1/3), x, 7, (1/16)*sqrt(3)*arctan((1 - 2*cot(8*x)^(2/3))/sqrt(3)) + (1/16)*log(1 + cot(8*x)^(2/3)) - (1/32)*log(1 - cot(8*x)^(2/3) + cot(8*x)^(4/3))],


# ::Subsection::Closed:: 
#x^m Cot[a+b x]^n


# Integrands of the form x^m*Tan[a+b*x]^n where m and n are integers 
[x*cot(a + b*x), x, 4, -((I*x^2)/2) + (x*log(1 - exp(2*I*a + 2*I*b*x)))/b - (I*polylog(2, exp(2*I*a + 2*I*b*x)))/(2*b^2)],
[x*cot(a + b*x)^2, x, 3, -x^2/2 - (x*cot(a + b*x))/b + log(sin(a + b*x))/b^2],
[x*cot(a + b*x)^3, x, 6, (I*x^2)/2 - cot(a + b*x)/(2*b^2) - (x*csc(a + b*x)^2)/(2*b) - (x*log(1 - exp(2*I*a + 2*I*b*x)))/b + (I*polylog(2, exp(2*I*a + 2*I*b*x)))/(2*b^2)],

[x^2*cot(a + b*x), x, 5, -((I*x^3)/3) + (x^2*log(1 - exp(2*I*a + 2*I*b*x)))/b - (I*x*polylog(2, exp(2*I*a + 2*I*b*x)))/b^2 + polylog(3, exp(2*I*a + 2*I*b*x))/(2*b^3)],
[x^2*cot(a + b*x)^2, x, 6, -((I*x^2)/b) - x^3/3 - (x^2*cot(a + b*x))/b + (2*x*log(1 - exp(2*I*a + 2*I*b*x)))/b^2 - (I*polylog(2, exp(2*I*a + 2*I*b*x)))/b^3],
[x^2*cot(a + b*x)^3, x, 9, (I*x^3)/3 - (x*cot(a + b*x))/b^2 - (x^2*csc(a + b*x)^2)/(2*b) - (x^2*log(1 - exp(2*I*a + 2*I*b*x)))/b + log(sin(a + b*x))/b^3 + (I*x*polylog(2, exp(2*I*a + 2*I*b*x)))/b^2 - polylog(3, exp(2*I*a + 2*I*b*x))/(2*b^3)],

[x^3*cot(a + b*x), x, 6, -((I*x^4)/4) + (x^3*log(1 - exp(2*I*a + 2*I*b*x)))/b - (3*I*x^2*polylog(2, exp(2*I*a + 2*I*b*x)))/(2*b^2) + (3*x*polylog(3, exp(2*I*a + 2*I*b*x)))/(2*b^3) + (3*I*polylog(4, exp(2*I*a + 2*I*b*x)))/(4*b^4)],
[x^3*cot(a + b*x)^2, x, 7, -((I*x^3)/b) - x^4/4 - (x^3*cot(a + b*x))/b + (3*x^2*log(1 - exp(2*I*a + 2*I*b*x)))/b^2 - (3*I*x*polylog(2, exp(2*I*a + 2*I*b*x)))/b^3 + (3*polylog(3, exp(2*I*a + 2*I*b*x)))/(2*b^4)],
[x^3*cot(a + b*x)^3, x, 13, -((3*I*x^2)/(2*b^2)) + (I*x^4)/4 - (3*x^2*cot(a + b*x))/(2*b^2) - (x^3*csc(a + b*x)^2)/(2*b) + (3*x*log(1 - exp(2*I*a + 2*I*b*x)))/b^3 - (x^3*log(1 - exp(2*I*a + 2*I*b*x)))/b - (3*I*(1 - b^2*x^2)*polylog(2, exp(2*I*a + 2*I*b*x)))/(2*b^4) - (3*x*polylog(3, exp(2*I*a + 2*I*b*x)))/(2*b^3) - (3*I*polylog(4, exp(2*I*a + 2*I*b*x)))/(4*b^4)],

[cot(a + b*x)/x, x, 0, Int(cot(a + b*x)/x, x)],
[cot(a + b*x)^2/x, x, 0, Int(cot(a + b*x)^2/x, x)],
[cot(a + b*x)^3/x, x, 0, Int(cot(a + b*x)^3/x, x)],

[cot(a + b*x)/x^2, x, 0, Int(cot(a + b*x)/x^2, x)],
[cot(a + b*x)^2/x^2, x, 0, Int(cot(a + b*x)^2/x^2, x)],
[cot(a + b*x)^3/x^2, x, 0, Int(cot(a + b*x)^3/x^2, x)],

[cot(a + b*x)/x^3, x, 0, Int(cot(a + b*x)/x^3, x)],
[cot(a + b*x)^2/x^3, x, 0, Int(cot(a + b*x)^2/x^3, x)],
[cot(a + b*x)^3/x^3, x, 0, Int(cot(a + b*x)^3/x^3, x)],


# ::Subsection::Closed:: 
#(a Cot[a+b x]^n)^m


# Integrands of the form (a*Cot[x]^n)^m where n is an integer and m is a half-integer 
[sqrt(a*cot(x)), x, 5, -((a*arctan(sqrt(a*cot(x))/(-a^2)^(1/4)))/(-a^2)^(1/4)) + (a*arctanh(sqrt(a*cot(x))/(-a^2)^(1/4)))/(-a^2)^(1/4)],
[sqrt(a*cot(x)^2), x, 2, sqrt(a*cot(x)^2)*log(sin(x))*tan(x)],
[sqrt(a*cot(x)^3), x, 10, -((1/(4*cot(x)^(3/2)))*(sqrt(a*cot(x)^3)*(2*sqrt(2)*arctan(1 - sqrt(2)*sqrt(cot(x))) - 2*sqrt(2)*arctan(1 + sqrt(2)*sqrt(cot(x))) + 8*sqrt(cot(x)) + sqrt(2)*log(1 - sqrt(2)*sqrt(cot(x)) + cot(x)) - sqrt(2)*log(1 + sqrt(2)*sqrt(cot(x)) + cot(x)))))],
[sqrt(a*cot(x)^4), x, 2, (-sqrt(a*cot(x)^4))*tan(x) - x*sqrt(a*cot(x)^4)*tan(x)^2],

[(a*cot(x))^(3/2),x, 6, a*(-a^2)^(1/4)*arctan(sqrt(a*cot(x))/(-a^2)^(1/4)) + a*(-a^2)^(1/4)*arctanh(sqrt(a*cot(x))/(-a^2)^(1/4)) - 2*a*sqrt(a*cot(x))],
[(a*cot(x)^2)^(3/2),x, 3, (-(1/2))*a*cot(x)*sqrt(a*cot(x)^2) - a*sqrt(a*cot(x)^2)*log(sin(x))*tan(x)],
[(a*cot(x)^3)^(3/2),x, 11, (1/(84*cot(x)^(3/2)))*(a*sqrt(a*cot(x)^3)*(42*sqrt(2)*arctan(1 - sqrt(2)*sqrt(cot(x))) - 42*sqrt(2)*arctan(1 + sqrt(2)*sqrt(cot(x))) + 56*cot(x)^(3/2) - 24*cot(x)^(7/2) - 21*sqrt(2)*log(1 - sqrt(2)*sqrt(cot(x)) + cot(x)) + 21*sqrt(2)*log(1 + sqrt(2)*sqrt(cot(x)) + cot(x))))],
[(a*cot(x)^4)^(3/2),x, 4, (1/3)*a*cot(x)*sqrt(a*cot(x)^4) - (1/5)*a*cot(x)^3*sqrt(a*cot(x)^4) - a*sqrt(a*cot(x)^4)*tan(x) - a*x*sqrt(a*cot(x)^4)*tan(x)^2],

[1/sqrt(a*cot(x)), x, 5, -(((-a^2)^(1/4)*arctan(sqrt(a*cot(x))/(-a^2)^(1/4)))/a) - ((-a^2)^(1/4)*arctanh(sqrt(a*cot(x))/(-a^2)^(1/4)))/a],
[1/sqrt(a*cot(x)^2), x, 2, -((cot(x)*log(cos(x)))/sqrt(a*cot(x)^2))],
[1/sqrt(a*cot(x)^3), x, 11, (1/(4*sqrt(a*cot(x)^3)))*(cot(x)*(8 - sqrt(2)*sqrt(cot(x))*(2*arctan(1 - sqrt(2)*sqrt(cot(x))) - 2*arctan(1 + sqrt(2)*sqrt(cot(x))) - log(1 - sqrt(2)*sqrt(cot(x)) + cot(x)) + log(1 + sqrt(2)*sqrt(cot(x)) + cot(x)))))],
[1/sqrt(a*cot(x)^4), x, 2, cot(x)/sqrt(a*cot(x)^4) - (x*cot(x)^2)/sqrt(a*cot(x)^4)],


# ::Subsection::Closed:: 
#(a+b Cot[c+d x])^n


# Integrands of the form (a+b*Cot[x])^n where a^2+b^2 is nonzero 
[(a + b*cot(x))^4, x, 8, a^4*x - 6*a^2*b^2*x + b^4*x - 6*a^2*b^2*cot(x) + b^4*cot(x) - 2*a*b^3*cot(x)^2 - (1/3)*b^4*cot(x)^3 + 4*a^3*b*log(sin(x)) - 4*a*b^3*log(sin(x))],
[(a + b*cot(x))^3, x, 6, a^3*x - 3*a*b^2*x - 3*a*b^2*cot(x) - (1/2)*b^3*cot(x)^2 + 3*a^2*b*log(sin(x)) - b^3*log(sin(x))],
[(a + b*cot(x))^2, x, 4, a^2*x - b^2*x - b^2*cot(x) + 2*a*b*log(sin(x))],
[(a + b*cot(x)), x, 2, a*x + b*log(sin(x))],
[1/(a + b*cot(x)), x, 1, (a*x)/(a^2 + b^2) - (b*log(b*cos(x) + a*sin(x)))/(a^2 + b^2)],
[1/(a + b*cot(x))^2, x, 3, (2*a^2*x)/(a^2 + b^2)^2 - x/(a^2 + b^2) + b/((a^2 + b^2)*(a + b*cot(x))) - (2*a*b*log(b*cos(x) + a*sin(x)))/(a^2 + b^2)^2],
[1/(a + b*cot(x))^3, x, 4, (a*(3*a^2 - b^2)*x)/(a^2 + b^2)^3 - (2*a*x)/(a^2 + b^2)^2 + b/(2*(a^2 + b^2)*(a + b*cot(x))^2) + (2*a*b)/((a^2 + b^2)^2*(a + b*cot(x))) - (b*(3*a^2 - b^2)*log(b*cos(x) + a*sin(x)))/(a^2 + b^2)^3],
[1/(a + b*cot(x))^4, x, 5, (4*a^2*(a^2 - b^2)*x)/(a^2 + b^2)^4 - ((3*a^2 - b^2)*x)/(a^2 + b^2)^3 + b/(3*(a^2 + b^2)*(a + b*cot(x))^3) + (a*b)/((a^2 + b^2)^2*(a + b*cot(x))^2) + (b*(3*a^2 - b^2))/((a^2 + b^2)^3*(a + b*cot(x))) - (4*a*b*(a^2 - b^2)*log(b*cos(x) + a*sin(x)))/(a^2 + b^2)^4],

[1/(4 + 6*cot(x)), x, 2, x/13 - (3/26)*log(3*cos(x) + 2*sin(x))],
[1/(4 - 6*cot(x)), x, 2, x/13 + (3/26)*log(-3*cos(x) + 2*sin(x))],

[(a + b*cot(x))^(5/2), x, 5, (I*(a^3 - 3*a*b^2 - I*b*(3*a^2 - b^2))*arccoth(sqrt(a + b*cot(x))/sqrt(a - I*b)))/sqrt(a - I*b) - (I*(a^3 - 3*a*b^2 + I*b*(3*a^2 - b^2))*arccoth(sqrt(a + b*cot(x))/sqrt(a + I*b)))/sqrt(a + I*b) - 4*a*b*sqrt(a + b*cot(x)) - (2/3)*b*(a + b*cot(x))^(3/2)],
[(a + b*cot(x))^(3/2), x, 4, (I*(a^2 - 2*I*a*b - b^2)*arccoth(sqrt(a + b*cot(x))/sqrt(a - I*b)))/sqrt(a - I*b) - (I*(a^2 + 2*I*a*b - b^2)*arccoth(sqrt(a + b*cot(x))/sqrt(a + I*b)))/sqrt(a + I*b) - 2*b*sqrt(a + b*cot(x))],
[(a + b*cot(x))^(1/2), x, 3, I*sqrt(a - I*b)*arccoth(sqrt(a + b*cot(x))/sqrt(a - I*b)) - I*sqrt(a + I*b)*arccoth(sqrt(a + b*cot(x))/sqrt(a + I*b))],
[1/(a + b*cot(x))^(1/2), x, 3, (I*arccoth(sqrt(a + b*cot(x))/sqrt(a - I*b)))/sqrt(a - I*b) - (I*arccoth(sqrt(a + b*cot(x))/sqrt(a + I*b)))/sqrt(a + I*b)],
[1/(a + b*cot(x))^(3/2), x, 4, (I*(a + I*b)*arccoth(sqrt(a + b*cot(x))/sqrt(a - I*b)))/(sqrt(a - I*b)*(a^2 + b^2)) - (I*(a - I*b)*arccoth(sqrt(a + b*cot(x))/sqrt(a + I*b)))/(sqrt(a + I*b)*(a^2 + b^2)) + (2*b)/((a^2 + b^2)*sqrt(a + b*cot(x)))],
[1/(a + b*cot(x))^(5/2), x, 5, (I*(a^2 + 2*I*a*b - b^2)*arccoth(sqrt(a + b*cot(x))/sqrt(a - I*b)))/(sqrt(a - I*b)*(a^2 + b^2)^2) - (I*(a^2 - 2*I*a*b - b^2)*arccoth(sqrt(a + b*cot(x))/sqrt(a + I*b)))/(sqrt(a + I*b)*(a^2 + b^2)^2) + (2*b)/(3*(a^2 + b^2)*(a + b*cot(x))^(3/2)) + (4*a*b)/((a^2 + b^2)^2*sqrt(a + b*cot(x)))],


# Integrands of the form (a+b*Cot[x])^n where a^2+b^2 is zero 
[(1 + I*cot(x))^4, x, 8, 8*x + 7*cot(x) + 2*I*cot(x)^2 - cot(x)^3/3 + 8*I*log(sin(x))],
[(1 + I*cot(x))^3, x, 6, 4*x + 3*cot(x) + (1/2)*I*cot(x)^2 + 4*I*log(sin(x))],
[(1 + I*cot(x))^2, x, 4, 2*x + cot(x) + 2*I*log(sin(x))],
[(1 + I*cot(x)), x, 2, x + I*log(sin(x))],
[1/(1 + I*cot(x)), x, 1, x/2 - I/(2*(1 + I*cot(x)))],
[1/(1 + I*cot(x))^2, x, 2, x/4 - I/(4*(1 + I*cot(x))^2) - I/(4*(1 + I*cot(x)))],
[1/(1 + I*cot(x))^3, x, 3, x/8 - I/(6*(1 + I*cot(x))^3) - I/(8*(1 + I*cot(x))^2) - I/(8*(1 + I*cot(x)))],

[(1 + I*cot(x))^(5/2), x, 3, 4*I*sqrt(2)*arccoth(sqrt(1 + I*cot(x))/sqrt(2)) - 4*I*sqrt(1 + I*cot(x)) - (2/3)*I*(1 + I*cot(x))^(3/2)],
[(1 + I*cot(x))^(3/2), x, 2, 2*I*sqrt(2)*arccoth(sqrt(1 + I*cot(x))/sqrt(2)) - 2*I*sqrt(1 + I*cot(x))],
[(1 + I*cot(x))^(1/2), x, 1, I*sqrt(2)*arccoth(sqrt(1 + I*cot(x))/sqrt(2))],
[1/(1 + I*cot(x))^(1/2), x, 2, (I*arccoth(sqrt(1 + I*cot(x))/sqrt(2)))/sqrt(2) - I/sqrt(1 + I*cot(x))],
[1/(1 + I*cot(x))^(3/2), x, 3, (I*arccoth(sqrt(1 + I*cot(x))/sqrt(2)))/(2*sqrt(2)) - I/(3*(1 + I*cot(x))^(3/2)) - I/(2*sqrt(1 + I*cot(x)))],
[1/(1 + I*cot(x))^(5/2), x, 4, (I*arccoth(sqrt(1 + I*cot(x))/sqrt(2)))/(4*sqrt(2)) - I/(5*(1 + I*cot(x))^(5/2)) - I/(6*(1 + I*cot(x))^(3/2)) - I/(4*sqrt(1 + I*cot(x)))],


# ::Subsection::Closed:: 
#(A+B Cot[c+d x]) (a+b Cot[c+d x])^n


[(A + B*cot(c + d*x))/(a + b*cot(c + d*x)), x, 2, ((a*A + b*B)*x)/(a^2 + b^2) - ((A*b - a*B)*log(b*cos(c + d*x) + a*sin(c + d*x)))/((a^2 + b^2)*d)],
[(A + B*cot(c + d*x))/(a + b*cot(c + d*x))^2, x, 3, -(((A*b - a*B)*x)/(b*(a^2 + b^2))) + (a*(b^2*B + a*(2*A*b - a*B))*x)/(b*(a^2 + b^2)^2) + (A*b - a*B)/((a^2 + b^2)*d*(a + b*cot(c + d*x))) - ((b^2*B + a*(2*A*b - a*B))*log(b*cos(c + d*x) + a*sin(c + d*x)))/((a^2 + b^2)^2*d)],
[(A + B*cot(c + d*x))/(a + b*cot(c + d*x))^3, x, 4, -(((b^2*B + a*(2*A*b - a*B))*x)/(b*(a^2 + b^2)^2)) + (a*(b*(a^2*A - b*(A*b - 2*a*B)) + a*(b^2*B + a*(2*A*b - a*B)))*x)/(b*(a^2 + b^2)^3) + (A*b - a*B)/(2*(a^2 + b^2)*d*(a + b*cot(c + d*x))^2) + (b^2*B + a*(2*A*b - a*B))/((a^2 + b^2)^2*d*(a + b*cot(c + d*x))) - ((b*(a^2*A - b*(A*b - 2*a*B)) + a*(b^2*B + a*(2*A*b - a*B)))*log(b*cos(c + d*x) + a*sin(c + d*x)))/((a^2 + b^2)^3*d)],


[(1 + I*cot(c + d*x))/sqrt(a + b*cot(c + d*x)), x, 1, (2*I*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*d)],
[(1 - I*cot(c + d*x))/sqrt(a + b*cot(c + d*x)), x, 1, -((2*I*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*d))],

[(A + B*cot(c + d*x))*(a + b*cot(c + d*x))^(5/2), x, 6, (I*(b*(b^2*B - a*(2*A*b + a*B)) + a*(a^2*A - b*(A*b + 2*a*B)) + I*(a*(b^2*B - a*(2*A*b + a*B)) - b*(a^2*A - b*(A*b + 2*a*B))))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*d) - (I*(b*(b^2*B - a*(2*A*b + a*B)) + a*(a^2*A - b*(A*b + 2*a*B)) - I*(a*(b^2*B - a*(2*A*b + a*B)) - b*(a^2*A - b*(A*b + 2*a*B))))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*d) + (2*(b^2*B - a*(2*A*b + a*B))*sqrt(a + b*cot(c + d*x)))/d - (2*(A*b + a*B)*(a + b*cot(c + d*x))^(3/2))/(3*d) - (2*B*(a + b*cot(c + d*x))^(5/2))/(5*d)],
[(A + B*cot(c + d*x))*(a + b*cot(c + d*x))^(3/2), x, 5, (I*(a^2*A - b*(A*b + 2*a*B) + I*(b^2*B - a*(2*A*b + a*B)))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*d) - (I*(a^2*A - b*(A*b + 2*a*B) - I*(b^2*B - a*(2*A*b + a*B)))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*d) - (2*(A*b + a*B)*sqrt(a + b*cot(c + d*x)))/d - (2*B*(a + b*cot(c + d*x))^(3/2))/(3*d)],
[(A + B*cot(c + d*x))*(a + b*cot(c + d*x))^(1/2), x, 4, (I*(a*A - b*B - I*(A*b + a*B))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*d) - (I*(a*A - b*B + I*(A*b + a*B))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*d) - (2*B*sqrt(a + b*cot(c + d*x)))/d],
[(A + B*cot(c + d*x))/(a + b*cot(c + d*x))^(1/2), x, 3, (I*(A - I*B)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*d) - (I*(A + I*B)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*d)],
[(A + B*cot(c + d*x))/(a + b*cot(c + d*x))^(3/2), x, 4, (I*(a*A + b*B + I*(A*b - a*B))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*(a^2 + b^2)*d) - (I*(a*A + b*B - I*(A*b - a*B))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*(a^2 + b^2)*d) + (2*(A*b - a*B))/((a^2 + b^2)*d*sqrt(a + b*cot(c + d*x)))],
[(A + B*cot(c + d*x))/(a + b*cot(c + d*x))^(5/2), x, 5, (I*(a^2*A - b*(A*b - 2*a*B) + I*(b^2*B + a*(2*A*b - a*B)))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*(a^2 + b^2)^2*d) - (I*(a^2*A - b*(A*b - 2*a*B) - I*(b^2*B + a*(2*A*b - a*B)))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*(a^2 + b^2)^2*d) + (2*(A*b - a*B))/(3*(a^2 + b^2)*d*(a + b*cot(c + d*x))^(3/2)) + (2*(b^2*B + a*(2*A*b - a*B)))/((a^2 + b^2)^2*d*sqrt(a + b*cot(c + d*x)))],

[(-a + b*cot(c + d*x))*(a + b*cot(c + d*x))^(5/2), x, 5, -((I*(a^2 - 2*I*a*b - b^2)*(a^2 + b^2)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*d)) + (I*(a^2 + 2*I*a*b - b^2)*(a^2 + b^2)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*d) + (2*b*(a^2 + b^2)*sqrt(a + b*cot(c + d*x)))/d - (2*b*(a + b*cot(c + d*x))^(5/2))/(5*d)],
[(-a + b*cot(c + d*x))*(a + b*cot(c + d*x))^(3/2), x, 4, -((I*sqrt(a - I*b)*(a^2 + b^2)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/d) + (I*sqrt(a + I*b)*(a^2 + b^2)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/d - (2*b*(a + b*cot(c + d*x))^(3/2))/(3*d)],
[(-a + b*cot(c + d*x))*(a + b*cot(c + d*x))^(1/2), x, 4, -((I*(a^2 + b^2)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*d)) + (I*(a^2 + b^2)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*d) - (2*b*sqrt(a + b*cot(c + d*x)))/d],
[(-a + b*cot(c + d*x))/(a + b*cot(c + d*x))^(1/2), x, 3, -((I*(a + I*b)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*d)) + (I*(a - I*b)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*d)],
[(-a + b*cot(c + d*x))/(a + b*cot(c + d*x))^(3/2), x, 4, -((I*(a^2 + 2*I*a*b - b^2)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*(a^2 + b^2)*d)) + (I*(a^2 - 2*I*a*b - b^2)*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*(a^2 + b^2)*d) - (4*a*b)/((a^2 + b^2)*d*sqrt(a + b*cot(c + d*x)))],
[(-a + b*cot(c + d*x))/(a + b*cot(c + d*x))^(5/2), x, 5, -((I*(a^3 - 3*a*b^2 + I*b*(3*a^2 - b^2))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a - I*b)))/(sqrt(a - I*b)*(a^2 + b^2)^2*d)) + (I*(a^3 - 3*a*b^2 - I*b*(3*a^2 - b^2))*arccoth(sqrt(a + b*cot(c + d*x))/sqrt(a + I*b)))/(sqrt(a + I*b)*(a^2 + b^2)^2*d) - (4*a*b)/(3*(a^2 + b^2)*d*(a + b*cot(c + d*x))^(3/2)) - (2*b*(3*a^2 - b^2))/((a^2 + b^2)^2*d*sqrt(a + b*cot(c + d*x)))],


# ::Subsection::Closed:: 
#(a+b Cot[c+d x]^n)^m


[1/(1 + 2*cot(x)^2), x, 1, -x - sqrt(2)*arctan(sqrt(2)*cot(x))],
[1/(1 - 2*cot(x)^2), x, 1, x/3 - (1/3)*sqrt(2)*arctanh(sqrt(2)*cot(x))],

[1/(1 + cot(x)^3), x, 8, x/2 - (1/6)*log(1 + cot(x)) - (1/4)*log(csc(x)^2) + (1/3)*log(-cot(x) + csc(x)^2), (-(1/6))*log(1 + cot(x)) - (1/4)*log(csc(x)^2) + (1/3)*log(-cot(x) + csc(x)^2) - (1/2)*Pi*modsx(1/2 - x/Pi)],


# Integrands of the form (a+b*Cot[x]^2)^m where m is a half-integer 
[sqrt(1 + cot(x)^2), x, 3, -arccsch(tan(x))],
[sqrt(1 - cot(x)^2), x, 4, arccsc(tan(x)) - sqrt(2)*arctan((sqrt(2)*cot(x))/sqrt(1 - cot(x)^2))],
[sqrt(-1 + cot(x)^2), x, 4, -arctanh(cot(x)/sqrt(-1 + cot(x)^2)) + sqrt(2)*arctanh((sqrt(2)*cot(x))/sqrt(-1 + cot(x)^2))],
[sqrt(-1 - cot(x)^2), x, 3, (-arctanh(cos(x)))*sqrt(-csc(x)^2)*sin(x)],
[sqrt(a + b*cot(x)^2), x, 4, (-sqrt(a - b))*arctan((sqrt(a - b)*cot(x))/sqrt(a + b*cot(x)^2)) - sqrt(b)*arctanh((sqrt(b)*cot(x))/sqrt(a + b*cot(x)^2))],

[1/sqrt(1 + cot(x)^2), x, 3, -(cot(x)/sqrt(csc(x)^2))],
[1/sqrt(1 - cot(x)^2), x, 2, -(arctan((sqrt(2)*cot(x))/sqrt(1 - cot(x)^2))/sqrt(2))],
[1/sqrt(-1 + cot(x)^2), x, 2, -(arctanh((sqrt(2)*cot(x))/sqrt(-1 + cot(x)^2))/sqrt(2))],
[1/sqrt(-1 - cot(x)^2), x, 3, -(cot(x)/sqrt(-csc(x)^2))],
[1/sqrt(a + b*cot(x)^2), x, 2, -(arctan((sqrt(a - b)*cot(x))/sqrt(a + b*cot(x)^2))/sqrt(a - b))],

[(1 + cot(x)^2)^(3/2), x, 4, (-(1/2))*arccsch(tan(x)) - (1/2)*cot(x)*sqrt(csc(x)^2)],
[(1 - cot(x)^2)^(3/2), x, 7, (5/2)*arccsc(tan(x)) - 2*sqrt(2)*arctan((sqrt(2)*cot(x))/sqrt(1 - cot(x)^2)) + (1/2)*cot(x)*sqrt(1 - cot(x)^2)],
[(-1 + cot(x)^2)^(3/2), x, 7, (5/2)*arctanh(cot(x)/sqrt(-1 + cot(x)^2)) - 2*sqrt(2)*arctanh((sqrt(2)*cot(x))/sqrt(-1 + cot(x)^2)) - (1/2)*cot(x)*sqrt(-1 + cot(x)^2)],
[(-1 - cot(x)^2)^(3/2), x, 4, (1/2)*sqrt(-csc(x)^2)*(arctanh(cos(x)) + cot(x)*csc(x))*sin(x)],
[(a + b*cot(x)^2)^(3/2), x, 7, (-(a - b)^(3/2))*arctan((sqrt(a - b)*cot(x))/sqrt(a + b*cot(x)^2)) - (3/2)*a*sqrt(b)*arctanh((sqrt(b)*cot(x))/sqrt(a + b*cot(x)^2)) + b^(3/2)*arctanh((sqrt(b)*cot(x))/sqrt(a + b*cot(x)^2)) - (1/2)*b*cot(x)*sqrt(a + b*cot(x)^2)],


# ::Subsection::Closed:: 
#x^m Cot[a+b Log[c x^n]]^p


# Integrands of the form Cot[a+b*Log[c*x^n]]^p/x where p is an integer 
[cot(a + b*log(c*x^n))/x, x, 2, log(sin(a + b*log(c*x^n)))/(b*n)],
[cot(a + b*log(c*x^n))^2/x, x, 2, -(cot(a + b*log(c*x^n))/(b*n)) - log(c*x^n)/n],
[cot(a + b*log(c*x^n))^3/x, x, 3, -(cot(a + b*log(c*x^n))^2/(2*b*n)) - log(sin(a + b*log(c*x^n)))/(b*n)],
[cot(a + b*log(c*x^n))^4/x, x, 3, cot(a + b*log(c*x^n))/(b*n) - cot(a + b*log(c*x^n))^3/(3*b*n) + log(c*x^n)/n],
[cot(a + b*log(c*x^n))^5/x, x, 4, cot(a + b*log(c*x^n))^2/(2*b*n) - cot(a + b*log(c*x^n))^4/(4*b*n) + log(sin(a + b*log(c*x^n)))/(b*n)],


# Integrands of the form Cot[a+b*Log[c*x^n]]^p/x where p is a half-integer 
[cot(a + b*log(c*x^n))^(5/2)/x, x, 9, -(arctan(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n)) + arctan(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n) - (2*cot(a + b*log(c*x^n))^(3/2))/(3*b*n) + log(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n) - log(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n)],
[cot(a + b*log(c*x^n))^(3/2)/x, x, 9, -(arctan(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n)) + arctan(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n) - (2*sqrt(cot(a + b*log(c*x^n))))/(b*n) - log(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n) + log(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n)],
[sqrt(cot(a + b*log(c*x^n)))/x, x, 8, arctan(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n) - arctan(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n) - log(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n) + log(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n)],
[1/(x*sqrt(cot(a + b*log(c*x^n)))), x, 8, arctan(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n) - arctan(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n) + log(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n) - log(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n)],
[1/(x*cot(a + b*log(c*x^n))^(3/2)), x, 9, -(arctan(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n)) + arctan(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n) + 2/(b*n*sqrt(cot(a + b*log(c*x^n)))) + log(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n) - log(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n)],
[1/(x*cot(a + b*log(c*x^n))^(5/2)), x, 9, -(arctan(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n)) + arctan(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))))/(sqrt(2)*b*n) + 2/(3*b*n*cot(a + b*log(c*x^n))^(3/2)) - log(1 - sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n) + log(1 + sqrt(2)*sqrt(cot(a + b*log(c*x^n))) + cot(a + b*log(c*x^n)))/(2*sqrt(2)*b*n)],


# ::Subsection::Closed:: 
#Miscellaneous integrands involving cotangents


[cot(sqrt(x))^2/sqrt(x), x, 2, -2*sqrt(x) - 2*cot(sqrt(x))],


[cot(x)/sqrt(1 + I*cot(x)), x, 6, arctanh(sqrt(1 + I*cot(x))/sqrt(2))/sqrt(2) + 1/sqrt(1 + I*cot(x))],
[cot(x)/sqrt(I + cot(x)), x, 6, (-(1/2) - I/2)*arctan((1/2 + I/2)*sqrt(I + cot(x))) + 1/sqrt(I + cot(x))]
]:
