\(\int \tan ^2(e+f x) \sqrt {a+b \tan ^2(e+f x)} \, dx\) [301]

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

Optimal result

Integrand size = 25, antiderivative size = 123 \[ \int \tan ^2(e+f x) \sqrt {a+b \tan ^2(e+f x)} \, dx=-\frac {\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \tan (e+f x)}{\sqrt {a+b \tan ^2(e+f x)}}\right )}{f}+\frac {(a-2 b) \text {arctanh}\left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a+b \tan ^2(e+f x)}}\right )}{2 \sqrt {b} f}+\frac {\tan (e+f x) \sqrt {a+b \tan ^2(e+f x)}}{2 f} \] Output:

-(a-b)^(1/2)*arctan((a-b)^(1/2)*tan(f*x+e)/(a+b*tan(f*x+e)^2)^(1/2))/f+1/2 
*(a-2*b)*arctanh(b^(1/2)*tan(f*x+e)/(a+b*tan(f*x+e)^2)^(1/2))/b^(1/2)/f+1/ 
2*tan(f*x+e)*(a+b*tan(f*x+e)^2)^(1/2)/f
 

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 4 vs. order 3 in optimal.

Time = 3.83 (sec) , antiderivative size = 251, normalized size of antiderivative = 2.04 \[ \int \tan ^2(e+f x) \sqrt {a+b \tan ^2(e+f x)} \, dx=\frac {\left (-\sqrt {2} a \sqrt {\frac {(a+b+(a-b) \cos (2 (e+f x))) \csc ^2(e+f x)}{b}} \operatorname {EllipticF}\left (\arcsin \left (\frac {\sqrt {\frac {(a+b+(a-b) \cos (2 (e+f x))) \csc ^2(e+f x)}{b}}}{\sqrt {2}}\right ),1\right )+2 \sqrt {2} a \sqrt {\frac {(a+b+(a-b) \cos (2 (e+f x))) \csc ^2(e+f x)}{b}} \operatorname {EllipticPi}\left (-\frac {b}{a-b},\arcsin \left (\frac {\sqrt {\frac {(a+b+(a-b) \cos (2 (e+f x))) \csc ^2(e+f x)}{b}}}{\sqrt {2}}\right ),1\right )+(a+b+(a-b) \cos (2 (e+f x))) \sec ^2(e+f x)\right ) \tan (e+f x)}{2 \sqrt {2} f \sqrt {(a+b+(a-b) \cos (2 (e+f x))) \sec ^2(e+f x)}} \] Input:

Integrate[Tan[e + f*x]^2*Sqrt[a + b*Tan[e + f*x]^2],x]
 

Output:

((-(Sqrt[2]*a*Sqrt[((a + b + (a - b)*Cos[2*(e + f*x)])*Csc[e + f*x]^2)/b]* 
EllipticF[ArcSin[Sqrt[((a + b + (a - b)*Cos[2*(e + f*x)])*Csc[e + f*x]^2)/ 
b]/Sqrt[2]], 1]) + 2*Sqrt[2]*a*Sqrt[((a + b + (a - b)*Cos[2*(e + f*x)])*Cs 
c[e + f*x]^2)/b]*EllipticPi[-(b/(a - b)), ArcSin[Sqrt[((a + b + (a - b)*Co 
s[2*(e + f*x)])*Csc[e + f*x]^2)/b]/Sqrt[2]], 1] + (a + b + (a - b)*Cos[2*( 
e + f*x)])*Sec[e + f*x]^2)*Tan[e + f*x])/(2*Sqrt[2]*f*Sqrt[(a + b + (a - b 
)*Cos[2*(e + f*x)])*Sec[e + f*x]^2])
 

Rubi [A] (verified)

Time = 0.53 (sec) , antiderivative size = 120, normalized size of antiderivative = 0.98, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.320, 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 \tan ^2(e+f x) \sqrt {a+b \tan ^2(e+f x)} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \tan (e+f x)^2 \sqrt {a+b \tan (e+f x)^2}dx\)

\(\Big \downarrow \) 4153

\(\displaystyle \frac {\int \frac {\tan ^2(e+f x) \sqrt {b \tan ^2(e+f x)+a}}{\tan ^2(e+f x)+1}d\tan (e+f x)}{f}\)

\(\Big \downarrow \) 380

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

\(\Big \downarrow \) 398

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

\(\Big \downarrow \) 224

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

\(\Big \downarrow \) 219

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

\(\Big \downarrow \) 291

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

\(\Big \downarrow \) 216

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

Input:

Int[Tan[e + f*x]^2*Sqrt[a + b*Tan[e + f*x]^2],x]
 

Output:

((-2*Sqrt[a - b]*ArcTan[(Sqrt[a - b]*Tan[e + f*x])/Sqrt[a + b*Tan[e + f*x] 
^2]] + ((a - 2*b)*ArcTanh[(Sqrt[b]*Tan[e + f*x])/Sqrt[a + b*Tan[e + f*x]^2 
]])/Sqrt[b])/2 + (Tan[e + f*x]*Sqrt[a + b*Tan[e + f*x]^2])/2)/f
 

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. \(222\) vs. \(2(105)=210\).

Time = 0.82 (sec) , antiderivative size = 223, normalized size of antiderivative = 1.81

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

Input:

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

Output:

1/f*(1/2*tan(f*x+e)*(a+b*tan(f*x+e)^2)^(1/2)+1/2*a/b^(1/2)*ln(b^(1/2)*tan( 
f*x+e)+(a+b*tan(f*x+e)^2)^(1/2))-b*(ln(b^(1/2)*tan(f*x+e)+(a+b*tan(f*x+e)^ 
2)^(1/2))/b^(1/2)-(b^4*(a-b))^(1/2)/b^2/(a-b)*arctan(b^2*(a-b)/(b^4*(a-b)) 
^(1/2)/(a+b*tan(f*x+e)^2)^(1/2)*tan(f*x+e)))-a*(b^4*(a-b))^(1/2)/b^2/(a-b) 
*arctan(b^2*(a-b)/(b^4*(a-b))^(1/2)/(a+b*tan(f*x+e)^2)^(1/2)*tan(f*x+e)))
 

Fricas [A] (verification not implemented)

Time = 0.23 (sec) , antiderivative size = 523, normalized size of antiderivative = 4.25 \[ \int \tan ^2(e+f x) \sqrt {a+b \tan ^2(e+f x)} \, dx=\left [-\frac {{\left (a - 2 \, b\right )} \sqrt {b} \log \left (2 \, b \tan \left (f x + e\right )^{2} - 2 \, \sqrt {b \tan \left (f x + e\right )^{2} + a} \sqrt {b} \tan \left (f x + e\right ) + a\right ) - 2 \, \sqrt {-a + b} b \log \left (-\frac {{\left (a - 2 \, b\right )} \tan \left (f x + e\right )^{2} - 2 \, \sqrt {b \tan \left (f x + e\right )^{2} + a} \sqrt {-a + b} \tan \left (f x + e\right ) - a}{\tan \left (f x + e\right )^{2} + 1}\right ) - 2 \, \sqrt {b \tan \left (f x + e\right )^{2} + a} b \tan \left (f x + e\right )}{4 \, b f}, -\frac {4 \, \sqrt {a - b} b \arctan \left (\frac {\sqrt {a - b} \tan \left (f x + e\right )}{\sqrt {b \tan \left (f x + e\right )^{2} + a}}\right ) + {\left (a - 2 \, b\right )} \sqrt {b} \log \left (2 \, b \tan \left (f x + e\right )^{2} - 2 \, \sqrt {b \tan \left (f x + e\right )^{2} + a} \sqrt {b} \tan \left (f x + e\right ) + a\right ) - 2 \, \sqrt {b \tan \left (f x + e\right )^{2} + a} b \tan \left (f x + e\right )}{4 \, b f}, -\frac {{\left (a - 2 \, b\right )} \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \tan \left (f x + e\right )}{\sqrt {b \tan \left (f x + e\right )^{2} + a}}\right ) - \sqrt {-a + b} b \log \left (-\frac {{\left (a - 2 \, b\right )} \tan \left (f x + e\right )^{2} - 2 \, \sqrt {b \tan \left (f x + e\right )^{2} + a} \sqrt {-a + b} \tan \left (f x + e\right ) - a}{\tan \left (f x + e\right )^{2} + 1}\right ) - \sqrt {b \tan \left (f x + e\right )^{2} + a} b \tan \left (f x + e\right )}{2 \, b f}, -\frac {2 \, \sqrt {a - b} b \arctan \left (\frac {\sqrt {a - b} \tan \left (f x + e\right )}{\sqrt {b \tan \left (f x + e\right )^{2} + a}}\right ) + {\left (a - 2 \, b\right )} \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \tan \left (f x + e\right )}{\sqrt {b \tan \left (f x + e\right )^{2} + a}}\right ) - \sqrt {b \tan \left (f x + e\right )^{2} + a} b \tan \left (f x + e\right )}{2 \, b f}\right ] \] Input:

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

Output:

[-1/4*((a - 2*b)*sqrt(b)*log(2*b*tan(f*x + e)^2 - 2*sqrt(b*tan(f*x + e)^2 
+ a)*sqrt(b)*tan(f*x + e) + a) - 2*sqrt(-a + b)*b*log(-((a - 2*b)*tan(f*x 
+ e)^2 - 2*sqrt(b*tan(f*x + e)^2 + a)*sqrt(-a + b)*tan(f*x + e) - a)/(tan( 
f*x + e)^2 + 1)) - 2*sqrt(b*tan(f*x + e)^2 + a)*b*tan(f*x + e))/(b*f), -1/ 
4*(4*sqrt(a - b)*b*arctan(sqrt(a - b)*tan(f*x + e)/sqrt(b*tan(f*x + e)^2 + 
 a)) + (a - 2*b)*sqrt(b)*log(2*b*tan(f*x + e)^2 - 2*sqrt(b*tan(f*x + e)^2 
+ a)*sqrt(b)*tan(f*x + e) + a) - 2*sqrt(b*tan(f*x + e)^2 + a)*b*tan(f*x + 
e))/(b*f), -1/2*((a - 2*b)*sqrt(-b)*arctan(sqrt(-b)*tan(f*x + e)/sqrt(b*ta 
n(f*x + e)^2 + a)) - sqrt(-a + b)*b*log(-((a - 2*b)*tan(f*x + e)^2 - 2*sqr 
t(b*tan(f*x + e)^2 + a)*sqrt(-a + b)*tan(f*x + e) - a)/(tan(f*x + e)^2 + 1 
)) - sqrt(b*tan(f*x + e)^2 + a)*b*tan(f*x + e))/(b*f), -1/2*(2*sqrt(a - b) 
*b*arctan(sqrt(a - b)*tan(f*x + e)/sqrt(b*tan(f*x + e)^2 + a)) + (a - 2*b) 
*sqrt(-b)*arctan(sqrt(-b)*tan(f*x + e)/sqrt(b*tan(f*x + e)^2 + a)) - sqrt( 
b*tan(f*x + e)^2 + a)*b*tan(f*x + e))/(b*f)]
 

Sympy [F]

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

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

Output:

Integral(sqrt(a + b*tan(e + f*x)**2)*tan(e + f*x)**2, x)
 

Maxima [F]

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

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

Output:

integrate(sqrt(b*tan(f*x + e)^2 + a)*tan(f*x + e)^2, x)
 

Giac [F(-2)]

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

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

Output:

Exception raised: TypeError >> an error occurred running a Giac command:IN 
PUT:sage2:=int(sage0,sageVARx):;OUTPUT:sym2poly/r2sym(const gen & e,const 
index_m & i,const vecteur & l) Error: Bad Argument Value
 

Mupad [F(-1)]

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

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

Output:

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

Reduce [F]

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

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

Output:

int(sqrt(tan(e + f*x)**2*b + a)*tan(e + f*x)**2,x)