3.39 \(\int (-\cot (x)+\tan (x))^2 \, dx\)

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

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.0275772, antiderivative size = 10, normalized size of antiderivative = 1., 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 = {461, 203} \[ -4 x+\tan (x)-\cot (x) \]

Antiderivative was successfully verified.

[In]

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

[Out]

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

Rule 461

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])

Rule 203

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

Rubi steps

\begin{align*} \int (-\cot (x)+\tan (x))^2 \, dx &=\operatorname{Subst}\left (\int \frac{\left (1-x^2\right )^2}{x^2 \left (1+x^2\right )} \, dx,x,\tan (x)\right )\\ &=\operatorname{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 \operatorname{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.0155332, size = 10, normalized size = 1. \[ -4 x+\tan (x)-\cot (x) \]

Antiderivative was successfully verified.

[In]

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

[Out]

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

________________________________________________________________________________________

Maple [A]  time = 0.014, size = 11, normalized size = 1.1 \begin{align*} -4\,x-\cot \left ( x \right ) +\tan \left ( x \right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Maxima [A]  time = 1.46524, size = 16, normalized size = 1.6 \begin{align*} -4 \, x - \frac{1}{\tan \left (x\right )} + \tan \left (x\right ) \end{align*}

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 = 2.04472, size = 50, normalized size = 5. \begin{align*} -\frac{4 \, x \tan \left (x\right ) - \tan \left (x\right )^{2} + 1}{\tan \left (x\right )} \end{align*}

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.393155, size = 10, normalized size = 1. \begin{align*} - 4 x + \tan{\left (x \right )} - \frac{1}{\tan{\left (x \right )}} \end{align*}

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.05474, size = 16, normalized size = 1.6 \begin{align*} -4 \, x - \frac{1}{\tan \left (x\right )} + \tan \left (x\right ) \end{align*}

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)