\(\int (\cot (x)+\csc (x))^4 \, dx\) [294]

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

Optimal result

Integrand size = 7, antiderivative size = 30 \[ \int (\cot (x)+\csc (x))^4 \, dx=x+\frac {2 \sin (x)}{1-\cos (x)}-\frac {2 \sin ^3(x)}{3 (1-\cos (x))^3} \]

[Out]

x+2*sin(x)/(1-cos(x))-2/3*sin(x)^3/(1-cos(x))^3

Rubi [A] (verified)

Time = 0.12 (sec) , antiderivative size = 30, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.571, Rules used = {4477, 2749, 2759, 8} \[ \int (\cot (x)+\csc (x))^4 \, dx=x-\frac {2 \sin ^3(x)}{3 (1-\cos (x))^3}+\frac {2 \sin (x)}{1-\cos (x)} \]

[In]

Int[(Cot[x] + Csc[x])^4,x]

[Out]

x + (2*Sin[x])/(1 - Cos[x]) - (2*Sin[x]^3)/(3*(1 - Cos[x])^3)

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 2749

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> Dist[(a/g)^
(2*m), Int[(g*Cos[e + f*x])^(2*m + p)/(a - b*Sin[e + f*x])^m, x], x] /; FreeQ[{a, b, e, f, g}, x] && EqQ[a^2 -
 b^2, 0] && IntegerQ[m] && LtQ[p, -1] && GeQ[2*m + p, 0]

Rule 2759

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> Simp[2*g*(g
*Cos[e + f*x])^(p - 1)*((a + b*Sin[e + f*x])^(m + 1)/(b*f*(2*m + p + 1))), x] + Dist[g^2*((p - 1)/(b^2*(2*m +
p + 1))), Int[(g*Cos[e + f*x])^(p - 2)*(a + b*Sin[e + f*x])^(m + 2), x], x] /; FreeQ[{a, b, e, f, g}, x] && Eq
Q[a^2 - b^2, 0] && LeQ[m, -2] && GtQ[p, 1] && NeQ[2*m + p + 1, 0] &&  !ILtQ[m + p + 1, 0] && IntegersQ[2*m, 2*
p]

Rule 4477

Int[(cot[(c_.) + (d_.)*(x_)]^(n_.)*(a_.) + csc[(c_.) + (d_.)*(x_)]^(n_.)*(b_.))^(p_)*(u_.), x_Symbol] :> Int[A
ctivateTrig[u]*Csc[c + d*x]^(n*p)*(b + a*Cos[c + d*x]^n)^p, x] /; FreeQ[{a, b, c, d}, x] && IntegersQ[n, p]

Rubi steps \begin{align*} \text {integral}& = \int (1+\cos (x))^4 \csc ^4(x) \, dx \\ & = \int \frac {\sin ^4(x)}{(1-\cos (x))^4} \, dx \\ & = -\frac {2 \sin ^3(x)}{3 (1-\cos (x))^3}-\int \frac {\sin ^2(x)}{(1-\cos (x))^2} \, dx \\ & = \frac {2 \sin (x)}{1-\cos (x)}-\frac {2 \sin ^3(x)}{3 (1-\cos (x))^3}+\int 1 \, dx \\ & = x+\frac {2 \sin (x)}{1-\cos (x)}-\frac {2 \sin ^3(x)}{3 (1-\cos (x))^3} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.05 (sec) , antiderivative size = 30, normalized size of antiderivative = 1.00 \[ \int (\cot (x)+\csc (x))^4 \, dx=x+\frac {8}{3} \cot \left (\frac {x}{2}\right )-\frac {2}{3} \cot \left (\frac {x}{2}\right ) \csc ^2\left (\frac {x}{2}\right ) \]

[In]

Integrate[(Cot[x] + Csc[x])^4,x]

[Out]

x + (8*Cot[x/2])/3 - (2*Cot[x/2]*Csc[x/2]^2)/3

Maple [C] (verified)

Result contains complex when optimal does not.

Time = 1.66 (sec) , antiderivative size = 31, normalized size of antiderivative = 1.03

method result size
risch \(x +\frac {8 i \left (3 \,{\mathrm e}^{2 i x}-3 \,{\mathrm e}^{i x}+2\right )}{3 \left ({\mathrm e}^{i x}-1\right )^{3}}\) \(31\)
parts \(-\frac {7 \cot \left (x \right )^{3}}{3}+\cot \left (x \right )-\frac {\pi }{2}+\operatorname {arccot}\left (\cot \left (x \right )\right )+\left (-\frac {2}{3}-\frac {\csc \left (x \right )^{2}}{3}\right ) \cot \left (x \right )-\frac {8 \csc \left (x \right )^{3}}{3}+4 \csc \left (x \right )\) \(37\)
default \(-\frac {\cot \left (x \right )^{3}}{3}+\cot \left (x \right )+x -\frac {4 \cos \left (x \right )^{4}}{3 \sin \left (x \right )^{3}}+\frac {4 \cos \left (x \right )^{4}}{3 \sin \left (x \right )}+\frac {4 \left (2+\cos \left (x \right )^{2}\right ) \sin \left (x \right )}{3}-\frac {2 \cos \left (x \right )^{3}}{\sin \left (x \right )^{3}}-\frac {4}{3 \sin \left (x \right )^{3}}+\left (-\frac {2}{3}-\frac {\csc \left (x \right )^{2}}{3}\right ) \cot \left (x \right )\) \(68\)

[In]

int((cot(x)+csc(x))^4,x,method=_RETURNVERBOSE)

[Out]

x+8/3*I*(3*exp(2*I*x)-3*exp(I*x)+2)/(exp(I*x)-1)^3

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 36, normalized size of antiderivative = 1.20 \[ \int (\cot (x)+\csc (x))^4 \, dx=\frac {8 \, \cos \left (x\right )^{2} + 3 \, {\left (x \cos \left (x\right ) - x\right )} \sin \left (x\right ) + 4 \, \cos \left (x\right ) - 4}{3 \, {\left (\cos \left (x\right ) - 1\right )} \sin \left (x\right )} \]

[In]

integrate((cot(x)+csc(x))^4,x, algorithm="fricas")

[Out]

1/3*(8*cos(x)^2 + 3*(x*cos(x) - x)*sin(x) + 4*cos(x) - 4)/((cos(x) - 1)*sin(x))

Sympy [A] (verification not implemented)

Time = 34.61 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.47 \[ \int (\cot (x)+\csc (x))^4 \, dx=x - \frac {7 \cot ^{3}{\left (x \right )}}{3} - \cot {\left (x \right )} - \frac {8 \csc ^{3}{\left (x \right )}}{3} + 4 \csc {\left (x \right )} + \frac {\cos {\left (x \right )}}{\sin {\left (x \right )}} - \frac {\cos ^{3}{\left (x \right )}}{3 \sin ^{3}{\left (x \right )}} \]

[In]

integrate((cot(x)+csc(x))**4,x)

[Out]

x - 7*cot(x)**3/3 - cot(x) - 8*csc(x)**3/3 + 4*csc(x) + cos(x)/sin(x) - cos(x)**3/(3*sin(x)**3)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 56 vs. \(2 (24) = 48\).

Time = 0.30 (sec) , antiderivative size = 56, normalized size of antiderivative = 1.87 \[ \int (\cot (x)+\csc (x))^4 \, dx=-2 \, \cot \left (x\right )^{3} + x + \frac {4 \, {\left (3 \, \sin \left (x\right )^{2} - 1\right )}}{3 \, \sin \left (x\right )^{3}} - \frac {3 \, \tan \left (x\right )^{2} + 1}{3 \, \tan \left (x\right )^{3}} + \frac {3 \, \tan \left (x\right )^{2} - 1}{3 \, \tan \left (x\right )^{3}} - \frac {4}{3 \, \sin \left (x\right )^{3}} \]

[In]

integrate((cot(x)+csc(x))^4,x, algorithm="maxima")

[Out]

-2*cot(x)^3 + x + 4/3*(3*sin(x)^2 - 1)/sin(x)^3 - 1/3*(3*tan(x)^2 + 1)/tan(x)^3 + 1/3*(3*tan(x)^2 - 1)/tan(x)^
3 - 4/3/sin(x)^3

Giac [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 20, normalized size of antiderivative = 0.67 \[ \int (\cot (x)+\csc (x))^4 \, dx=x + \frac {2 \, {\left (3 \, \tan \left (\frac {1}{2} \, x\right )^{2} - 1\right )}}{3 \, \tan \left (\frac {1}{2} \, x\right )^{3}} \]

[In]

integrate((cot(x)+csc(x))^4,x, algorithm="giac")

[Out]

x + 2/3*(3*tan(1/2*x)^2 - 1)/tan(1/2*x)^3

Mupad [B] (verification not implemented)

Time = 27.68 (sec) , antiderivative size = 16, normalized size of antiderivative = 0.53 \[ \int (\cot (x)+\csc (x))^4 \, dx=-\frac {2\,{\mathrm {cot}\left (\frac {x}{2}\right )}^3}{3}+2\,\mathrm {cot}\left (\frac {x}{2}\right )+x \]

[In]

int((cot(x) + 1/sin(x))^4,x)

[Out]

x + 2*cot(x/2) - (2*cot(x/2)^3)/3