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

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

Optimal result

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

-(a-b)^(1/2)*arctan((a-b)^(1/2)*cot(d*x+c)/(a+b*cot(d*x+c)^2)^(1/2))/d-b^( 
1/2)*arctanh(b^(1/2)*cot(d*x+c)/(a+b*cot(d*x+c)^2)^(1/2))/d
 

Mathematica [A] (verified)

Time = 0.04 (sec) , antiderivative size = 107, normalized size of antiderivative = 1.23 \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=\frac {\sqrt {a-b} \arctan \left (\frac {\sqrt {b}+\sqrt {b} \cot ^2(c+d x)-\cot (c+d x) \sqrt {a+b \cot ^2(c+d x)}}{\sqrt {a-b}}\right )+\sqrt {b} \log \left (-\sqrt {b} \cot (c+d x)+\sqrt {a+b \cot ^2(c+d x)}\right )}{d} \] Input:

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

Output:

(Sqrt[a - b]*ArcTan[(Sqrt[b] + Sqrt[b]*Cot[c + d*x]^2 - Cot[c + d*x]*Sqrt[ 
a + b*Cot[c + d*x]^2])/Sqrt[a - b]] + Sqrt[b]*Log[-(Sqrt[b]*Cot[c + d*x]) 
+ Sqrt[a + b*Cot[c + d*x]^2]])/d
 

Rubi [A] (verified)

Time = 0.25 (sec) , antiderivative size = 84, normalized size of antiderivative = 0.97, number of steps used = 8, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.438, Rules used = {3042, 4144, 301, 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 \sqrt {a+b \cot ^2(c+d x)} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4144

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

\(\Big \downarrow \) 301

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

\(\Big \downarrow \) 224

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

\(\Big \downarrow \) 219

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

\(\Big \downarrow \) 291

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

\(\Big \downarrow \) 216

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

Input:

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

Output:

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

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 301
Int[((a_) + (b_.)*(x_)^2)^(p_.)/((c_) + (d_.)*(x_)^2), x_Symbol] :> Simp[b/ 
d   Int[(a + b*x^2)^(p - 1), x], x] - Simp[(b*c - a*d)/d   Int[(a + b*x^2)^ 
(p - 1)/(c + d*x^2), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] 
&& GtQ[p, 0] && (EqQ[p, 1/2] || EqQ[Denominator[p], 4] || (EqQ[p, 2/3] && E 
qQ[b*c + 3*a*d, 0]))
 

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

rule 4144
Int[((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[(a + b* 
(ff*x)^n)^p/(c^2 + ff^2*x^2), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, 
 b, c, e, f, n, p}, x] && (IntegersQ[n, p] || IGtQ[p, 0] || EqQ[n^2, 4] || 
EqQ[n^2, 16])
 
Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(169\) vs. \(2(75)=150\).

Time = 0.22 (sec) , antiderivative size = 170, normalized size of antiderivative = 1.95

method result size
derivativedivides \(-\frac {\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (d x +c \right )+\sqrt {a +b \cot \left (d x +c \right )^{2}}\right )}{d}+\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d 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 (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d \,b^{2} \left (a -b \right )}\) \(170\)
default \(-\frac {\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (d x +c \right )+\sqrt {a +b \cot \left (d x +c \right )^{2}}\right )}{d}+\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d 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 (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d \,b^{2} \left (a -b \right )}\) \(170\)

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 181 vs. \(2 (75) = 150\).

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

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

Output:

[1/2*(sqrt(-a + b)*log(-(a - b)*cos(2*d*x + 2*c) + sqrt(-a + b)*sqrt(((a - 
 b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c) + b 
) + sqrt(b)*log(((a - 2*b)*cos(2*d*x + 2*c) + 2*sqrt(b)*sqrt(((a - b)*cos( 
2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c) - a - 2*b)/ 
(cos(2*d*x + 2*c) - 1)))/d, -1/2*(2*sqrt(a - b)*arctan(-sqrt(a - b)*sqrt(( 
(a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c) 
/((a - b)*cos(2*d*x + 2*c) - a - b)) - sqrt(b)*log(((a - 2*b)*cos(2*d*x + 
2*c) + 2*sqrt(b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) 
 - 1))*sin(2*d*x + 2*c) - a - 2*b)/(cos(2*d*x + 2*c) - 1)))/d, 1/2*(2*sqrt 
(-b)*arctan(-sqrt(-b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x + 
 2*c) - 1))*sin(2*d*x + 2*c)/((a - b)*cos(2*d*x + 2*c) - a - b)) + sqrt(-a 
 + b)*log(-(a - b)*cos(2*d*x + 2*c) + sqrt(-a + b)*sqrt(((a - b)*cos(2*d*x 
 + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c) + b))/d, -(sqrt( 
a - b)*arctan(-sqrt(a - b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2* 
d*x + 2*c) - 1))*sin(2*d*x + 2*c)/((a - b)*cos(2*d*x + 2*c) - a - b)) - sq 
rt(-b)*arctan(-sqrt(-b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x 
 + 2*c) - 1))*sin(2*d*x + 2*c)/((a - b)*cos(2*d*x + 2*c) - a - b)))/d]
 

Sympy [F]

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

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

Output:

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

Maxima [F(-2)]

Exception generated. \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=\text {Exception raised: ValueError} \] Input:

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

Output:

Exception raised: ValueError >> Computation failed since Maxima requested 
additional constraints; using the 'assume' command before evaluation *may* 
 help (example of legal syntax is 'assume(b-a>0)', see `assume?` for more 
details)Is
 

Giac [F(-2)]

Exception generated. \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=\text {Exception raised: TypeError} \] Input:

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

Output:

Exception raised: TypeError >> an error occurred running a Giac command:IN 
PUT:sage2:=int(sage0,sageVARx):;OUTPUT:Degree mismatch inside factorisatio 
n over extensionDegree mismatch inside factorisation over extensionDegree 
mismatch
 

Mupad [F(-1)]

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

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

Output:

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

Reduce [F]

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

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

Output:

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