3.305 \(\int (\csc (x)-\sin (x))^2 \, dx\)

Optimal. Leaf size=22 \[ -\frac{3 x}{2}-\frac{3 \cot (x)}{2}+\frac{1}{2} \cos ^2(x) \cot (x) \]

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.0238772, antiderivative size = 22, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 3, integrand size = 9, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.333, Rules used = {290, 325, 203} \[ -\frac{3 x}{2}-\frac{3 \cot (x)}{2}+\frac{1}{2} \cos ^2(x) \cot (x) \]

Antiderivative was successfully verified.

[In]

Int[(Csc[x] - Sin[x])^2,x]

[Out]

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

Rule 290

Int[((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> -Simp[((c*x)^(m + 1)*(a + b*x^n)^(p + 1))/(
a*c*n*(p + 1)), x] + Dist[(m + n*(p + 1) + 1)/(a*n*(p + 1)), Int[(c*x)^m*(a + b*x^n)^(p + 1), x], x] /; FreeQ[
{a, b, c, m}, x] && IGtQ[n, 0] && LtQ[p, -1] && IntBinomialQ[a, b, c, n, m, p, x]

Rule 325

Int[((c_.)*(x_))^(m_)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[((c*x)^(m + 1)*(a + b*x^n)^(p + 1))/(a*
c*(m + 1)), x] - Dist[(b*(m + n*(p + 1) + 1))/(a*c^n*(m + 1)), Int[(c*x)^(m + n)*(a + b*x^n)^p, x], x] /; Free
Q[{a, b, c, p}, x] && IGtQ[n, 0] && LtQ[m, -1] && IntBinomialQ[a, b, c, n, m, p, x]

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 (\csc (x)-\sin (x))^2 \, dx &=\operatorname{Subst}\left (\int \frac{1}{x^2 \left (1+x^2\right )^2} \, dx,x,\tan (x)\right )\\ &=\frac{1}{2} \cos ^2(x) \cot (x)+\frac{3}{2} \operatorname{Subst}\left (\int \frac{1}{x^2 \left (1+x^2\right )} \, dx,x,\tan (x)\right )\\ &=-\frac{3 \cot (x)}{2}+\frac{1}{2} \cos ^2(x) \cot (x)-\frac{3}{2} \operatorname{Subst}\left (\int \frac{1}{1+x^2} \, dx,x,\tan (x)\right )\\ &=-\frac{3 x}{2}-\frac{3 \cot (x)}{2}+\frac{1}{2} \cos ^2(x) \cot (x)\\ \end{align*}

Mathematica [A]  time = 0.0157032, size = 18, normalized size = 0.82 \[ -\frac{3 x}{2}-\frac{1}{4} \sin (2 x)-\cot (x) \]

Antiderivative was successfully verified.

[In]

Integrate[(Csc[x] - Sin[x])^2,x]

[Out]

(-3*x)/2 - Cot[x] - Sin[2*x]/4

________________________________________________________________________________________

Maple [A]  time = 0.016, size = 15, normalized size = 0.7 \begin{align*} -{\frac{\cos \left ( x \right ) \sin \left ( x \right ) }{2}}-{\frac{3\,x}{2}}-\cot \left ( x \right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((csc(x)-sin(x))^2,x)

[Out]

-1/2*cos(x)*sin(x)-3/2*x-cot(x)

________________________________________________________________________________________

Maxima [A]  time = 0.994337, size = 22, normalized size = 1. \begin{align*} -\frac{3}{2} \, x - \frac{1}{\tan \left (x\right )} - \frac{1}{4} \, \sin \left (2 \, x\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Fricas [A]  time = 2.11598, size = 63, normalized size = 2.86 \begin{align*} \frac{\cos \left (x\right )^{3} - 3 \, x \sin \left (x\right ) - 3 \, \cos \left (x\right )}{2 \, \sin \left (x\right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [A]  time = 1.9787, size = 15, normalized size = 0.68 \begin{align*} - \frac{3 x}{2} - \frac{\sin{\left (2 x \right )}}{4} - \cot{\left (x \right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((csc(x)-sin(x))**2,x)

[Out]

-3*x/2 - sin(2*x)/4 - cot(x)

________________________________________________________________________________________

Giac [A]  time = 1.14499, size = 31, normalized size = 1.41 \begin{align*} -\frac{3}{2} \, x - \frac{3 \, \tan \left (x\right )^{2} + 2}{2 \,{\left (\tan \left (x\right )^{3} + \tan \left (x\right )\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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