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

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 [B] (verification not implemented)
Reduce [F]

Optimal result

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

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

Mathematica [A] (verified)

Time = 0.03 (sec) , antiderivative size = 60, normalized size of antiderivative = 1.00 \[ \int \frac {\tan (x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\frac {\text {arctanh}\left (\frac {\sqrt {a+b \cot ^2(x)}}{\sqrt {a}}\right )}{\sqrt {a}}-\frac {\text {arctanh}\left (\frac {\sqrt {a+b \cot ^2(x)}}{\sqrt {a-b}}\right )}{\sqrt {a-b}} \] Input:

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

Output:

ArcTanh[Sqrt[a + b*Cot[x]^2]/Sqrt[a]]/Sqrt[a] - ArcTanh[Sqrt[a + b*Cot[x]^ 
2]/Sqrt[a - b]]/Sqrt[a - b]
 

Rubi [A] (verified)

Time = 0.29 (sec) , antiderivative size = 65, normalized size of antiderivative = 1.08, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.533, Rules used = {3042, 25, 4153, 25, 354, 97, 73, 221}

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 \frac {\tan (x)}{\sqrt {a+b \cot ^2(x)}} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 25

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

\(\Big \downarrow \) 4153

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

\(\Big \downarrow \) 25

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

\(\Big \downarrow \) 354

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

\(\Big \downarrow \) 97

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

\(\Big \downarrow \) 73

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

\(\Big \downarrow \) 221

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

Input:

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

Output:

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

Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 73
Int[((a_.) + (b_.)*(x_))^(m_)*((c_.) + (d_.)*(x_))^(n_), x_Symbol] :> With[ 
{p = Denominator[m]}, Simp[p/b   Subst[Int[x^(p*(m + 1) - 1)*(c - a*(d/b) + 
 d*(x^p/b))^n, x], x, (a + b*x)^(1/p)], x]] /; FreeQ[{a, b, c, d}, x] && Lt 
Q[-1, m, 0] && LeQ[-1, n, 0] && LeQ[Denominator[n], Denominator[m]] && IntL 
inearQ[a, b, c, d, m, n, x]
 

rule 97
Int[((e_.) + (f_.)*(x_))^(p_)/(((a_.) + (b_.)*(x_))*((c_.) + (d_.)*(x_))), 
x_] :> Simp[b/(b*c - a*d)   Int[(e + f*x)^p/(a + b*x), x], x] - Simp[d/(b*c 
 - a*d)   Int[(e + f*x)^p/(c + d*x), x], x] /; FreeQ[{a, b, c, d, e, f, p}, 
 x] &&  !IntegerQ[p]
 

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

rule 354
Int[(x_)^(m_.)*((a_) + (b_.)*(x_)^2)^(p_.)*((c_) + (d_.)*(x_)^2)^(q_.), x_S 
ymbol] :> Simp[1/2   Subst[Int[x^((m - 1)/2)*(a + b*x)^p*(c + d*x)^q, x], x 
, x^2], x] /; FreeQ[{a, b, c, d, p, q}, x] && NeQ[b*c - a*d, 0] && IntegerQ 
[(m - 1)/2]
 

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. \(142\) vs. \(2(48)=96\).

Time = 3.31 (sec) , antiderivative size = 143, normalized size of antiderivative = 2.38

method result size
default \(\frac {\sqrt {4}\, \sqrt {\frac {\cos \left (x \right )^{2} b +a \sin \left (x \right )^{2}}{\left (\cos \left (x \right )+1\right )^{2}}}\, \left (\arctan \left (\frac {\sqrt {\frac {\cos \left (x \right )^{2} b +a \sin \left (x \right )^{2}}{\left (\cos \left (x \right )+1\right )^{2}}}\, \sin \left (x \right )}{\sqrt {-a +b}\, \left (-1+\cos \left (x \right )\right )}\right ) \sqrt {a}+\operatorname {arctanh}\left (\frac {\sqrt {\frac {\cos \left (x \right )^{2} b +a \sin \left (x \right )^{2}}{\left (\cos \left (x \right )+1\right )^{2}}}\, \sin \left (x \right )}{\sqrt {a}\, \left (-1+\cos \left (x \right )\right )}\right ) \sqrt {-a +b}\right ) \sin \left (x \right )}{2 \sqrt {a}\, \sqrt {-a +b}\, \sqrt {a +b \cot \left (x \right )^{2}}\, \left (-1+\cos \left (x \right )\right )}\) \(143\)

Input:

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

Output:

1/2*4^(1/2)/a^(1/2)/(-a+b)^(1/2)*((cos(x)^2*b+a*sin(x)^2)/(cos(x)+1)^2)^(1 
/2)*(arctan(1/(-a+b)^(1/2)*((cos(x)^2*b+a*sin(x)^2)/(cos(x)+1)^2)^(1/2)*si 
n(x)/(-1+cos(x)))*a^(1/2)+arctanh(1/a^(1/2)*((cos(x)^2*b+a*sin(x)^2)/(cos( 
x)+1)^2)^(1/2)*sin(x)/(-1+cos(x)))*(-a+b)^(1/2))*sin(x)/(a+b*cot(x)^2)^(1/ 
2)/(-1+cos(x))
 

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 108 vs. \(2 (48) = 96\).

Time = 0.11 (sec) , antiderivative size = 453, normalized size of antiderivative = 7.55 \[ \int \frac {\tan (x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\left [\frac {{\left (a - b\right )} \sqrt {a} \log \left (2 \, a \tan \left (x\right )^{2} + 2 \, \sqrt {a} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )^{2} + b\right ) + \sqrt {a - b} a \log \left (\frac {{\left (2 \, a - b\right )} \tan \left (x\right )^{2} - 2 \, \sqrt {a - b} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2} + 1}\right )}{2 \, {\left (a^{2} - a b\right )}}, \frac {2 \, a \sqrt {-a + b} \arctan \left (\frac {\sqrt {-a + b} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )^{2}}{a \tan \left (x\right )^{2} + b}\right ) + {\left (a - b\right )} \sqrt {a} \log \left (2 \, a \tan \left (x\right )^{2} + 2 \, \sqrt {a} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )^{2} + b\right )}{2 \, {\left (a^{2} - a b\right )}}, -\frac {2 \, \sqrt {-a} {\left (a - b\right )} \arctan \left (\frac {\sqrt {-a} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )^{2}}{a \tan \left (x\right )^{2} + b}\right ) - \sqrt {a - b} a \log \left (\frac {{\left (2 \, a - b\right )} \tan \left (x\right )^{2} - 2 \, \sqrt {a - b} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2} + 1}\right )}{2 \, {\left (a^{2} - a b\right )}}, -\frac {\sqrt {-a} {\left (a - b\right )} \arctan \left (\frac {\sqrt {-a} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )^{2}}{a \tan \left (x\right )^{2} + b}\right ) - a \sqrt {-a + b} \arctan \left (\frac {\sqrt {-a + b} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )^{2}}{a \tan \left (x\right )^{2} + b}\right )}{a^{2} - a b}\right ] \] Input:

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

Output:

[1/2*((a - b)*sqrt(a)*log(2*a*tan(x)^2 + 2*sqrt(a)*sqrt((a*tan(x)^2 + b)/t 
an(x)^2)*tan(x)^2 + b) + sqrt(a - b)*a*log(((2*a - b)*tan(x)^2 - 2*sqrt(a 
- b)*sqrt((a*tan(x)^2 + b)/tan(x)^2)*tan(x)^2 + b)/(tan(x)^2 + 1)))/(a^2 - 
 a*b), 1/2*(2*a*sqrt(-a + b)*arctan(sqrt(-a + b)*sqrt((a*tan(x)^2 + b)/tan 
(x)^2)*tan(x)^2/(a*tan(x)^2 + b)) + (a - b)*sqrt(a)*log(2*a*tan(x)^2 + 2*s 
qrt(a)*sqrt((a*tan(x)^2 + b)/tan(x)^2)*tan(x)^2 + b))/(a^2 - a*b), -1/2*(2 
*sqrt(-a)*(a - b)*arctan(sqrt(-a)*sqrt((a*tan(x)^2 + b)/tan(x)^2)*tan(x)^2 
/(a*tan(x)^2 + b)) - sqrt(a - b)*a*log(((2*a - b)*tan(x)^2 - 2*sqrt(a - b) 
*sqrt((a*tan(x)^2 + b)/tan(x)^2)*tan(x)^2 + b)/(tan(x)^2 + 1)))/(a^2 - a*b 
), -(sqrt(-a)*(a - b)*arctan(sqrt(-a)*sqrt((a*tan(x)^2 + b)/tan(x)^2)*tan( 
x)^2/(a*tan(x)^2 + b)) - a*sqrt(-a + b)*arctan(sqrt(-a + b)*sqrt((a*tan(x) 
^2 + b)/tan(x)^2)*tan(x)^2/(a*tan(x)^2 + b)))/(a^2 - a*b)]
 

Sympy [F]

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

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

Output:

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

Maxima [F]

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

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

Output:

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

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 203 vs. \(2 (48) = 96\).

Time = 0.14 (sec) , antiderivative size = 203, normalized size of antiderivative = 3.38 \[ \int \frac {\tan (x)}{\sqrt {a+b \cot ^2(x)}} \, dx=-\frac {{\left (2 \, a \arctan \left (-\frac {a - b}{\sqrt {-a^{2} + a b}}\right ) - 2 \, b \arctan \left (-\frac {a - b}{\sqrt {-a^{2} + a b}}\right ) + \sqrt {-a^{2} + a b} \log \left (b\right )\right )} \mathrm {sgn}\left (\sin \left (x\right )\right )}{2 \, \sqrt {-a^{2} + a b} \sqrt {a - b}} + \frac {\frac {2 \, \sqrt {a - b} \arctan \left (\frac {{\left (\sqrt {a - b} \sin \left (x\right ) - \sqrt {a \sin \left (x\right )^{2} - b \sin \left (x\right )^{2} + b}\right )}^{2} - 2 \, a + b}{2 \, \sqrt {-a^{2} + a b}}\right )}{\sqrt {-a^{2} + a b}} + \frac {\log \left ({\left (\sqrt {a - b} \sin \left (x\right ) - \sqrt {a \sin \left (x\right )^{2} - b \sin \left (x\right )^{2} + b}\right )}^{2}\right )}{\sqrt {a - b}}}{2 \, \mathrm {sgn}\left (\sin \left (x\right )\right )} \] Input:

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

Output:

-1/2*(2*a*arctan(-(a - b)/sqrt(-a^2 + a*b)) - 2*b*arctan(-(a - b)/sqrt(-a^ 
2 + a*b)) + sqrt(-a^2 + a*b)*log(b))*sgn(sin(x))/(sqrt(-a^2 + a*b)*sqrt(a 
- b)) + 1/2*(2*sqrt(a - b)*arctan(1/2*((sqrt(a - b)*sin(x) - sqrt(a*sin(x) 
^2 - b*sin(x)^2 + b))^2 - 2*a + b)/sqrt(-a^2 + a*b))/sqrt(-a^2 + a*b) + lo 
g((sqrt(a - b)*sin(x) - sqrt(a*sin(x)^2 - b*sin(x)^2 + b))^2)/sqrt(a - b)) 
/sgn(sin(x))
 

Mupad [B] (verification not implemented)

Time = 0.23 (sec) , antiderivative size = 93, normalized size of antiderivative = 1.55 \[ \int \frac {\tan (x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\frac {\mathrm {atanh}\left (\frac {\sqrt {a+\frac {b}{{\mathrm {tan}\left (x\right )}^2}}}{\sqrt {a-b}}+\frac {2\,\sqrt {a-b}\,\sqrt {a+\frac {b}{{\mathrm {tan}\left (x\right )}^2}}}{b}-\frac {2\,a\,\sqrt {a+\frac {b}{{\mathrm {tan}\left (x\right )}^2}}}{b\,\sqrt {a-b}}\right )}{\sqrt {a-b}}+\frac {\mathrm {atanh}\left (\frac {\sqrt {a+\frac {b}{{\mathrm {tan}\left (x\right )}^2}}}{\sqrt {a}}\right )}{\sqrt {a}} \] Input:

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

Output:

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

Reduce [F]

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

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

Output:

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