\(\int \frac {(a+b \cot (x))^3 \csc ^2(x)}{c+d \cot (x)} \, dx\) [722]

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

Optimal result

Integrand size = 21, antiderivative size = 78 \[ \int \frac {(a+b \cot (x))^3 \csc ^2(x)}{c+d \cot (x)} \, dx=-\frac {b (b c-a d)^2 \cot (x)}{d^3}+\frac {(b c-a d) (a+b \cot (x))^2}{2 d^2}-\frac {(a+b \cot (x))^3}{3 d}+\frac {(b c-a d)^3 \log (c+d \cot (x))}{d^4} \]

[Out]

-b*(-a*d+b*c)^2*cot(x)/d^3+1/2*(-a*d+b*c)*(a+b*cot(x))^2/d^2-1/3*(a+b*cot(x))^3/d+(-a*d+b*c)^3*ln(c+d*cot(x))/
d^4

Rubi [A] (verified)

Time = 0.15 (sec) , antiderivative size = 78, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.095, Rules used = {4429, 45} \[ \int \frac {(a+b \cot (x))^3 \csc ^2(x)}{c+d \cot (x)} \, dx=\frac {(b c-a d)^3 \log (c+d \cot (x))}{d^4}-\frac {b \cot (x) (b c-a d)^2}{d^3}+\frac {(b c-a d) (a+b \cot (x))^2}{2 d^2}-\frac {(a+b \cot (x))^3}{3 d} \]

[In]

Int[((a + b*Cot[x])^3*Csc[x]^2)/(c + d*Cot[x]),x]

[Out]

-((b*(b*c - a*d)^2*Cot[x])/d^3) + ((b*c - a*d)*(a + b*Cot[x])^2)/(2*d^2) - (a + b*Cot[x])^3/(3*d) + ((b*c - a*
d)^3*Log[c + d*Cot[x]])/d^4

Rule 45

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_.), x_Symbol] :> Int[ExpandIntegrand[(a + b*x)^m*(c + d
*x)^n, x], x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0] && IGtQ[m, 0] && ( !IntegerQ[n] || (EqQ[c, 0]
&& LeQ[7*m + 4*n + 4, 0]) || LtQ[9*m + 5*(n + 1), 0] || GtQ[m + n + 2, 0])

Rule 4429

Int[(u_)*(F_)[(c_.)*((a_.) + (b_.)*(x_))]^2, x_Symbol] :> With[{d = FreeFactors[Cot[c*(a + b*x)], x]}, Dist[-d
/(b*c), Subst[Int[SubstFor[1, Cot[c*(a + b*x)]/d, u, x], x], x, Cot[c*(a + b*x)]/d], x] /; FunctionOfQ[Cot[c*(
a + b*x)]/d, u, x, True]] /; FreeQ[{a, b, c}, x] && NonsumQ[u] && (EqQ[F, Csc] || EqQ[F, csc])

Rubi steps \begin{align*} \text {integral}& = -\text {Subst}\left (\int \frac {(a+b x)^3}{c+d x} \, dx,x,\cot (x)\right ) \\ & = -\text {Subst}\left (\int \left (\frac {b (b c-a d)^2}{d^3}-\frac {b (b c-a d) (a+b x)}{d^2}+\frac {b (a+b x)^2}{d}+\frac {(-b c+a d)^3}{d^3 (c+d x)}\right ) \, dx,x,\cot (x)\right ) \\ & = -\frac {b (b c-a d)^2 \cot (x)}{d^3}+\frac {(b c-a d) (a+b \cot (x))^2}{2 d^2}-\frac {(a+b \cot (x))^3}{3 d}+\frac {(b c-a d)^3 \log (c+d \cot (x))}{d^4} \\ \end{align*}

Mathematica [A] (verified)

Time = 3.08 (sec) , antiderivative size = 135, normalized size of antiderivative = 1.73 \[ \int \frac {(a+b \cot (x))^3 \csc ^2(x)}{c+d \cot (x)} \, dx=\frac {(a+b \cot (x))^3 (d \cos (x)+c \sin (x)) \left (-2 b^3 d^3 \cot (x)-6 (b c-a d)^3 (\log (\sin (x))-\log (d \cos (x)+c \sin (x))) \sin ^2(x)+b d \left (3 b d (b c-3 a d)+\left (9 a b c d-9 a^2 d^2+b^2 \left (-3 c^2+d^2\right )\right ) \sin (2 x)\right )\right )}{6 d^4 (c+d \cot (x)) (b \cos (x)+a \sin (x))^3} \]

[In]

Integrate[((a + b*Cot[x])^3*Csc[x]^2)/(c + d*Cot[x]),x]

[Out]

((a + b*Cot[x])^3*(d*Cos[x] + c*Sin[x])*(-2*b^3*d^3*Cot[x] - 6*(b*c - a*d)^3*(Log[Sin[x]] - Log[d*Cos[x] + c*S
in[x]])*Sin[x]^2 + b*d*(3*b*d*(b*c - 3*a*d) + (9*a*b*c*d - 9*a^2*d^2 + b^2*(-3*c^2 + d^2))*Sin[2*x])))/(6*d^4*
(c + d*Cot[x])*(b*Cos[x] + a*Sin[x])^3)

Maple [A] (verified)

Time = 1.17 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.51

method result size
derivativedivides \(-\frac {b \left (\frac {b^{2} \cot \left (x \right )^{3} d^{2}}{3}+\frac {3 a b \,d^{2} \cot \left (x \right )^{2}}{2}-\frac {b^{2} c d \cot \left (x \right )^{2}}{2}+3 \cot \left (x \right ) d^{2} a^{2}-3 \cot \left (x \right ) c d a b +\cot \left (x \right ) b^{2} c^{2}\right )}{d^{3}}-\frac {\left (d^{3} a^{3}-3 c \,d^{2} a^{2} b +3 c^{2} d a \,b^{2}-b^{3} c^{3}\right ) \ln \left (c +d \cot \left (x \right )\right )}{d^{4}}\) \(118\)
default \(-\frac {b \left (\frac {b^{2} \cot \left (x \right )^{3} d^{2}}{3}+\frac {3 a b \,d^{2} \cot \left (x \right )^{2}}{2}-\frac {b^{2} c d \cot \left (x \right )^{2}}{2}+3 \cot \left (x \right ) d^{2} a^{2}-3 \cot \left (x \right ) c d a b +\cot \left (x \right ) b^{2} c^{2}\right )}{d^{3}}-\frac {\left (d^{3} a^{3}-3 c \,d^{2} a^{2} b +3 c^{2} d a \,b^{2}-b^{3} c^{3}\right ) \ln \left (c +d \cot \left (x \right )\right )}{d^{4}}\) \(118\)
risch \(-\frac {2 i b \left (9 a^{2} d^{2} {\mathrm e}^{4 i x}-9 a b c d \,{\mathrm e}^{4 i x}+3 b^{2} c^{2} {\mathrm e}^{4 i x}-3 b^{2} d^{2} {\mathrm e}^{4 i x}+9 i a b \,d^{2} {\mathrm e}^{4 i x}-3 i b^{2} c d \,{\mathrm e}^{4 i x}-18 a^{2} d^{2} {\mathrm e}^{2 i x}+18 a b c d \,{\mathrm e}^{2 i x}-6 b^{2} c^{2} {\mathrm e}^{2 i x}-9 i a b \,d^{2} {\mathrm e}^{2 i x}+3 i b^{2} c d \,{\mathrm e}^{2 i x}+9 d^{2} a^{2}-9 c d a b +3 b^{2} c^{2}-b^{2} d^{2}\right )}{3 d^{3} \left ({\mathrm e}^{2 i x}-1\right )^{3}}+\frac {\ln \left ({\mathrm e}^{2 i x}-1\right ) a^{3}}{d}-\frac {3 \ln \left ({\mathrm e}^{2 i x}-1\right ) c \,a^{2} b}{d^{2}}+\frac {3 \ln \left ({\mathrm e}^{2 i x}-1\right ) c^{2} a \,b^{2}}{d^{3}}-\frac {\ln \left ({\mathrm e}^{2 i x}-1\right ) b^{3} c^{3}}{d^{4}}-\frac {\ln \left ({\mathrm e}^{2 i x}+\frac {i d -c}{i d +c}\right ) a^{3}}{d}+\frac {3 \ln \left ({\mathrm e}^{2 i x}+\frac {i d -c}{i d +c}\right ) c \,a^{2} b}{d^{2}}-\frac {3 \ln \left ({\mathrm e}^{2 i x}+\frac {i d -c}{i d +c}\right ) c^{2} a \,b^{2}}{d^{3}}+\frac {\ln \left ({\mathrm e}^{2 i x}+\frac {i d -c}{i d +c}\right ) b^{3} c^{3}}{d^{4}}\) \(396\)

[In]

int((a+b*cot(x))^3*csc(x)^2/(c+d*cot(x)),x,method=_RETURNVERBOSE)

[Out]

-b/d^3*(1/3*b^2*cot(x)^3*d^2+3/2*a*b*d^2*cot(x)^2-1/2*b^2*c*d*cot(x)^2+3*cot(x)*d^2*a^2-3*cot(x)*c*d*a*b+cot(x
)*b^2*c^2)-(a^3*d^3-3*a^2*b*c*d^2+3*a*b^2*c^2*d-b^3*c^3)/d^4*ln(c+d*cot(x))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 320 vs. \(2 (74) = 148\).

Time = 0.29 (sec) , antiderivative size = 320, normalized size of antiderivative = 4.10 \[ \int \frac {(a+b \cot (x))^3 \csc ^2(x)}{c+d \cot (x)} \, dx=-\frac {2 \, {\left (3 \, b^{3} c^{2} d - 9 \, a b^{2} c d^{2} + {\left (9 \, a^{2} b - b^{3}\right )} d^{3}\right )} \cos \left (x\right )^{3} + 3 \, {\left (b^{3} c^{3} - 3 \, a b^{2} c^{2} d + 3 \, a^{2} b c d^{2} - a^{3} d^{3} - {\left (b^{3} c^{3} - 3 \, a b^{2} c^{2} d + 3 \, a^{2} b c d^{2} - a^{3} d^{3}\right )} \cos \left (x\right )^{2}\right )} \log \left (2 \, c d \cos \left (x\right ) \sin \left (x\right ) - {\left (c^{2} - d^{2}\right )} \cos \left (x\right )^{2} + c^{2}\right ) \sin \left (x\right ) - 3 \, {\left (b^{3} c^{3} - 3 \, a b^{2} c^{2} d + 3 \, a^{2} b c d^{2} - a^{3} d^{3} - {\left (b^{3} c^{3} - 3 \, a b^{2} c^{2} d + 3 \, a^{2} b c d^{2} - a^{3} d^{3}\right )} \cos \left (x\right )^{2}\right )} \log \left (-\frac {1}{4} \, \cos \left (x\right )^{2} + \frac {1}{4}\right ) \sin \left (x\right ) - 6 \, {\left (b^{3} c^{2} d - 3 \, a b^{2} c d^{2} + 3 \, a^{2} b d^{3}\right )} \cos \left (x\right ) + 3 \, {\left (b^{3} c d^{2} - 3 \, a b^{2} d^{3}\right )} \sin \left (x\right )}{6 \, {\left (d^{4} \cos \left (x\right )^{2} - d^{4}\right )} \sin \left (x\right )} \]

[In]

integrate((a+b*cot(x))^3*csc(x)^2/(c+d*cot(x)),x, algorithm="fricas")

[Out]

-1/6*(2*(3*b^3*c^2*d - 9*a*b^2*c*d^2 + (9*a^2*b - b^3)*d^3)*cos(x)^3 + 3*(b^3*c^3 - 3*a*b^2*c^2*d + 3*a^2*b*c*
d^2 - a^3*d^3 - (b^3*c^3 - 3*a*b^2*c^2*d + 3*a^2*b*c*d^2 - a^3*d^3)*cos(x)^2)*log(2*c*d*cos(x)*sin(x) - (c^2 -
 d^2)*cos(x)^2 + c^2)*sin(x) - 3*(b^3*c^3 - 3*a*b^2*c^2*d + 3*a^2*b*c*d^2 - a^3*d^3 - (b^3*c^3 - 3*a*b^2*c^2*d
 + 3*a^2*b*c*d^2 - a^3*d^3)*cos(x)^2)*log(-1/4*cos(x)^2 + 1/4)*sin(x) - 6*(b^3*c^2*d - 3*a*b^2*c*d^2 + 3*a^2*b
*d^3)*cos(x) + 3*(b^3*c*d^2 - 3*a*b^2*d^3)*sin(x))/((d^4*cos(x)^2 - d^4)*sin(x))

Sympy [A] (verification not implemented)

Time = 33.51 (sec) , antiderivative size = 97, normalized size of antiderivative = 1.24 \[ \int \frac {(a+b \cot (x))^3 \csc ^2(x)}{c+d \cot (x)} \, dx=- \frac {b^{3} \cot ^{3}{\left (x \right )}}{3 d} - \frac {\left (3 a b^{2} d - b^{3} c\right ) \cot ^{2}{\left (x \right )}}{2 d^{2}} - \frac {\left (a d - b c\right )^{3} \left (\begin {cases} \frac {\cot {\left (x \right )}}{c} & \text {for}\: d = 0 \\\frac {\log {\left (c + d \cot {\left (x \right )} \right )}}{d} & \text {otherwise} \end {cases}\right )}{d^{3}} - \frac {\left (3 a^{2} b d^{2} - 3 a b^{2} c d + b^{3} c^{2}\right ) \cot {\left (x \right )}}{d^{3}} \]

[In]

integrate((a+b*cot(x))**3*csc(x)**2/(c+d*cot(x)),x)

[Out]

-b**3*cot(x)**3/(3*d) - (3*a*b**2*d - b**3*c)*cot(x)**2/(2*d**2) - (a*d - b*c)**3*Piecewise((cot(x)/c, Eq(d, 0
)), (log(c + d*cot(x))/d, True))/d**3 - (3*a**2*b*d**2 - 3*a*b**2*c*d + b**3*c**2)*cot(x)/d**3

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 161 vs. \(2 (74) = 148\).

Time = 0.22 (sec) , antiderivative size = 161, normalized size of antiderivative = 2.06 \[ \int \frac {(a+b \cot (x))^3 \csc ^2(x)}{c+d \cot (x)} \, dx=\frac {{\left (b^{3} c^{3} - 3 \, a b^{2} c^{2} d + 3 \, a^{2} b c d^{2} - a^{3} d^{3}\right )} \log \left (c \tan \left (x\right ) + d\right )}{d^{4}} - \frac {{\left (b^{3} c^{3} - 3 \, a b^{2} c^{2} d + 3 \, a^{2} b c d^{2} - a^{3} d^{3}\right )} \log \left (\tan \left (x\right )\right )}{d^{4}} - \frac {2 \, b^{3} d^{2} + 6 \, {\left (b^{3} c^{2} - 3 \, a b^{2} c d + 3 \, a^{2} b d^{2}\right )} \tan \left (x\right )^{2} - 3 \, {\left (b^{3} c d - 3 \, a b^{2} d^{2}\right )} \tan \left (x\right )}{6 \, d^{3} \tan \left (x\right )^{3}} \]

[In]

integrate((a+b*cot(x))^3*csc(x)^2/(c+d*cot(x)),x, algorithm="maxima")

[Out]

(b^3*c^3 - 3*a*b^2*c^2*d + 3*a^2*b*c*d^2 - a^3*d^3)*log(c*tan(x) + d)/d^4 - (b^3*c^3 - 3*a*b^2*c^2*d + 3*a^2*b
*c*d^2 - a^3*d^3)*log(tan(x))/d^4 - 1/6*(2*b^3*d^2 + 6*(b^3*c^2 - 3*a*b^2*c*d + 3*a^2*b*d^2)*tan(x)^2 - 3*(b^3
*c*d - 3*a*b^2*d^2)*tan(x))/(d^3*tan(x)^3)

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 232 vs. \(2 (74) = 148\).

Time = 0.29 (sec) , antiderivative size = 232, normalized size of antiderivative = 2.97 \[ \int \frac {(a+b \cot (x))^3 \csc ^2(x)}{c+d \cot (x)} \, dx=-\frac {{\left (b^{3} c^{3} - 3 \, a b^{2} c^{2} d + 3 \, a^{2} b c d^{2} - a^{3} d^{3}\right )} \log \left ({\left | \tan \left (x\right ) \right |}\right )}{d^{4}} + \frac {{\left (b^{3} c^{4} - 3 \, a b^{2} c^{3} d + 3 \, a^{2} b c^{2} d^{2} - a^{3} c d^{3}\right )} \log \left ({\left | c \tan \left (x\right ) + d \right |}\right )}{c d^{4}} + \frac {11 \, b^{3} c^{3} \tan \left (x\right )^{3} - 33 \, a b^{2} c^{2} d \tan \left (x\right )^{3} + 33 \, a^{2} b c d^{2} \tan \left (x\right )^{3} - 11 \, a^{3} d^{3} \tan \left (x\right )^{3} - 6 \, b^{3} c^{2} d \tan \left (x\right )^{2} + 18 \, a b^{2} c d^{2} \tan \left (x\right )^{2} - 18 \, a^{2} b d^{3} \tan \left (x\right )^{2} + 3 \, b^{3} c d^{2} \tan \left (x\right ) - 9 \, a b^{2} d^{3} \tan \left (x\right ) - 2 \, b^{3} d^{3}}{6 \, d^{4} \tan \left (x\right )^{3}} \]

[In]

integrate((a+b*cot(x))^3*csc(x)^2/(c+d*cot(x)),x, algorithm="giac")

[Out]

-(b^3*c^3 - 3*a*b^2*c^2*d + 3*a^2*b*c*d^2 - a^3*d^3)*log(abs(tan(x)))/d^4 + (b^3*c^4 - 3*a*b^2*c^3*d + 3*a^2*b
*c^2*d^2 - a^3*c*d^3)*log(abs(c*tan(x) + d))/(c*d^4) + 1/6*(11*b^3*c^3*tan(x)^3 - 33*a*b^2*c^2*d*tan(x)^3 + 33
*a^2*b*c*d^2*tan(x)^3 - 11*a^3*d^3*tan(x)^3 - 6*b^3*c^2*d*tan(x)^2 + 18*a*b^2*c*d^2*tan(x)^2 - 18*a^2*b*d^3*ta
n(x)^2 + 3*b^3*c*d^2*tan(x) - 9*a*b^2*d^3*tan(x) - 2*b^3*d^3)/(d^4*tan(x)^3)

Mupad [B] (verification not implemented)

Time = 26.51 (sec) , antiderivative size = 141, normalized size of antiderivative = 1.81 \[ \int \frac {(a+b \cot (x))^3 \csc ^2(x)}{c+d \cot (x)} \, dx=-\frac {\frac {b^3}{3\,d}+\frac {b^2\,\mathrm {tan}\left (x\right )\,\left (3\,a\,d-b\,c\right )}{2\,d^2}+\frac {b\,{\mathrm {tan}\left (x\right )}^2\,\left (3\,a^2\,d^2-3\,a\,b\,c\,d+b^2\,c^2\right )}{d^3}}{{\mathrm {tan}\left (x\right )}^3}-\frac {2\,\mathrm {atanh}\left (\frac {\left (d+2\,c\,\mathrm {tan}\left (x\right )\right )\,{\left (a\,d-b\,c\right )}^3}{d\,\left (a^3\,d^3-3\,a^2\,b\,c\,d^2+3\,a\,b^2\,c^2\,d-b^3\,c^3\right )}\right )\,{\left (a\,d-b\,c\right )}^3}{d^4} \]

[In]

int((a + b*cot(x))^3/(sin(x)^2*(c + d*cot(x))),x)

[Out]

- (b^3/(3*d) + (b^2*tan(x)*(3*a*d - b*c))/(2*d^2) + (b*tan(x)^2*(3*a^2*d^2 + b^2*c^2 - 3*a*b*c*d))/d^3)/tan(x)
^3 - (2*atanh(((d + 2*c*tan(x))*(a*d - b*c)^3)/(d*(a^3*d^3 - b^3*c^3 + 3*a*b^2*c^2*d - 3*a^2*b*c*d^2)))*(a*d -
 b*c)^3)/d^4