\(\int (c+d x) (a+b \cot (e+f x))^2 \, dx\) [44]

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [B] (verified)
Fricas [B] (verification not implemented)
Sympy [F]
Maxima [B] (verification not implemented)
Giac [F]
Mupad [F(-1)]
Reduce [F]

Optimal result

Integrand size = 18, antiderivative size = 136 \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\frac {a^2 (c+d x)^2}{2 d}-\frac {i a b (c+d x)^2}{d}-\frac {b^2 (c+d x)^2}{2 d}-\frac {b^2 (c+d x) \cot (e+f x)}{f}+\frac {2 a b (c+d x) \log \left (1-e^{2 i (e+f x)}\right )}{f}+\frac {b^2 d \log (\sin (e+f x))}{f^2}-\frac {i a b d \operatorname {PolyLog}\left (2,e^{2 i (e+f x)}\right )}{f^2} \] Output:

1/2*a^2*(d*x+c)^2/d-I*a*b*(d*x+c)^2/d-1/2*b^2*(d*x+c)^2/d-b^2*(d*x+c)*cot( 
f*x+e)/f+2*a*b*(d*x+c)*ln(1-exp(2*I*(f*x+e)))/f+b^2*d*ln(sin(f*x+e))/f^2-I 
*a*b*d*polylog(2,exp(2*I*(f*x+e)))/f^2
 

Mathematica [A] (verified)

Time = 7.13 (sec) , antiderivative size = 200, normalized size of antiderivative = 1.47 \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\frac {(a+b \cot (e+f x))^2 \sin (e+f x) \left (-2 b^2 f (c+d x) \cos (e+f x)+\left (-\left ((e+f x) \left (2 i a b d (e+f x)+a^2 (d e-2 c f-d f x)+b^2 (-d e+2 c f+d f x)\right )\right )+4 a b d (e+f x) \log \left (1-e^{2 i (e+f x)}\right )+2 b (b d-2 a d e+2 a c f) \log (\sin (e+f x))\right ) \sin (e+f x)-2 i a b d \operatorname {PolyLog}\left (2,e^{2 i (e+f x)}\right ) \sin (e+f x)\right )}{2 f^2 (b \cos (e+f x)+a \sin (e+f x))^2} \] Input:

Integrate[(c + d*x)*(a + b*Cot[e + f*x])^2,x]
 

Output:

((a + b*Cot[e + f*x])^2*Sin[e + f*x]*(-2*b^2*f*(c + d*x)*Cos[e + f*x] + (- 
((e + f*x)*((2*I)*a*b*d*(e + f*x) + a^2*(d*e - 2*c*f - d*f*x) + b^2*(-(d*e 
) + 2*c*f + d*f*x))) + 4*a*b*d*(e + f*x)*Log[1 - E^((2*I)*(e + f*x))] + 2* 
b*(b*d - 2*a*d*e + 2*a*c*f)*Log[Sin[e + f*x]])*Sin[e + f*x] - (2*I)*a*b*d* 
PolyLog[2, E^((2*I)*(e + f*x))]*Sin[e + f*x]))/(2*f^2*(b*Cos[e + f*x] + a* 
Sin[e + f*x])^2)
 

Rubi [A] (verified)

Time = 0.42 (sec) , antiderivative size = 136, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.167, Rules used = {3042, 4205, 2009}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int (c+d x) (a+b \cot (e+f x))^2 \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (c+d x) \left (a-b \tan \left (e+f x+\frac {\pi }{2}\right )\right )^2dx\)

\(\Big \downarrow \) 4205

\(\displaystyle \int \left (a^2 (c+d x)+2 a b (c+d x) \cot (e+f x)+b^2 (c+d x) \cot ^2(e+f x)\right )dx\)

\(\Big \downarrow \) 2009

\(\displaystyle \frac {a^2 (c+d x)^2}{2 d}+\frac {2 a b (c+d x) \log \left (1-e^{2 i (e+f x)}\right )}{f}-\frac {i a b (c+d x)^2}{d}-\frac {i a b d \operatorname {PolyLog}\left (2,e^{2 i (e+f x)}\right )}{f^2}-\frac {b^2 (c+d x) \cot (e+f x)}{f}-\frac {b^2 (c+d x)^2}{2 d}+\frac {b^2 d \log (\sin (e+f x))}{f^2}\)

Input:

Int[(c + d*x)*(a + b*Cot[e + f*x])^2,x]
 

Output:

(a^2*(c + d*x)^2)/(2*d) - (I*a*b*(c + d*x)^2)/d - (b^2*(c + d*x)^2)/(2*d) 
- (b^2*(c + d*x)*Cot[e + f*x])/f + (2*a*b*(c + d*x)*Log[1 - E^((2*I)*(e + 
f*x))])/f + (b^2*d*Log[Sin[e + f*x]])/f^2 - (I*a*b*d*PolyLog[2, E^((2*I)*( 
e + f*x))])/f^2
 

Defintions of rubi rules used

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4205
Int[((c_.) + (d_.)*(x_))^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.) 
, x_Symbol] :> Int[ExpandIntegrand[(c + d*x)^m, (a + b*Tan[e + f*x])^n, x], 
 x] /; FreeQ[{a, b, c, d, e, f, m}, x] && IGtQ[m, 0] && IGtQ[n, 0]
 
Maple [B] (verified)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 364 vs. \(2 (126 ) = 252\).

Time = 1.07 (sec) , antiderivative size = 365, normalized size of antiderivative = 2.68

method result size
risch \(-\frac {b^{2} d \,x^{2}}{2}-\frac {4 i b a d e x}{f}+\frac {a^{2} d \,x^{2}}{2}-b^{2} c x -i a b d \,x^{2}+a^{2} c x +2 i a b c x +\frac {b^{2} d \ln \left ({\mathrm e}^{i \left (f x +e \right )}-1\right )}{f^{2}}-\frac {2 b^{2} d \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}+\frac {b^{2} d \ln \left ({\mathrm e}^{i \left (f x +e \right )}+1\right )}{f^{2}}+\frac {2 b a c \ln \left ({\mathrm e}^{i \left (f x +e \right )}-1\right )}{f}-\frac {4 b a c \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f}+\frac {2 b a c \ln \left ({\mathrm e}^{i \left (f x +e \right )}+1\right )}{f}-\frac {2 b e a d \ln \left ({\mathrm e}^{i \left (f x +e \right )}-1\right )}{f^{2}}+\frac {4 b e a d \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}-\frac {2 i b a d \,e^{2}}{f^{2}}-\frac {2 i b a d \operatorname {polylog}\left (2, {\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}-\frac {2 i b^{2} \left (d x +c \right )}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right )}+\frac {2 b a d \ln \left (1-{\mathrm e}^{i \left (f x +e \right )}\right ) x}{f}+\frac {2 b a d \ln \left (1-{\mathrm e}^{i \left (f x +e \right )}\right ) e}{f^{2}}-\frac {2 i b a d \operatorname {polylog}\left (2, -{\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}+\frac {2 b a d \ln \left ({\mathrm e}^{i \left (f x +e \right )}+1\right ) x}{f}\) \(365\)

Input:

int((d*x+c)*(a+b*cot(f*x+e))^2,x,method=_RETURNVERBOSE)
 

Output:

-1/2*b^2*d*x^2-4*I/f*b*a*d*e*x+1/2*a^2*d*x^2-b^2*c*x-I*a*b*d*x^2+a^2*c*x+2 
*I*a*b*c*x+1/f^2*b^2*d*ln(exp(I*(f*x+e))-1)-2/f^2*b^2*d*ln(exp(I*(f*x+e))) 
+1/f^2*b^2*d*ln(exp(I*(f*x+e))+1)+2/f*b*a*c*ln(exp(I*(f*x+e))-1)-4/f*b*a*c 
*ln(exp(I*(f*x+e)))+2/f*b*a*c*ln(exp(I*(f*x+e))+1)-2/f^2*b*e*a*d*ln(exp(I* 
(f*x+e))-1)+4/f^2*b*e*a*d*ln(exp(I*(f*x+e)))-2*I/f^2*b*a*d*e^2-2*I/f^2*b*a 
*d*polylog(2,exp(I*(f*x+e)))-2*I*b^2*(d*x+c)/f/(exp(2*I*(f*x+e))-1)+2/f*b* 
a*d*ln(1-exp(I*(f*x+e)))*x+2/f^2*b*a*d*ln(1-exp(I*(f*x+e)))*e-2*I/f^2*b*a* 
d*polylog(2,-exp(I*(f*x+e)))+2/f*b*a*d*ln(exp(I*(f*x+e))+1)*x
 

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 378 vs. \(2 (123) = 246\).

Time = 0.09 (sec) , antiderivative size = 378, normalized size of antiderivative = 2.78 \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=-\frac {2 \, b^{2} d f x + i \, a b d {\rm Li}_2\left (\cos \left (2 \, f x + 2 \, e\right ) + i \, \sin \left (2 \, f x + 2 \, e\right )\right ) \sin \left (2 \, f x + 2 \, e\right ) - i \, a b d {\rm Li}_2\left (\cos \left (2 \, f x + 2 \, e\right ) - i \, \sin \left (2 \, f x + 2 \, e\right )\right ) \sin \left (2 \, f x + 2 \, e\right ) + 2 \, b^{2} c f + {\left (2 \, a b d e - 2 \, a b c f - b^{2} d\right )} \log \left (-\frac {1}{2} \, \cos \left (2 \, f x + 2 \, e\right ) + \frac {1}{2} i \, \sin \left (2 \, f x + 2 \, e\right ) + \frac {1}{2}\right ) \sin \left (2 \, f x + 2 \, e\right ) + {\left (2 \, a b d e - 2 \, a b c f - b^{2} d\right )} \log \left (-\frac {1}{2} \, \cos \left (2 \, f x + 2 \, e\right ) - \frac {1}{2} i \, \sin \left (2 \, f x + 2 \, e\right ) + \frac {1}{2}\right ) \sin \left (2 \, f x + 2 \, e\right ) - 2 \, {\left (a b d f x + a b d e\right )} \log \left (-\cos \left (2 \, f x + 2 \, e\right ) + i \, \sin \left (2 \, f x + 2 \, e\right ) + 1\right ) \sin \left (2 \, f x + 2 \, e\right ) - 2 \, {\left (a b d f x + a b d e\right )} \log \left (-\cos \left (2 \, f x + 2 \, e\right ) - i \, \sin \left (2 \, f x + 2 \, e\right ) + 1\right ) \sin \left (2 \, f x + 2 \, e\right ) + 2 \, {\left (b^{2} d f x + b^{2} c f\right )} \cos \left (2 \, f x + 2 \, e\right ) - {\left ({\left (a^{2} - b^{2}\right )} d f^{2} x^{2} + 2 \, {\left (a^{2} - b^{2}\right )} c f^{2} x\right )} \sin \left (2 \, f x + 2 \, e\right )}{2 \, f^{2} \sin \left (2 \, f x + 2 \, e\right )} \] Input:

integrate((d*x+c)*(a+b*cot(f*x+e))^2,x, algorithm="fricas")
 

Output:

-1/2*(2*b^2*d*f*x + I*a*b*d*dilog(cos(2*f*x + 2*e) + I*sin(2*f*x + 2*e))*s 
in(2*f*x + 2*e) - I*a*b*d*dilog(cos(2*f*x + 2*e) - I*sin(2*f*x + 2*e))*sin 
(2*f*x + 2*e) + 2*b^2*c*f + (2*a*b*d*e - 2*a*b*c*f - b^2*d)*log(-1/2*cos(2 
*f*x + 2*e) + 1/2*I*sin(2*f*x + 2*e) + 1/2)*sin(2*f*x + 2*e) + (2*a*b*d*e 
- 2*a*b*c*f - b^2*d)*log(-1/2*cos(2*f*x + 2*e) - 1/2*I*sin(2*f*x + 2*e) + 
1/2)*sin(2*f*x + 2*e) - 2*(a*b*d*f*x + a*b*d*e)*log(-cos(2*f*x + 2*e) + I* 
sin(2*f*x + 2*e) + 1)*sin(2*f*x + 2*e) - 2*(a*b*d*f*x + a*b*d*e)*log(-cos( 
2*f*x + 2*e) - I*sin(2*f*x + 2*e) + 1)*sin(2*f*x + 2*e) + 2*(b^2*d*f*x + b 
^2*c*f)*cos(2*f*x + 2*e) - ((a^2 - b^2)*d*f^2*x^2 + 2*(a^2 - b^2)*c*f^2*x) 
*sin(2*f*x + 2*e))/(f^2*sin(2*f*x + 2*e))
 

Sympy [F]

\[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\int \left (a + b \cot {\left (e + f x \right )}\right )^{2} \left (c + d x\right )\, dx \] Input:

integrate((d*x+c)*(a+b*cot(f*x+e))**2,x)
 

Output:

Integral((a + b*cot(e + f*x))**2*(c + d*x), x)
 

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 774 vs. \(2 (123) = 246\).

Time = 0.14 (sec) , antiderivative size = 774, normalized size of antiderivative = 5.69 \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx =\text {Too large to display} \] Input:

integrate((d*x+c)*(a+b*cot(f*x+e))^2,x, algorithm="maxima")
 

Output:

1/2*(2*(f*x + e)*a^2*c + (f*x + e)^2*a^2*d/f - 2*(f*x + e)*a^2*d*e/f + 4*a 
*b*c*log(sin(f*x + e)) - 4*a*b*d*e*log(sin(f*x + e))/f + 2*((2*a*b - I*b^2 
)*(f*x + e)^2*d + 4*b^2*d*e - 4*b^2*c*f - 2*(-I*b^2*d*e + I*b^2*c*f)*(f*x 
+ e) - 2*(2*(f*x + e)*a*b*d + b^2*d - (2*(f*x + e)*a*b*d + b^2*d)*cos(2*f* 
x + 2*e) + (-2*I*(f*x + e)*a*b*d - I*b^2*d)*sin(2*f*x + 2*e))*arctan2(sin( 
f*x + e), cos(f*x + e) + 1) + 2*(b^2*d*cos(2*f*x + 2*e) + I*b^2*d*sin(2*f* 
x + 2*e) - b^2*d)*arctan2(sin(f*x + e), cos(f*x + e) - 1) - 4*((f*x + e)*a 
*b*d*cos(2*f*x + 2*e) + I*(f*x + e)*a*b*d*sin(2*f*x + 2*e) - (f*x + e)*a*b 
*d)*arctan2(sin(f*x + e), -cos(f*x + e) + 1) - ((2*a*b - I*b^2)*(f*x + e)^ 
2*d + 2*(I*b^2*d*e - I*b^2*c*f + 2*b^2*d)*(f*x + e))*cos(2*f*x + 2*e) - 4* 
(a*b*d*cos(2*f*x + 2*e) + I*a*b*d*sin(2*f*x + 2*e) - a*b*d)*dilog(-e^(I*f* 
x + I*e)) - 4*(a*b*d*cos(2*f*x + 2*e) + I*a*b*d*sin(2*f*x + 2*e) - a*b*d)* 
dilog(e^(I*f*x + I*e)) + (2*I*(f*x + e)*a*b*d + I*b^2*d + (-2*I*(f*x + e)* 
a*b*d - I*b^2*d)*cos(2*f*x + 2*e) + (2*(f*x + e)*a*b*d + b^2*d)*sin(2*f*x 
+ 2*e))*log(cos(f*x + e)^2 + sin(f*x + e)^2 + 2*cos(f*x + e) + 1) + (2*I*( 
f*x + e)*a*b*d + I*b^2*d + (-2*I*(f*x + e)*a*b*d - I*b^2*d)*cos(2*f*x + 2* 
e) + (2*(f*x + e)*a*b*d + b^2*d)*sin(2*f*x + 2*e))*log(cos(f*x + e)^2 + si 
n(f*x + e)^2 - 2*cos(f*x + e) + 1) + ((-2*I*a*b - b^2)*(f*x + e)^2*d + 2*( 
b^2*d*e - b^2*c*f - 2*I*b^2*d)*(f*x + e))*sin(2*f*x + 2*e))/(-2*I*f*cos(2* 
f*x + 2*e) + 2*f*sin(2*f*x + 2*e) + 2*I*f))/f
 

Giac [F]

\[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\int { {\left (d x + c\right )} {\left (b \cot \left (f x + e\right ) + a\right )}^{2} \,d x } \] Input:

integrate((d*x+c)*(a+b*cot(f*x+e))^2,x, algorithm="giac")
 

Output:

integrate((d*x + c)*(b*cot(f*x + e) + a)^2, x)
 

Mupad [F(-1)]

Timed out. \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\int {\left (a+b\,\mathrm {cot}\left (e+f\,x\right )\right )}^2\,\left (c+d\,x\right ) \,d x \] Input:

int((a + b*cot(e + f*x))^2*(c + d*x),x)
 

Output:

int((a + b*cot(e + f*x))^2*(c + d*x), x)
 

Reduce [F]

\[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\frac {-2 \cos \left (f x +e \right ) b^{2} d f x -2 \cot \left (f x +e \right ) \sin \left (f x +e \right ) b^{2} c f +4 \left (\int \cot \left (f x +e \right ) x d x \right ) \sin \left (f x +e \right ) a b d \,f^{2}-4 \,\mathrm {log}\left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2}+1\right ) \sin \left (f x +e \right ) a b c f -2 \,\mathrm {log}\left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2}+1\right ) \sin \left (f x +e \right ) b^{2} d +4 \,\mathrm {log}\left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right ) \sin \left (f x +e \right ) a b c f +2 \,\mathrm {log}\left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right ) \sin \left (f x +e \right ) b^{2} d +2 \sin \left (f x +e \right ) a^{2} c \,f^{2} x +\sin \left (f x +e \right ) a^{2} d \,f^{2} x^{2}-2 \sin \left (f x +e \right ) b^{2} c \,f^{2} x -\sin \left (f x +e \right ) b^{2} d \,f^{2} x^{2}}{2 \sin \left (f x +e \right ) f^{2}} \] Input:

int((d*x+c)*(a+b*cot(f*x+e))^2,x)
 

Output:

( - 2*cos(e + f*x)*b**2*d*f*x - 2*cot(e + f*x)*sin(e + f*x)*b**2*c*f + 4*i 
nt(cot(e + f*x)*x,x)*sin(e + f*x)*a*b*d*f**2 - 4*log(tan((e + f*x)/2)**2 + 
 1)*sin(e + f*x)*a*b*c*f - 2*log(tan((e + f*x)/2)**2 + 1)*sin(e + f*x)*b** 
2*d + 4*log(tan((e + f*x)/2))*sin(e + f*x)*a*b*c*f + 2*log(tan((e + f*x)/2 
))*sin(e + f*x)*b**2*d + 2*sin(e + f*x)*a**2*c*f**2*x + sin(e + f*x)*a**2* 
d*f**2*x**2 - 2*sin(e + f*x)*b**2*c*f**2*x - sin(e + f*x)*b**2*d*f**2*x**2 
)/(2*sin(e + f*x)*f**2)