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.06, antiderivative size = 29, normalized size of antiderivative = 1.00, 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 2637

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

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

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.13, size = 24, normalized size = 0.83 \[ -\left (\left (a^2+b^2\right ) \cot (x)\right )-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])

________________________________________________________________________________________

fricas [A]  time = 0.92, size = 28, normalized size = 0.97 \[ -\frac {a^{2} x \sin \relax (x) + 2 \, a b + {\left (a^{2} + b^{2}\right )} \cos \relax (x)}{\sin \relax (x)} \]

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)

________________________________________________________________________________________

giac [A]  time = 0.15, size = 52, normalized size = 1.79 \[ -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 )} \]

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)

________________________________________________________________________________________

maple [A]  time = 0.04, size = 29, normalized size = 1.00 \[ a^{2} \left (-\cot \relax (x )-x \right )-\frac {2 a b}{\sin \relax (x )}-b^{2} \cot \relax (x ) \]

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 = 0.42, size = 29, normalized size = 1.00 \[ -a^{2} {\left (x + \frac {1}{\tan \relax (x)}\right )} - \frac {2 \, a b}{\sin \relax (x)} - \frac {b^{2}}{\tan \relax (x)} \]

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)

________________________________________________________________________________________

mupad [B]  time = 2.42, size = 30, normalized size = 1.03 \[ -\frac {\cos \relax (x)\,a^2+2\,a\,b+\cos \relax (x)\,b^2}{\sin \relax (x)}-a^2\,x \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

sympy [A]  time = 2.79, size = 31, normalized size = 1.07 \[ - a^{2} x - \frac {a^{2} \cos {\relax (x )}}{\sin {\relax (x )}} - 2 a b \csc {\relax (x )} - b^{2} \cot {\relax (x )} \]

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)

________________________________________________________________________________________