3.286 \(\int (a \cot (x)+b \csc (x))^2 \, dx\)

Optimal. Leaf size=29 \[ a^2 (-x)-a b \sin (x)-\csc (x) (a \cos (x)+b) (a+b \cos (x)) \]

[Out]

-(a^2*x) - (b + a*Cos[x])*(a + b*Cos[x])*Csc[x] - a*b*Sin[x]

________________________________________________________________________________________

Rubi [A]  time = 0.056306, antiderivative size = 29, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 3, integrand size = 11, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.273, Rules used = {4392, 2691, 2637} \[ a^2 (-x)-a b \sin (x)-\csc (x) (a \cos (x)+b) (a+b \cos (x)) \]

Antiderivative was successfully verified.

[In]

Int[(a*Cot[x] + b*Csc[x])^2,x]

[Out]

-(a^2*x) - (b + a*Cos[x])*(a + b*Cos[x])*Csc[x] - a*b*Sin[x]

Rule 4392

Int[(cot[(c_.) + (d_.)*(x_)]^(n_.)*(a_.) + csc[(c_.) + (d_.)*(x_)]^(n_.)*(b_.))^(p_)*(u_.), x_Symbol] :> Int[A
ctivateTrig[u]*Csc[c + d*x]^(n*p)*(b + a*Cos[c + d*x]^n)^p, x] /; FreeQ[{a, b, c, d}, x] && IntegersQ[n, p]

Rule 2691

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> -Simp[((g*C
os[e + f*x])^(p + 1)*(a + b*Sin[e + f*x])^(m - 1)*(b + a*Sin[e + f*x]))/(f*g*(p + 1)), x] + Dist[1/(g^2*(p + 1
)), Int[(g*Cos[e + f*x])^(p + 2)*(a + b*Sin[e + f*x])^(m - 2)*(b^2*(m - 1) + a^2*(p + 2) + a*b*(m + p + 1)*Sin
[e + f*x]), x], x] /; FreeQ[{a, b, e, f, g}, x] && NeQ[a^2 - b^2, 0] && GtQ[m, 1] && LtQ[p, -1] && (IntegersQ[
2*m, 2*p] || IntegerQ[m])

Rule 2637

Int[sin[Pi/2 + (c_.) + (d_.)*(x_)], x_Symbol] :> Simp[Sin[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int (a \cot (x)+b \csc (x))^2 \, dx &=\int (b+a \cos (x))^2 \csc ^2(x) \, dx\\ &=-(b+a \cos (x)) (a+b \cos (x)) \csc (x)-\int \left (a^2+a b \cos (x)\right ) \, dx\\ &=-a^2 x-(b+a \cos (x)) (a+b \cos (x)) \csc (x)-(a b) \int \cos (x) \, dx\\ &=-a^2 x-(b+a \cos (x)) (a+b \cos (x)) \csc (x)-a b \sin (x)\\ \end{align*}

Mathematica [A]  time = 0.129501, size = 24, normalized size = 0.83 \[ -\left (a^2+b^2\right ) \cot (x)-a (a x+2 b \csc (x)) \]

Antiderivative was successfully verified.

[In]

Integrate[(a*Cot[x] + b*Csc[x])^2,x]

[Out]

-((a^2 + b^2)*Cot[x]) - a*(a*x + 2*b*Csc[x])

________________________________________________________________________________________

Maple [A]  time = 0.014, size = 29, normalized size = 1. \begin{align*}{a}^{2} \left ( -\cot \left ( x \right ) -x \right ) -2\,{\frac{ab}{\sin \left ( x \right ) }}-{b}^{2}\cot \left ( x \right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a*cot(x)+b*csc(x))^2,x)

[Out]

a^2*(-cot(x)-x)-2*a*b/sin(x)-b^2*cot(x)

________________________________________________________________________________________

Maxima [A]  time = 1.48353, size = 39, normalized size = 1.34 \begin{align*} -a^{2}{\left (x + \frac{1}{\tan \left (x\right )}\right )} - \frac{2 \, a b}{\sin \left (x\right )} - \frac{b^{2}}{\tan \left (x\right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a*cot(x)+b*csc(x))^2,x, algorithm="maxima")

[Out]

-a^2*(x + 1/tan(x)) - 2*a*b/sin(x) - b^2/tan(x)

________________________________________________________________________________________

Fricas [A]  time = 1.95012, size = 72, normalized size = 2.48 \begin{align*} -\frac{a^{2} x \sin \left (x\right ) + 2 \, a b +{\left (a^{2} + b^{2}\right )} \cos \left (x\right )}{\sin \left (x\right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a*cot(x)+b*csc(x))^2,x, algorithm="fricas")

[Out]

-(a^2*x*sin(x) + 2*a*b + (a^2 + b^2)*cos(x))/sin(x)

________________________________________________________________________________________

Sympy [A]  time = 7.40745, size = 31, normalized size = 1.07 \begin{align*} - a^{2} x - \frac{a^{2} \cos{\left (x \right )}}{\sin{\left (x \right )}} - 2 a b \csc{\left (x \right )} - b^{2} \cot{\left (x \right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a*cot(x)+b*csc(x))**2,x)

[Out]

-a**2*x - a**2*cos(x)/sin(x) - 2*a*b*csc(x) - b**2*cot(x)

________________________________________________________________________________________

Giac [A]  time = 1.14155, size = 70, normalized size = 2.41 \begin{align*} -a^{2} x + \frac{1}{2} \, a^{2} \tan \left (\frac{1}{2} \, x\right ) - a b \tan \left (\frac{1}{2} \, x\right ) + \frac{1}{2} \, b^{2} \tan \left (\frac{1}{2} \, x\right ) - \frac{a^{2} + 2 \, a b + b^{2}}{2 \, \tan \left (\frac{1}{2} \, x\right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a*cot(x)+b*csc(x))^2,x, algorithm="giac")

[Out]

-a^2*x + 1/2*a^2*tan(1/2*x) - a*b*tan(1/2*x) + 1/2*b^2*tan(1/2*x) - 1/2*(a^2 + 2*a*b + b^2)/tan(1/2*x)