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

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

Optimal result

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

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

Mathematica [A] (verified)

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

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

Output:

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

Rubi [A] (verified)

Time = 0.48 (sec) , antiderivative size = 90, normalized size of antiderivative = 1.06, number of steps used = 11, number of rules used = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.476, Rules used = {3042, 4382, 3042, 4549, 27, 3042, 4270, 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))^2} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4382

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4549

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

\(\Big \downarrow \) 27

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4270

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3138

\(\displaystyle \frac {\tan (c+d x)}{a d (a+b \sec (c+d x))}-\frac {\frac {x}{a}-\frac {2 \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 d}}{a}\)

\(\Big \downarrow \) 221

\(\displaystyle \frac {\tan (c+d x)}{a d (a+b \sec (c+d x))}-\frac {\frac {x}{a}-\frac {2 b \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}}}{a}\)

Input:

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

Output:

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

Defintions of rubi rules used

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, 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 4270
Int[(csc[(c_.) + (d_.)*(x_)]*(b_.) + (a_))^(-1), x_Symbol] :> Simp[x/a, x] 
- Simp[1/a   Int[1/(1 + (a/b)*Sin[c + d*x]), x], x] /; FreeQ[{a, b, c, d}, 
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 4549
Int[((A_.) + csc[(e_.) + (f_.)*(x_)]^2*(C_.))*(csc[(e_.) + (f_.)*(x_)]*(b_. 
) + (a_))^(m_), x_Symbol] :> Simp[(A*b^2 + a^2*C)*Cot[e + f*x]*((a + b*Csc[ 
e + f*x])^(m + 1)/(a*f*(m + 1)*(a^2 - b^2))), x] + Simp[1/(a*(m + 1)*(a^2 - 
 b^2))   Int[(a + b*Csc[e + f*x])^(m + 1)*Simp[A*(a^2 - b^2)*(m + 1) - a*b* 
(A + C)*(m + 1)*Csc[e + f*x] + (A*b^2 + a^2*C)*(m + 2)*Csc[e + f*x]^2, x], 
x], x] /; FreeQ[{a, b, e, f, A, C}, x] && NeQ[a^2 - b^2, 0] && IntegerQ[2*m 
] && LtQ[m, -1]
 
Maple [A] (verified)

Time = 0.36 (sec) , antiderivative size = 115, normalized size of antiderivative = 1.35

method result size
derivativedivides \(\frac {\frac {-\frac {2 a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} b -a -b}+\frac {2 b \,\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 )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}}{a^{2}}-\frac {2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{a^{2}}}{d}\) \(115\)
default \(\frac {\frac {-\frac {2 a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} b -a -b}+\frac {2 b \,\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 )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}}{a^{2}}-\frac {2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{a^{2}}}{d}\) \(115\)
risch \(-\frac {x}{a^{2}}+\frac {2 i \left (b \,{\mathrm e}^{i \left (d x +c \right )}+a \right )}{a^{2} d \left (a \,{\mathrm e}^{2 i \left (d x +c \right )}+2 b \,{\mathrm e}^{i \left (d x +c \right )}+a \right )}-\frac {b \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right )}{\sqrt {a^{2}-b^{2}}\, d \,a^{2}}+\frac {b \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right )}{\sqrt {a^{2}-b^{2}}\, d \,a^{2}}\) \(200\)

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 162 vs. \(2 (76) = 152\).

Time = 0.14 (sec) , antiderivative size = 383, normalized size of antiderivative = 4.51 \[ \int \frac {\tan ^2(c+d x)}{(a+b \sec (c+d x))^2} \, dx=\left [-\frac {2 \, {\left (a^{3} - a b^{2}\right )} d x \cos \left (d x + c\right ) + 2 \, {\left (a^{2} b - b^{3}\right )} d x - {\left (a b \cos \left (d x + c\right ) + b^{2}\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 \, {\left (a^{3} - a b^{2}\right )} \sin \left (d x + c\right )}{2 \, {\left ({\left (a^{5} - a^{3} b^{2}\right )} d \cos \left (d x + c\right ) + {\left (a^{4} b - a^{2} b^{3}\right )} d\right )}}, -\frac {{\left (a^{3} - a b^{2}\right )} d x \cos \left (d x + c\right ) + {\left (a^{2} b - b^{3}\right )} d x - {\left (a b \cos \left (d x + c\right ) + b^{2}\right )} \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 ) - {\left (a^{3} - a b^{2}\right )} \sin \left (d x + c\right )}{{\left (a^{5} - a^{3} b^{2}\right )} d \cos \left (d x + c\right ) + {\left (a^{4} b - a^{2} b^{3}\right )} d}\right ] \] Input:

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

Output:

[-1/2*(2*(a^3 - a*b^2)*d*x*cos(d*x + c) + 2*(a^2*b - b^3)*d*x - (a*b*cos(d 
*x + c) + b^2)*sqrt(a^2 - b^2)*log((2*a*b*cos(d*x + c) - (a^2 - 2*b^2)*cos 
(d*x + c)^2 + 2*sqrt(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)) - 2*(a^3 - a*b^2)* 
sin(d*x + c))/((a^5 - a^3*b^2)*d*cos(d*x + c) + (a^4*b - a^2*b^3)*d), -((a 
^3 - a*b^2)*d*x*cos(d*x + c) + (a^2*b - b^3)*d*x - (a*b*cos(d*x + c) + b^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^3 - a*b^2)*sin(d*x + c))/((a^5 - a^3*b^2)*d*cos(d* 
x + c) + (a^4*b - a^2*b^3)*d)]
 

Sympy [F]

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

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

Output:

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

Maxima [F(-2)]

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

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

Giac [A] (verification not implemented)

Time = 0.27 (sec) , antiderivative size = 144, normalized size of antiderivative = 1.69 \[ \int \frac {\tan ^2(c+d x)}{(a+b \sec (c+d x))^2} \, dx=\frac {\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 )} b}{\sqrt {-a^{2} + b^{2}} a^{2}} - \frac {d x + c}{a^{2}} - \frac {2 \, \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{{\left (a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - a - b\right )} a}}{d} \] Input:

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

Output:

(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)))*b/(sqrt(-a^2 + b 
^2)*a^2) - (d*x + c)/a^2 - 2*tan(1/2*d*x + 1/2*c)/((a*tan(1/2*d*x + 1/2*c) 
^2 - b*tan(1/2*d*x + 1/2*c)^2 - a - b)*a))/d
 

Mupad [B] (verification not implemented)

Time = 11.22 (sec) , antiderivative size = 551, normalized size of antiderivative = 6.48 \[ \int \frac {\tan ^2(c+d x)}{(a+b \sec (c+d x))^2} \, dx=-\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^2\,d}-\frac {b^2\,\left (a\,\sin \left (c+d\,x\right )+2\,\mathrm {atanh}\left (\frac {2\,b^3\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,{\left (a^2-b^2\right )}^{3/2}-a^5\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}+2\,b^5\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}-3\,a^2\,b^3\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}+a^3\,b^2\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}+a^4\,b\,\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^2-a^3\right )\,\left (b\,\left (a^2-b^2\right )+a\,b^2-a^2\,b-a^3+b^3\right )}\right )\,\sqrt {a^2-b^2}\right )-a^3\,\sin \left (c+d\,x\right )+2\,a\,b\,\cos \left (c+d\,x\right )\,\mathrm {atanh}\left (\frac {2\,b^3\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,{\left (a^2-b^2\right )}^{3/2}-a^5\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}+2\,b^5\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}-3\,a^2\,b^3\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}+a^3\,b^2\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}+a^4\,b\,\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^2-a^3\right )\,\left (b\,\left (a^2-b^2\right )+a\,b^2-a^2\,b-a^3+b^3\right )}\right )\,\sqrt {a^2-b^2}}{a^2\,d\,\left (a^2-b^2\right )\,\left (b+a\,\cos \left (c+d\,x\right )\right )} \] Input:

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

Output:

- (2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/(a^2*d) - (b^2*(a*sin(c 
+ d*x) + 2*atanh((2*b^3*sin(c/2 + (d*x)/2)*(a^2 - b^2)^(3/2) - a^5*sin(c/2 
 + (d*x)/2)*(a^2 - b^2)^(1/2) + 2*b^5*sin(c/2 + (d*x)/2)*(a^2 - b^2)^(1/2) 
 - 3*a^2*b^3*sin(c/2 + (d*x)/2)*(a^2 - b^2)^(1/2) + a^3*b^2*sin(c/2 + (d*x 
)/2)*(a^2 - b^2)^(1/2) + a^4*b*sin(c/2 + (d*x)/2)*(a^2 - b^2)^(1/2))/(cos( 
c/2 + (d*x)/2)*(a*b^2 - a^3)*(b*(a^2 - b^2) + a*b^2 - a^2*b - a^3 + b^3))) 
*(a^2 - b^2)^(1/2)) - a^3*sin(c + d*x) + 2*a*b*cos(c + d*x)*atanh((2*b^3*s 
in(c/2 + (d*x)/2)*(a^2 - b^2)^(3/2) - a^5*sin(c/2 + (d*x)/2)*(a^2 - b^2)^( 
1/2) + 2*b^5*sin(c/2 + (d*x)/2)*(a^2 - b^2)^(1/2) - 3*a^2*b^3*sin(c/2 + (d 
*x)/2)*(a^2 - b^2)^(1/2) + a^3*b^2*sin(c/2 + (d*x)/2)*(a^2 - b^2)^(1/2) + 
a^4*b*sin(c/2 + (d*x)/2)*(a^2 - b^2)^(1/2))/(cos(c/2 + (d*x)/2)*(a*b^2 - a 
^3)*(b*(a^2 - b^2) + a*b^2 - a^2*b - a^3 + b^3)))*(a^2 - b^2)^(1/2))/(a^2* 
d*(a^2 - b^2)*(b + a*cos(c + d*x)))
 

Reduce [B] (verification not implemented)

Time = 0.16 (sec) , antiderivative size = 216, normalized size of antiderivative = 2.54 \[ \int \frac {\tan ^2(c+d x)}{(a+b \sec (c+d x))^2} \, 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 ) a b +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 ) b^{2}-\cos \left (d x +c \right ) a^{3} d x +\cos \left (d x +c \right ) a \,b^{2} d x +\sin \left (d x +c \right ) a^{3}-\sin \left (d x +c \right ) a \,b^{2}-a^{2} b d x +b^{3} d x}{a^{2} d \left (\cos \left (d x +c \right ) a^{3}-\cos \left (d x +c \right ) a \,b^{2}+a^{2} b -b^{3}\right )} \] Input:

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

Output:

(2*sqrt( - a**2 + b**2)*atan((tan((c + d*x)/2)*a - tan((c + d*x)/2)*b)/sqr 
t( - a**2 + b**2))*cos(c + d*x)*a*b + 2*sqrt( - a**2 + b**2)*atan((tan((c 
+ d*x)/2)*a - tan((c + d*x)/2)*b)/sqrt( - a**2 + b**2))*b**2 - cos(c + d*x 
)*a**3*d*x + cos(c + d*x)*a*b**2*d*x + sin(c + d*x)*a**3 - sin(c + d*x)*a* 
b**2 - a**2*b*d*x + b**3*d*x)/(a**2*d*(cos(c + d*x)*a**3 - cos(c + d*x)*a* 
b**2 + a**2*b - b**3))