3.1.39 \(\int (-\cot (x)+\tan (x))^2 \, dx\) [39]

Optimal. Leaf size=10 \[ -4 x-\cot (x)+\tan (x) \]

[Out]

-4*x-cot(x)+tan(x)

________________________________________________________________________________________

Rubi [A]
time = 0.02, antiderivative size = 10, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 2, integrand size = 9, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.222, Rules used = {472, 209} \begin {gather*} -4 x+\tan (x)-\cot (x) \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

-4*x - Cot[x] + Tan[x]

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 472

Int[(((e_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_))/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Int[ExpandIntegr
and[(e*x)^m*((a + b*x^n)^p/(c + d*x^n)), x], x] /; FreeQ[{a, b, c, d, e, m}, x] && NeQ[b*c - a*d, 0] && IGtQ[n
, 0] && IGtQ[p, 0] && (IntegerQ[m] || IGtQ[2*(m + 1), 0] ||  !RationalQ[m])

Rubi steps

\begin {align*} \int (-\cot (x)+\tan (x))^2 \, dx &=\text {Subst}\left (\int \frac {\left (1-x^2\right )^2}{x^2 \left (1+x^2\right )} \, dx,x,\tan (x)\right )\\ &=\text {Subst}\left (\int \left (1+\frac {1}{x^2}-\frac {4}{1+x^2}\right ) \, dx,x,\tan (x)\right )\\ &=-\cot (x)+\tan (x)-4 \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (x)\right )\\ &=-4 x-\cot (x)+\tan (x)\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.01, size = 10, normalized size = 1.00 \begin {gather*} -4 x-\cot (x)+\tan (x) \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

-4*x - Cot[x] + Tan[x]

________________________________________________________________________________________

Maple [A]
time = 0.03, size = 11, normalized size = 1.10

method result size
default \(-4 x -\cot \left (x \right )+\tan \left (x \right )\) \(11\)
norman \(\frac {-1+\tan ^{2}\left (x \right )-4 x \tan \left (x \right )}{\tan \left (x \right )}\) \(17\)
risch \(-4 x -\frac {4 i}{\left ({\mathrm e}^{2 i x}+1\right ) \left ({\mathrm e}^{2 i x}-1\right )}\) \(26\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((-cot(x)+tan(x))^2,x,method=_RETURNVERBOSE)

[Out]

-4*x-cot(x)+tan(x)

________________________________________________________________________________________

Maxima [A]
time = 2.73, size = 12, normalized size = 1.20 \begin {gather*} -4 \, x - \frac {1}{\tan \left (x\right )} + \tan \left (x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-cot(x)+tan(x))^2,x, algorithm="maxima")

[Out]

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

________________________________________________________________________________________

Fricas [A]
time = 0.68, size = 19, normalized size = 1.90 \begin {gather*} -\frac {4 \, x \tan \left (x\right ) - \tan \left (x\right )^{2} + 1}{\tan \left (x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-cot(x)+tan(x))^2,x, algorithm="fricas")

[Out]

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

________________________________________________________________________________________

Sympy [A]
time = 0.14, size = 10, normalized size = 1.00 \begin {gather*} - 4 x + \tan {\left (x \right )} - \frac {1}{\tan {\left (x \right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-cot(x)+tan(x))**2,x)

[Out]

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

________________________________________________________________________________________

Giac [A]
time = 1.42, size = 12, normalized size = 1.20 \begin {gather*} -4 \, x - \frac {1}{\tan \left (x\right )} + \tan \left (x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-cot(x)+tan(x))^2,x, algorithm="giac")

[Out]

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

________________________________________________________________________________________

Mupad [B]
time = 0.27, size = 12, normalized size = 1.20 \begin {gather*} \mathrm {tan}\left (x\right )-4\,x-\frac {1}{\mathrm {tan}\left (x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((cot(x) - tan(x))^2,x)

[Out]

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

________________________________________________________________________________________