\(\int \frac {1}{(\sin (x)+\tan (x))^2} \, dx\) [346]

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

Optimal result

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

[Out]

-1/3*cot(x)^3-2/5*cot(x)^5-2/3*csc(x)^3+2/5*csc(x)^5

Rubi [A] (verified)

Time = 0.15 (sec) , antiderivative size = 33, normalized size of antiderivative = 1.00, number of steps used = 11, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.857, Rules used = {4482, 2790, 2687, 30, 2686, 14} \[ \int \frac {1}{(\sin (x)+\tan (x))^2} \, dx=-\frac {2}{5} \cot ^5(x)-\frac {\cot ^3(x)}{3}+\frac {2 \csc ^5(x)}{5}-\frac {2 \csc ^3(x)}{3} \]

[In]

Int[(Sin[x] + Tan[x])^(-2),x]

[Out]

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

Rule 14

Int[(u_)*((c_.)*(x_))^(m_.), x_Symbol] :> Int[ExpandIntegrand[(c*x)^m*u, x], x] /; FreeQ[{c, m}, x] && SumQ[u]
 &&  !LinearQ[u, x] &&  !MatchQ[u, (a_) + (b_.)*(v_) /; FreeQ[{a, b}, x] && InverseFunctionQ[v]]

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 2686

Int[((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a/f, Subst[
Int[(a*x)^(m - 1)*(-1 + x^2)^((n - 1)/2), x], x, Sec[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n -
1)/2] &&  !(IntegerQ[m/2] && LtQ[0, m, n + 1])

Rule 2687

Int[sec[(e_.) + (f_.)*(x_)]^(m_)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[1/f, Subst[Int[(b*x)
^n*(1 + x^2)^(m/2 - 1), x], x, Tan[e + f*x]], x] /; FreeQ[{b, e, f, n}, x] && IntegerQ[m/2] &&  !(IntegerQ[(n
- 1)/2] && LtQ[0, n, m - 1])

Rule 2790

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((g_.)*tan[(e_.) + (f_.)*(x_)])^(p_.), x_Symbol] :> Dist[a^(2*
m), Int[ExpandIntegrand[(g*Tan[e + f*x])^p/Sec[e + f*x]^m, (a*Sec[e + f*x] - b*Tan[e + f*x])^(-m), x], x], x]
/; FreeQ[{a, b, e, f, g, p}, x] && EqQ[a^2 - b^2, 0] && ILtQ[m, 0]

Rule 4482

Int[u_, x_Symbol] :> Int[TrigSimplify[u], x] /; TrigSimplifyQ[u]

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

Mathematica [A] (verified)

Time = 0.02 (sec) , antiderivative size = 57, normalized size of antiderivative = 1.73 \[ \int \frac {1}{(\sin (x)+\tan (x))^2} \, dx=-\frac {1}{8} \cot \left (\frac {x}{2}\right )-\frac {7}{120} \tan \left (\frac {x}{2}\right )-\frac {11}{120} \sec ^2\left (\frac {x}{2}\right ) \tan \left (\frac {x}{2}\right )+\frac {1}{40} \sec ^4\left (\frac {x}{2}\right ) \tan \left (\frac {x}{2}\right ) \]

[In]

Integrate[(Sin[x] + Tan[x])^(-2),x]

[Out]

-1/8*Cot[x/2] - (7*Tan[x/2])/120 - (11*Sec[x/2]^2*Tan[x/2])/120 + (Sec[x/2]^4*Tan[x/2])/40

Maple [A] (verified)

Time = 0.59 (sec) , antiderivative size = 32, normalized size of antiderivative = 0.97

method result size
default \(\frac {\tan \left (\frac {x}{2}\right )^{5}}{40}-\frac {\tan \left (\frac {x}{2}\right )^{3}}{24}-\frac {\tan \left (\frac {x}{2}\right )}{8}-\frac {1}{8 \tan \left (\frac {x}{2}\right )}\) \(32\)
risch \(-\frac {2 i \left (15 \,{\mathrm e}^{4 i x}+20 \,{\mathrm e}^{3 i x}+20 \,{\mathrm e}^{2 i x}+4 \,{\mathrm e}^{i x}+1\right )}{15 \left ({\mathrm e}^{i x}+1\right )^{5} \left ({\mathrm e}^{i x}-1\right )}\) \(52\)

[In]

int(1/(sin(x)+tan(x))^2,x,method=_RETURNVERBOSE)

[Out]

1/40*tan(1/2*x)^5-1/24*tan(1/2*x)^3-1/8*tan(1/2*x)-1/8/tan(1/2*x)

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 34, normalized size of antiderivative = 1.03 \[ \int \frac {1}{(\sin (x)+\tan (x))^2} \, dx=-\frac {\cos \left (x\right )^{3} + 2 \, \cos \left (x\right )^{2} + 8 \, \cos \left (x\right ) + 4}{15 \, {\left (\cos \left (x\right )^{2} + 2 \, \cos \left (x\right ) + 1\right )} \sin \left (x\right )} \]

[In]

integrate(1/(sin(x)+tan(x))^2,x, algorithm="fricas")

[Out]

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

Sympy [F]

\[ \int \frac {1}{(\sin (x)+\tan (x))^2} \, dx=\int \frac {1}{\left (\sin {\left (x \right )} + \tan {\left (x \right )}\right )^{2}}\, dx \]

[In]

integrate(1/(sin(x)+tan(x))**2,x)

[Out]

Integral((sin(x) + tan(x))**(-2), x)

Maxima [A] (verification not implemented)

none

Time = 0.22 (sec) , antiderivative size = 45, normalized size of antiderivative = 1.36 \[ \int \frac {1}{(\sin (x)+\tan (x))^2} \, dx=-\frac {\cos \left (x\right ) + 1}{8 \, \sin \left (x\right )} - \frac {\sin \left (x\right )}{8 \, {\left (\cos \left (x\right ) + 1\right )}} - \frac {\sin \left (x\right )^{3}}{24 \, {\left (\cos \left (x\right ) + 1\right )}^{3}} + \frac {\sin \left (x\right )^{5}}{40 \, {\left (\cos \left (x\right ) + 1\right )}^{5}} \]

[In]

integrate(1/(sin(x)+tan(x))^2,x, algorithm="maxima")

[Out]

-1/8*(cos(x) + 1)/sin(x) - 1/8*sin(x)/(cos(x) + 1) - 1/24*sin(x)^3/(cos(x) + 1)^3 + 1/40*sin(x)^5/(cos(x) + 1)
^5

Giac [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 31, normalized size of antiderivative = 0.94 \[ \int \frac {1}{(\sin (x)+\tan (x))^2} \, dx=\frac {1}{40} \, \tan \left (\frac {1}{2} \, x\right )^{5} - \frac {1}{24} \, \tan \left (\frac {1}{2} \, x\right )^{3} - \frac {1}{8 \, \tan \left (\frac {1}{2} \, x\right )} - \frac {1}{8} \, \tan \left (\frac {1}{2} \, x\right ) \]

[In]

integrate(1/(sin(x)+tan(x))^2,x, algorithm="giac")

[Out]

1/40*tan(1/2*x)^5 - 1/24*tan(1/2*x)^3 - 1/8/tan(1/2*x) - 1/8*tan(1/2*x)

Mupad [B] (verification not implemented)

Time = 29.09 (sec) , antiderivative size = 40, normalized size of antiderivative = 1.21 \[ \int \frac {1}{(\sin (x)+\tan (x))^2} \, dx=-\frac {8\,{\cos \left (\frac {x}{2}\right )}^6-4\,{\cos \left (\frac {x}{2}\right )}^4+14\,{\cos \left (\frac {x}{2}\right )}^2-3}{120\,{\cos \left (\frac {x}{2}\right )}^5\,\sin \left (\frac {x}{2}\right )} \]

[In]

int(1/(sin(x) + tan(x))^2,x)

[Out]

-(14*cos(x/2)^2 - 4*cos(x/2)^4 + 8*cos(x/2)^6 - 3)/(120*cos(x/2)^5*sin(x/2))