\(\int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx\) [22]

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [B] (verified)
Fricas [B] (verification not implemented)
Sympy [F]
Maxima [F]
Giac [B] (verification not implemented)
Mupad [F(-1)]
Reduce [F]

Optimal result

Integrand size = 17, antiderivative size = 89 \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\frac {(a-2 b) \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{2 \sqrt {b}}-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)} \] Output:

(a-b)^(1/2)*arctan((a-b)^(1/2)*cot(x)/(a+b*cot(x)^2)^(1/2))-1/2*(a-2*b)*ar 
ctanh(b^(1/2)*cot(x)/(a+b*cot(x)^2)^(1/2))/b^(1/2)-1/2*cot(x)*(a+b*cot(x)^ 
2)^(1/2)
 

Mathematica [A] (verified)

Time = 2.59 (sec) , antiderivative size = 140, normalized size of antiderivative = 1.57 \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=-\frac {1}{2} \sqrt {\frac {-a-b+a \cos (2 x)-b \cos (2 x)}{-1+\cos (2 x)}} \cot (x)-\frac {\left (2 \sqrt {a-b} \sqrt {b} \arctan \left (\frac {\sqrt {b+a \tan ^2(x)}}{\sqrt {a-b}}\right )+(a-2 b) \text {arctanh}\left (\frac {\sqrt {b+a \tan ^2(x)}}{\sqrt {b}}\right )\right ) \sqrt {a+b \cot ^2(x)} \tan (x)}{2 \sqrt {b} \sqrt {b+a \tan ^2(x)}} \] Input:

Integrate[Cot[x]^2*Sqrt[a + b*Cot[x]^2],x]
 

Output:

-1/2*(Sqrt[(-a - b + a*Cos[2*x] - b*Cos[2*x])/(-1 + Cos[2*x])]*Cot[x]) - ( 
(2*Sqrt[a - b]*Sqrt[b]*ArcTan[Sqrt[b + a*Tan[x]^2]/Sqrt[a - b]] + (a - 2*b 
)*ArcTanh[Sqrt[b + a*Tan[x]^2]/Sqrt[b]])*Sqrt[a + b*Cot[x]^2]*Tan[x])/(2*S 
qrt[b]*Sqrt[b + a*Tan[x]^2])
 

Rubi [A] (verified)

Time = 0.33 (sec) , antiderivative size = 93, normalized size of antiderivative = 1.04, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.471, Rules used = {3042, 4153, 380, 398, 224, 219, 291, 216}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \tan \left (x+\frac {\pi }{2}\right )^2 \sqrt {a+b \tan \left (x+\frac {\pi }{2}\right )^2}dx\)

\(\Big \downarrow \) 4153

\(\displaystyle -\int \frac {\cot ^2(x) \sqrt {b \cot ^2(x)+a}}{\cot ^2(x)+1}d\cot (x)\)

\(\Big \downarrow \) 380

\(\displaystyle \frac {1}{2} \int \frac {a-(a-2 b) \cot ^2(x)}{\left (\cot ^2(x)+1\right ) \sqrt {b \cot ^2(x)+a}}d\cot (x)-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)}\)

\(\Big \downarrow \) 398

\(\displaystyle \frac {1}{2} \left (2 (a-b) \int \frac {1}{\left (\cot ^2(x)+1\right ) \sqrt {b \cot ^2(x)+a}}d\cot (x)-(a-2 b) \int \frac {1}{\sqrt {b \cot ^2(x)+a}}d\cot (x)\right )-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)}\)

\(\Big \downarrow \) 224

\(\displaystyle \frac {1}{2} \left (2 (a-b) \int \frac {1}{\left (\cot ^2(x)+1\right ) \sqrt {b \cot ^2(x)+a}}d\cot (x)-(a-2 b) \int \frac {1}{1-\frac {b \cot ^2(x)}{b \cot ^2(x)+a}}d\frac {\cot (x)}{\sqrt {b \cot ^2(x)+a}}\right )-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)}\)

\(\Big \downarrow \) 219

\(\displaystyle \frac {1}{2} \left (2 (a-b) \int \frac {1}{\left (\cot ^2(x)+1\right ) \sqrt {b \cot ^2(x)+a}}d\cot (x)-\frac {(a-2 b) \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{\sqrt {b}}\right )-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)}\)

\(\Big \downarrow \) 291

\(\displaystyle \frac {1}{2} \left (2 (a-b) \int \frac {1}{1-\frac {(b-a) \cot ^2(x)}{b \cot ^2(x)+a}}d\frac {\cot (x)}{\sqrt {b \cot ^2(x)+a}}-\frac {(a-2 b) \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{\sqrt {b}}\right )-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)}\)

\(\Big \downarrow \) 216

\(\displaystyle \frac {1}{2} \left (2 \sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\frac {(a-2 b) \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{\sqrt {b}}\right )-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)}\)

Input:

Int[Cot[x]^2*Sqrt[a + b*Cot[x]^2],x]
 

Output:

(2*Sqrt[a - b]*ArcTan[(Sqrt[a - b]*Cot[x])/Sqrt[a + b*Cot[x]^2]] - ((a - 2 
*b)*ArcTanh[(Sqrt[b]*Cot[x])/Sqrt[a + b*Cot[x]^2]])/Sqrt[b])/2 - (Cot[x]*S 
qrt[a + b*Cot[x]^2])/2
 

Defintions of rubi rules used

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

rule 219
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))* 
ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x] /; FreeQ[{a, b}, x] && NegQ[a/b] && (Gt 
Q[a, 0] || LtQ[b, 0])
 

rule 224
Int[1/Sqrt[(a_) + (b_.)*(x_)^2], x_Symbol] :> Subst[Int[1/(1 - b*x^2), x], 
x, x/Sqrt[a + b*x^2]] /; FreeQ[{a, b}, x] &&  !GtQ[a, 0]
 

rule 291
Int[1/(Sqrt[(a_) + (b_.)*(x_)^2]*((c_) + (d_.)*(x_)^2)), x_Symbol] :> Subst 
[Int[1/(c - (b*c - a*d)*x^2), x], x, x/Sqrt[a + b*x^2]] /; FreeQ[{a, b, c, 
d}, x] && NeQ[b*c - a*d, 0]
 

rule 380
Int[((e_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^2)^(p_)*((c_) + (d_.)*(x_)^2)^(q_ 
), x_Symbol] :> Simp[e*(e*x)^(m - 1)*(a + b*x^2)^(p + 1)*((c + d*x^2)^q/(b* 
(m + 2*(p + q) + 1))), x] - Simp[e^2/(b*(m + 2*(p + q) + 1))   Int[(e*x)^(m 
 - 2)*(a + b*x^2)^p*(c + d*x^2)^(q - 1)*Simp[a*c*(m - 1) + (a*d*(m - 1) - 2 
*q*(b*c - a*d))*x^2, x], x], x] /; FreeQ[{a, b, c, d, e, p}, x] && NeQ[b*c 
- a*d, 0] && GtQ[q, 0] && GtQ[m, 1] && IntBinomialQ[a, b, c, d, e, m, 2, p, 
 q, x]
 

rule 398
Int[((e_) + (f_.)*(x_)^2)/(((a_) + (b_.)*(x_)^2)*Sqrt[(c_) + (d_.)*(x_)^2]) 
, x_Symbol] :> Simp[f/b   Int[1/Sqrt[c + d*x^2], x], x] + Simp[(b*e - a*f)/ 
b   Int[1/((a + b*x^2)*Sqrt[c + d*x^2]), x], x] /; FreeQ[{a, b, c, d, e, f} 
, x]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4153
Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + 
(f_.)*(x_)])^(n_))^(p_.), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x], 
 x]}, Simp[c*(ff/f)   Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2 + f 
f^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, 
n, p}, x] && (IGtQ[p, 0] || EqQ[n, 2] || EqQ[n, 4] || (IntegerQ[p] && Ratio 
nalQ[n]))
 
Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(173\) vs. \(2(71)=142\).

Time = 0.18 (sec) , antiderivative size = 174, normalized size of antiderivative = 1.96

method result size
derivativedivides \(-\frac {\cot \left (x \right ) \sqrt {a +b \cot \left (x \right )^{2}}}{2}-\frac {a \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )}{2 \sqrt {b}}+\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )-\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b \left (a -b \right )}+\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b^{2} \left (a -b \right )}\) \(174\)
default \(-\frac {\cot \left (x \right ) \sqrt {a +b \cot \left (x \right )^{2}}}{2}-\frac {a \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )}{2 \sqrt {b}}+\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )-\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b \left (a -b \right )}+\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b^{2} \left (a -b \right )}\) \(174\)

Input:

int(cot(x)^2*(a+b*cot(x)^2)^(1/2),x,method=_RETURNVERBOSE)
 

Output:

-1/2*cot(x)*(a+b*cot(x)^2)^(1/2)-1/2*a/b^(1/2)*ln(b^(1/2)*cot(x)+(a+b*cot( 
x)^2)^(1/2))+b^(1/2)*ln(b^(1/2)*cot(x)+(a+b*cot(x)^2)^(1/2))-(b^4*(a-b))^( 
1/2)/b/(a-b)*arctan(b^2*(a-b)/(b^4*(a-b))^(1/2)/(a+b*cot(x)^2)^(1/2)*cot(x 
))+a*(b^4*(a-b))^(1/2)/b^2/(a-b)*arctan(b^2*(a-b)/(b^4*(a-b))^(1/2)/(a+b*c 
ot(x)^2)^(1/2)*cot(x))
 

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 199 vs. \(2 (71) = 142\).

Time = 0.11 (sec) , antiderivative size = 792, normalized size of antiderivative = 8.90 \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx =\text {Too large to display} \] Input:

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

Output:

[1/4*(2*sqrt(-a + b)*b*log(-(a - b)*cos(2*x) - sqrt(-a + b)*sqrt(((a - b)* 
cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x) + b)*sin(2*x) - (a - 2*b)*sqrt( 
b)*log(((a - 2*b)*cos(2*x) - 2*sqrt(b)*sqrt(((a - b)*cos(2*x) - a - b)/(co 
s(2*x) - 1))*sin(2*x) - a - 2*b)/(cos(2*x) - 1))*sin(2*x) - 2*(b*cos(2*x) 
+ b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1)))/(b*sin(2*x)), 1/4*(4 
*sqrt(a - b)*b*arctan(-sqrt(a - b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2* 
x) - 1))*sin(2*x)/((a - b)*cos(2*x) - a - b))*sin(2*x) - (a - 2*b)*sqrt(b) 
*log(((a - 2*b)*cos(2*x) - 2*sqrt(b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos( 
2*x) - 1))*sin(2*x) - a - 2*b)/(cos(2*x) - 1))*sin(2*x) - 2*(b*cos(2*x) + 
b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1)))/(b*sin(2*x)), 1/2*((a 
- 2*b)*sqrt(-b)*arctan(-sqrt(-b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) 
 - 1))*sin(2*x)/((a - b)*cos(2*x) - a - b))*sin(2*x) + sqrt(-a + b)*b*log( 
-(a - b)*cos(2*x) - sqrt(-a + b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) 
 - 1))*sin(2*x) + b)*sin(2*x) - (b*cos(2*x) + b)*sqrt(((a - b)*cos(2*x) - 
a - b)/(cos(2*x) - 1)))/(b*sin(2*x)), 1/2*(2*sqrt(a - b)*b*arctan(-sqrt(a 
- b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x)/((a - b)*cos 
(2*x) - a - b))*sin(2*x) + (a - 2*b)*sqrt(-b)*arctan(-sqrt(-b)*sqrt(((a - 
b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x)/((a - b)*cos(2*x) - a - b))* 
sin(2*x) - (b*cos(2*x) + b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1) 
))/(b*sin(2*x))]
 

Sympy [F]

\[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\int \sqrt {a + b \cot ^{2}{\left (x \right )}} \cot ^{2}{\left (x \right )}\, dx \] Input:

integrate(cot(x)**2*(a+b*cot(x)**2)**(1/2),x)
 

Output:

Integral(sqrt(a + b*cot(x)**2)*cot(x)**2, x)
 

Maxima [F]

\[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\int { \sqrt {b \cot \left (x\right )^{2} + a} \cot \left (x\right )^{2} \,d x } \] Input:

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

Output:

integrate(sqrt(b*cot(x)^2 + a)*cot(x)^2, x)
 

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 259 vs. \(2 (71) = 142\).

Time = 0.59 (sec) , antiderivative size = 259, normalized size of antiderivative = 2.91 \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=-\frac {1}{2} \, {\left (\frac {{\left (a - 2 \, b\right )} \sqrt {-a + b} \arctan \left (\frac {{\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2} + a - 2 \, b}{2 \, \sqrt {a b - b^{2}}}\right )}{\sqrt {a b - b^{2}}} - \sqrt {-a + b} \log \left ({\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2}\right ) - \frac {2 \, {\left ({\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2} {\left (a - 2 \, b\right )} \sqrt {-a + b} + a^{2} \sqrt {-a + b}\right )}}{{\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{4} + 2 \, {\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2} {\left (a - 2 \, b\right )} + a^{2}}\right )} \mathrm {sgn}\left (\sin \left (x\right )\right ) \] Input:

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

Output:

-1/2*((a - 2*b)*sqrt(-a + b)*arctan(1/2*((sqrt(-a + b)*cos(x) - sqrt(-a*co 
s(x)^2 + b*cos(x)^2 + a))^2 + a - 2*b)/sqrt(a*b - b^2))/sqrt(a*b - b^2) - 
sqrt(-a + b)*log((sqrt(-a + b)*cos(x) - sqrt(-a*cos(x)^2 + b*cos(x)^2 + a) 
)^2) - 2*((sqrt(-a + b)*cos(x) - sqrt(-a*cos(x)^2 + b*cos(x)^2 + a))^2*(a 
- 2*b)*sqrt(-a + b) + a^2*sqrt(-a + b))/((sqrt(-a + b)*cos(x) - sqrt(-a*co 
s(x)^2 + b*cos(x)^2 + a))^4 + 2*(sqrt(-a + b)*cos(x) - sqrt(-a*cos(x)^2 + 
b*cos(x)^2 + a))^2*(a - 2*b) + a^2))*sgn(sin(x))
 

Mupad [F(-1)]

Timed out. \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\int {\mathrm {cot}\left (x\right )}^2\,\sqrt {b\,{\mathrm {cot}\left (x\right )}^2+a} \,d x \] Input:

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

Output:

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

Reduce [F]

\[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\int \sqrt {\cot \left (x \right )^{2} b +a}\, \cot \left (x \right )^{2}d x \] Input:

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

Output:

int(sqrt(cot(x)**2*b + a)*cot(x)**2,x)