\(\int \frac {2}{(\cos (x)-\sin (x))^2} \, dx\) [70]

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

Optimal result

Integrand size = 11, antiderivative size = 8 \[ \int \frac {2}{(\cos (x)-\sin (x))^2} \, dx=\frac {2}{-1+\cot (x)} \]

[Out]

2/(-1+cot(x))

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 13, normalized size of antiderivative = 1.62, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.182, Rules used = {12, 3154} \[ \int \frac {2}{(\cos (x)-\sin (x))^2} \, dx=\frac {2 \sin (x)}{\cos (x)-\sin (x)} \]

[In]

Int[2/(Cos[x] - Sin[x])^2,x]

[Out]

(2*Sin[x])/(Cos[x] - Sin[x])

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

Rule 3154

Int[(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-2), x_Symbol] :> Simp[Sin[c + d*x]/(a*d*
(a*Cos[c + d*x] + b*Sin[c + d*x])), x] /; FreeQ[{a, b, c, d}, x] && NeQ[a^2 + b^2, 0]

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

Mathematica [A] (verified)

Time = 0.03 (sec) , antiderivative size = 13, normalized size of antiderivative = 1.62 \[ \int \frac {2}{(\cos (x)-\sin (x))^2} \, dx=\frac {2 \sin (x)}{\cos (x)-\sin (x)} \]

[In]

Integrate[2/(Cos[x] - Sin[x])^2,x]

[Out]

(2*Sin[x])/(Cos[x] - Sin[x])

Maple [A] (verified)

Time = 0.14 (sec) , antiderivative size = 9, normalized size of antiderivative = 1.12

method result size
default \(-\frac {2}{\tan \left (x \right )-1}\) \(9\)
risch \(\frac {2}{{\mathrm e}^{2 i x}-i}\) \(13\)
parallelrisch \(\frac {2 \sin \left (x \right )}{\cos \left (x \right )-\sin \left (x \right )}\) \(14\)
norman \(-\frac {4 \tan \left (\frac {x}{2}\right )}{\tan \left (\frac {x}{2}\right )^{2}+2 \tan \left (\frac {x}{2}\right )-1}\) \(23\)

[In]

int(2/(cos(x)-sin(x))^2,x,method=_RETURNVERBOSE)

[Out]

-2/(tan(x)-1)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.88 \[ \int \frac {2}{(\cos (x)-\sin (x))^2} \, dx=\frac {\cos \left (x\right ) + \sin \left (x\right )}{\cos \left (x\right ) - \sin \left (x\right )} \]

[In]

integrate(2/(cos(x)-sin(x))^2,x, algorithm="fricas")

[Out]

(cos(x) + sin(x))/(cos(x) - sin(x))

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 22 vs. \(2 (5) = 10\).

Time = 0.33 (sec) , antiderivative size = 22, normalized size of antiderivative = 2.75 \[ \int \frac {2}{(\cos (x)-\sin (x))^2} \, dx=- \frac {4 \tan {\left (\frac {x}{2} \right )}}{\tan ^{2}{\left (\frac {x}{2} \right )} + 2 \tan {\left (\frac {x}{2} \right )} - 1} \]

[In]

integrate(2/(cos(x)-sin(x))**2,x)

[Out]

-4*tan(x/2)/(tan(x/2)**2 + 2*tan(x/2) - 1)

Maxima [A] (verification not implemented)

none

Time = 0.20 (sec) , antiderivative size = 8, normalized size of antiderivative = 1.00 \[ \int \frac {2}{(\cos (x)-\sin (x))^2} \, dx=-\frac {2}{\tan \left (x\right ) - 1} \]

[In]

integrate(2/(cos(x)-sin(x))^2,x, algorithm="maxima")

[Out]

-2/(tan(x) - 1)

Giac [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 8, normalized size of antiderivative = 1.00 \[ \int \frac {2}{(\cos (x)-\sin (x))^2} \, dx=-\frac {2}{\tan \left (x\right ) - 1} \]

[In]

integrate(2/(cos(x)-sin(x))^2,x, algorithm="giac")

[Out]

-2/(tan(x) - 1)

Mupad [B] (verification not implemented)

Time = 15.12 (sec) , antiderivative size = 13, normalized size of antiderivative = 1.62 \[ \int \frac {2}{(\cos (x)-\sin (x))^2} \, dx=\frac {2\,\sin \left (x\right )}{\cos \left (x\right )-\sin \left (x\right )} \]

[In]

int(2/(cos(x) - sin(x))^2,x)

[Out]

(2*sin(x))/(cos(x) - sin(x))