\(\int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx\) [293]

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

Optimal result

Integrand size = 21, antiderivative size = 76 \[ \int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx=-\frac {x}{a}+\frac {\text {arctanh}(\sin (c+d x))}{b d}-\frac {2 \sqrt {a-b} \sqrt {a+b} \text {arctanh}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a b d} \] Output:

-x/a+arctanh(sin(d*x+c))/b/d-2*(a-b)^(1/2)*(a+b)^(1/2)*arctanh((a-b)^(1/2) 
*tan(1/2*d*x+1/2*c)/(a+b)^(1/2))/a/b/d
 

Mathematica [A] (verified)

Time = 0.28 (sec) , antiderivative size = 115, normalized size of antiderivative = 1.51 \[ \int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx=-\frac {b c+b d x-2 \sqrt {a^2-b^2} \text {arctanh}\left (\frac {(-a+b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2-b^2}}\right )+a \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )-a \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )}{a b d} \] Input:

Integrate[Tan[c + d*x]^2/(a + b*Sec[c + d*x]),x]
 

Output:

-((b*c + b*d*x - 2*Sqrt[a^2 - b^2]*ArcTanh[((-a + b)*Tan[(c + d*x)/2])/Sqr 
t[a^2 - b^2]] + a*Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] - a*Log[Cos[(c 
+ d*x)/2] + Sin[(c + d*x)/2]])/(a*b*d))
 

Rubi [A] (verified)

Time = 0.64 (sec) , antiderivative size = 88, normalized size of antiderivative = 1.16, number of steps used = 14, number of rules used = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.619, Rules used = {3042, 4382, 3042, 4539, 25, 3042, 4257, 4407, 3042, 4318, 3042, 3138, 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 ^2(c+d x)}{a+b \sec (c+d x)} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4382

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4539

\(\displaystyle \frac {\int -\frac {b+a \sec (c+d x)}{a+b \sec (c+d x)}dx}{b}+\frac {\int \sec (c+d x)dx}{b}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {\int \sec (c+d x)dx}{b}-\frac {\int \frac {b+a \sec (c+d x)}{a+b \sec (c+d x)}dx}{b}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \csc \left (c+d x+\frac {\pi }{2}\right )dx}{b}-\frac {\int \frac {b+a \csc \left (c+d x+\frac {\pi }{2}\right )}{a+b \csc \left (c+d x+\frac {\pi }{2}\right )}dx}{b}\)

\(\Big \downarrow \) 4257

\(\displaystyle \frac {\text {arctanh}(\sin (c+d x))}{b d}-\frac {\int \frac {b+a \csc \left (c+d x+\frac {\pi }{2}\right )}{a+b \csc \left (c+d x+\frac {\pi }{2}\right )}dx}{b}\)

\(\Big \downarrow \) 4407

\(\displaystyle \frac {\text {arctanh}(\sin (c+d x))}{b d}-\frac {\frac {\left (a^2-b^2\right ) \int \frac {\sec (c+d x)}{a+b \sec (c+d x)}dx}{a}+\frac {b x}{a}}{b}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\text {arctanh}(\sin (c+d x))}{b d}-\frac {\frac {\left (a^2-b^2\right ) \int \frac {\csc \left (c+d x+\frac {\pi }{2}\right )}{a+b \csc \left (c+d x+\frac {\pi }{2}\right )}dx}{a}+\frac {b x}{a}}{b}\)

\(\Big \downarrow \) 4318

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3138

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

\(\Big \downarrow \) 221

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

Input:

Int[Tan[c + d*x]^2/(a + b*Sec[c + d*x]),x]
 

Output:

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

Defintions of rubi rules used

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

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 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3138
Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{ 
e = FreeFactors[Tan[(c + d*x)/2], x]}, Simp[2*(e/d)   Subst[Int[1/(a + b + 
(a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] 
 && NeQ[a^2 - b^2, 0]
 

rule 4257
Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] 
 /; FreeQ[{c, d}, x]
 

rule 4318
Int[csc[(e_.) + (f_.)*(x_)]/(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_)), x_Symbo 
l] :> Simp[1/b   Int[1/(1 + (a/b)*Sin[e + f*x]), x], x] /; FreeQ[{a, b, e, 
f}, x] && NeQ[a^2 - b^2, 0]
 

rule 4382
Int[cot[(c_.) + (d_.)*(x_)]^2*(csc[(c_.) + (d_.)*(x_)]*(b_.) + (a_))^(n_), 
x_Symbol] :> Int[(-1 + Csc[c + d*x]^2)*(a + b*Csc[c + d*x])^n, x] /; FreeQ[ 
{a, b, c, d, n}, x] && NeQ[a^2 - b^2, 0]
 

rule 4407
Int[(csc[(e_.) + (f_.)*(x_)]*(d_.) + (c_))/(csc[(e_.) + (f_.)*(x_)]*(b_.) + 
 (a_)), x_Symbol] :> Simp[c*(x/a), x] - Simp[(b*c - a*d)/a   Int[Csc[e + f* 
x]/(a + b*Csc[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c 
- a*d, 0]
 

rule 4539
Int[((A_.) + csc[(e_.) + (f_.)*(x_)]^2*(C_.))/(csc[(e_.) + (f_.)*(x_)]*(b_. 
) + (a_)), x_Symbol] :> Simp[C/b   Int[Csc[e + f*x], x], x] + Simp[1/b   In 
t[(A*b - a*C*Csc[e + f*x])/(a + b*Csc[e + f*x]), x], x] /; FreeQ[{a, b, e, 
f, A, C}, x]
 
Maple [A] (verified)

Time = 0.25 (sec) , antiderivative size = 108, normalized size of antiderivative = 1.42

method result size
derivativedivides \(\frac {\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{b}-\frac {2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{a}-\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{b}-\frac {2 \left (a +b \right ) \left (a -b \right ) \operatorname {arctanh}\left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{b a \sqrt {\left (a +b \right ) \left (a -b \right )}}}{d}\) \(108\)
default \(\frac {\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{b}-\frac {2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{a}-\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{b}-\frac {2 \left (a +b \right ) \left (a -b \right ) \operatorname {arctanh}\left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{b a \sqrt {\left (a +b \right ) \left (a -b \right )}}}{d}\) \(108\)
risch \(-\frac {x}{a}-\frac {\sqrt {a^{2}-b^{2}}\, \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i \sqrt {a^{2}-b^{2}}+b}{a}\right )}{d b a}+\frac {\sqrt {a^{2}-b^{2}}\, \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i \sqrt {a^{2}-b^{2}}-b}{a}\right )}{d b a}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{d b}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{d b}\) \(157\)

Input:

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

Output:

1/d*(1/b*ln(tan(1/2*d*x+1/2*c)+1)-2/a*arctan(tan(1/2*d*x+1/2*c))-1/b*ln(ta 
n(1/2*d*x+1/2*c)-1)-2/b*(a+b)*(a-b)/a/((a+b)*(a-b))^(1/2)*arctanh((a-b)*ta 
n(1/2*d*x+1/2*c)/((a+b)*(a-b))^(1/2)))
 

Fricas [A] (verification not implemented)

Time = 0.18 (sec) , antiderivative size = 253, normalized size of antiderivative = 3.33 \[ \int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\left [-\frac {2 \, b d x - a \log \left (\sin \left (d x + c\right ) + 1\right ) + a \log \left (-\sin \left (d x + c\right ) + 1\right ) - \sqrt {a^{2} - b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) - {\left (a^{2} - 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, \sqrt {a^{2} - b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )} \sin \left (d x + c\right ) + 2 \, a^{2} - b^{2}}{a^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + b^{2}}\right )}{2 \, a b d}, -\frac {2 \, b d x - a \log \left (\sin \left (d x + c\right ) + 1\right ) + a \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, \sqrt {-a^{2} + b^{2}} \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )}}{{\left (a^{2} - b^{2}\right )} \sin \left (d x + c\right )}\right )}{2 \, a b d}\right ] \] Input:

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

Output:

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

Sympy [F]

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

integrate(tan(d*x+c)**2/(a+b*sec(d*x+c)),x)
 

Output:

Integral(tan(c + d*x)**2/(a + b*sec(c + d*x)), x)
 

Maxima [F(-2)]

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

integrate(tan(d*x+c)^2/(a+b*sec(d*x+c)),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(4*a^2-4*b^2>0)', see `assume?` f 
or more de
 

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 140 vs. \(2 (67) = 134\).

Time = 0.24 (sec) , antiderivative size = 140, normalized size of antiderivative = 1.84 \[ \int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx=-\frac {\frac {d x + c}{a} - \frac {\log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{b} + \frac {\log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{b} + \frac {2 \, {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {-a^{2} + b^{2}}}\right )\right )} {\left (a^{2} - b^{2}\right )}}{\sqrt {-a^{2} + b^{2}} a b}}{d} \] Input:

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

Output:

-((d*x + c)/a - log(abs(tan(1/2*d*x + 1/2*c) + 1))/b + log(abs(tan(1/2*d*x 
 + 1/2*c) - 1))/b + 2*(pi*floor(1/2*(d*x + c)/pi + 1/2)*sgn(-2*a + 2*b) + 
arctan(-(a*tan(1/2*d*x + 1/2*c) - b*tan(1/2*d*x + 1/2*c))/sqrt(-a^2 + b^2) 
))*(a^2 - b^2)/(sqrt(-a^2 + b^2)*a*b))/d
 

Mupad [B] (verification not implemented)

Time = 11.44 (sec) , antiderivative size = 121, normalized size of antiderivative = 1.59 \[ \int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\frac {2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b\,d}-\frac {2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{a\,d}-\frac {2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (a+b\right )}\right )\,\sqrt {a^2-b^2}}{a\,b\,d} \] Input:

int(tan(c + d*x)^2/(a + b/cos(c + d*x)),x)
 

Output:

(2*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/(b*d) - (2*atan(sin(c/2 + 
 (d*x)/2)/cos(c/2 + (d*x)/2)))/(a*d) - (2*atanh((sin(c/2 + (d*x)/2)*(a^2 - 
 b^2)^(1/2))/(cos(c/2 + (d*x)/2)*(a + b)))*(a^2 - b^2)^(1/2))/(a*b*d)
 

Reduce [B] (verification not implemented)

Time = 0.16 (sec) , antiderivative size = 150, normalized size of antiderivative = 1.97 \[ \int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\frac {-2 \sqrt {-a^{2}+b^{2}}\, \mathit {atan} \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) a -\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) b}{\sqrt {-a^{2}+b^{2}}}\right ) \cos \left (d x +c \right )-\cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) a +\cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) a +\cos \left (d x +c \right ) \tan \left (d x +c \right ) b -\cos \left (d x +c \right ) b d x -\sin \left (d x +c \right ) b}{\cos \left (d x +c \right ) a b d} \] Input:

int(tan(d*x+c)^2/(a+b*sec(d*x+c)),x)
 

Output:

( - 2*sqrt( - a**2 + b**2)*atan((tan((c + d*x)/2)*a - tan((c + d*x)/2)*b)/ 
sqrt( - a**2 + b**2))*cos(c + d*x) - cos(c + d*x)*log(tan((c + d*x)/2) - 1 
)*a + cos(c + d*x)*log(tan((c + d*x)/2) + 1)*a + cos(c + d*x)*tan(c + d*x) 
*b - cos(c + d*x)*b*d*x - sin(c + d*x)*b)/(cos(c + d*x)*a*b*d)