\(\int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx\) [242]

Optimal result
Mathematica [B] (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 = 11, antiderivative size = 66 \[ \int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx=-\frac {x}{b^2}+\frac {2 a \arctan \left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {\cos (x)}{b (a+b \sin (x))} \] Output:

-x/b^2+2*a*arctan((b+a*tan(1/2*x))/(a^2-b^2)^(1/2))/b^2/(a^2-b^2)^(1/2)-co 
s(x)/b/(a+b*sin(x))
 

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(344\) vs. \(2(66)=132\).

Time = 1.64 (sec) , antiderivative size = 344, normalized size of antiderivative = 5.21 \[ \int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx=\frac {\cos (x) (1+\sin (x)) \left (2 a (a-b) \text {arctanh}\left (\frac {\sqrt {a-b} \sqrt {-\frac {b (1+\sin (x))}{a-b}}}{\sqrt {a+b} \sqrt {-\frac {b (-1+\sin (x))}{a+b}}}\right ) \sqrt {1-\sin (x)} (a+b \sin (x))+\sqrt {a+b} \left (-2 a \sqrt {a-b} \text {arctanh}\left (\frac {\sqrt {\frac {b (1+\sin (x))}{-a+b}}}{\sqrt {\frac {b-b \sin (x)}{a+b}}}\right ) \sqrt {1-\sin (x)} (a+b \sin (x))-(-a+b) \sqrt {\frac {b-b \sin (x)}{a+b}} \left (\sqrt {a-b} (a+b) \sqrt {1-\sin (x)} \sqrt {-\frac {b (1+\sin (x))}{a-b}}+2 \sqrt {b} \text {arcsinh}\left (\frac {\sqrt {a-b} \sqrt {-\frac {b (1+\sin (x))}{a-b}}}{\sqrt {2} \sqrt {b}}\right ) (a+b \sin (x))\right )\right )\right )}{(a-b)^{5/2} (a+b)^{3/2} \sqrt {1-\sin (x)} \left (-\frac {b (1+\sin (x))}{a-b}\right )^{3/2} \sqrt {\frac {b-b \sin (x)}{a+b}} (a+b \sin (x))} \] Input:

Integrate[(a*Sec[x] + b*Tan[x])^(-2),x]
 

Output:

(Cos[x]*(1 + Sin[x])*(2*a*(a - b)*ArcTanh[(Sqrt[a - b]*Sqrt[-((b*(1 + Sin[ 
x]))/(a - b))])/(Sqrt[a + b]*Sqrt[-((b*(-1 + Sin[x]))/(a + b))])]*Sqrt[1 - 
 Sin[x]]*(a + b*Sin[x]) + Sqrt[a + b]*(-2*a*Sqrt[a - b]*ArcTanh[Sqrt[(b*(1 
 + Sin[x]))/(-a + b)]/Sqrt[(b - b*Sin[x])/(a + b)]]*Sqrt[1 - Sin[x]]*(a + 
b*Sin[x]) - (-a + b)*Sqrt[(b - b*Sin[x])/(a + b)]*(Sqrt[a - b]*(a + b)*Sqr 
t[1 - Sin[x]]*Sqrt[-((b*(1 + Sin[x]))/(a - b))] + 2*Sqrt[b]*ArcSinh[(Sqrt[ 
a - b]*Sqrt[-((b*(1 + Sin[x]))/(a - b))])/(Sqrt[2]*Sqrt[b])]*(a + b*Sin[x] 
)))))/((a - b)^(5/2)*(a + b)^(3/2)*Sqrt[1 - Sin[x]]*(-((b*(1 + Sin[x]))/(a 
 - b)))^(3/2)*Sqrt[(b - b*Sin[x])/(a + b)]*(a + b*Sin[x]))
 

Rubi [A] (verified)

Time = 0.42 (sec) , antiderivative size = 77, normalized size of antiderivative = 1.17, number of steps used = 11, number of rules used = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.909, Rules used = {3042, 4891, 3042, 3172, 3042, 3214, 3042, 3139, 1083, 217}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4891

\(\displaystyle \int \frac {\cos ^2(x)}{(a+b \sin (x))^2}dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {\cos (x)^2}{(a+b \sin (x))^2}dx\)

\(\Big \downarrow \) 3172

\(\displaystyle -\frac {\int \frac {\sin (x)}{a+b \sin (x)}dx}{b}-\frac {\cos (x)}{b (a+b \sin (x))}\)

\(\Big \downarrow \) 3042

\(\displaystyle -\frac {\int \frac {\sin (x)}{a+b \sin (x)}dx}{b}-\frac {\cos (x)}{b (a+b \sin (x))}\)

\(\Big \downarrow \) 3214

\(\displaystyle -\frac {\frac {x}{b}-\frac {a \int \frac {1}{a+b \sin (x)}dx}{b}}{b}-\frac {\cos (x)}{b (a+b \sin (x))}\)

\(\Big \downarrow \) 3042

\(\displaystyle -\frac {\frac {x}{b}-\frac {a \int \frac {1}{a+b \sin (x)}dx}{b}}{b}-\frac {\cos (x)}{b (a+b \sin (x))}\)

\(\Big \downarrow \) 3139

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

\(\Big \downarrow \) 1083

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

\(\Big \downarrow \) 217

\(\displaystyle -\frac {\frac {x}{b}-\frac {2 a \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^2-b^2}}\right )}{b \sqrt {a^2-b^2}}}{b}-\frac {\cos (x)}{b (a+b \sin (x))}\)

Input:

Int[(a*Sec[x] + b*Tan[x])^(-2),x]
 

Output:

-((x/b - (2*a*ArcTan[(2*b + 2*a*Tan[x/2])/(2*Sqrt[a^2 - b^2])])/(b*Sqrt[a^ 
2 - b^2]))/b) - Cos[x]/(b*(a + b*Sin[x]))
 

Defintions of rubi rules used

rule 217
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(-(Rt[-a, 2]*Rt[-b, 2])^( 
-1))*ArcTan[Rt[-b, 2]*(x/Rt[-a, 2])], x] /; FreeQ[{a, b}, x] && PosQ[a/b] & 
& (LtQ[a, 0] || LtQ[b, 0])
 

rule 1083
Int[((a_) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Simp[-2   Subst[I 
nt[1/Simp[b^2 - 4*a*c - x^2, x], x], x, b + 2*c*x], x] /; FreeQ[{a, b, c}, 
x]
 

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

rule 3139
Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = Fre 
eFactors[Tan[(c + d*x)/2], x]}, Simp[2*(e/d)   Subst[Int[1/(a + 2*b*e*x + a 
*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 3172
Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x 
_)])^(m_), x_Symbol] :> Simp[g*(g*Cos[e + f*x])^(p - 1)*((a + b*Sin[e + f*x 
])^(m + 1)/(b*f*(m + 1))), x] + Simp[g^2*((p - 1)/(b*(m + 1)))   Int[(g*Cos 
[e + f*x])^(p - 2)*(a + b*Sin[e + f*x])^(m + 1)*Sin[e + f*x], x], x] /; Fre 
eQ[{a, b, e, f, g}, x] && NeQ[a^2 - b^2, 0] && LtQ[m, -1] && GtQ[p, 1] && I 
ntegersQ[2*m, 2*p]
 

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

rule 4891
Int[(u_.)*((b_.)*sec[(c_.) + (d_.)*(x_)]^(n_.) + (a_.)*tan[(c_.) + (d_.)*(x 
_)]^(n_.))^(p_), x_Symbol] :> Int[ActivateTrig[u]*Sec[c + d*x]^(n*p)*(b + a 
*Sin[c + d*x]^n)^p, x] /; FreeQ[{a, b, c, d}, x] && IntegersQ[n, p]
 
Maple [A] (verified)

Time = 1.54 (sec) , antiderivative size = 92, normalized size of antiderivative = 1.39

method result size
default \(-\frac {2 \arctan \left (\tan \left (\frac {x}{2}\right )\right )}{b^{2}}+\frac {\frac {2 \left (-\frac {b^{2} \tan \left (\frac {x}{2}\right )}{a}-b \right )}{\tan \left (\frac {x}{2}\right )^{2} a +2 b \tan \left (\frac {x}{2}\right )+a}+\frac {2 a \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{\sqrt {a^{2}-b^{2}}}}{b^{2}}\) \(92\)
risch \(-\frac {x}{b^{2}}-\frac {2 \left (i b +a \,{\mathrm e}^{i x}\right )}{b^{2} \left (b \,{\mathrm e}^{2 i x}-b +2 i a \,{\mathrm e}^{i x}\right )}-\frac {a \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}-a^{2}+b^{2}}{\sqrt {-a^{2}+b^{2}}\, b}\right )}{\sqrt {-a^{2}+b^{2}}\, b^{2}}+\frac {a \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}+a^{2}-b^{2}}{\sqrt {-a^{2}+b^{2}}\, b}\right )}{\sqrt {-a^{2}+b^{2}}\, b^{2}}\) \(172\)

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 121 vs. \(2 (60) = 120\).

Time = 0.10 (sec) , antiderivative size = 308, normalized size of antiderivative = 4.67 \[ \int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx=\left [-\frac {2 \, {\left (a^{2} b - b^{3}\right )} x \sin \left (x\right ) + {\left (a b \sin \left (x\right ) + a^{2}\right )} \sqrt {-a^{2} + b^{2}} \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2} + 2 \, {\left (a \cos \left (x\right ) \sin \left (x\right ) + b \cos \left (x\right )\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right ) + 2 \, {\left (a^{3} - a b^{2}\right )} x + 2 \, {\left (a^{2} b - b^{3}\right )} \cos \left (x\right )}{2 \, {\left (a^{3} b^{2} - a b^{4} + {\left (a^{2} b^{3} - b^{5}\right )} \sin \left (x\right )\right )}}, -\frac {{\left (a^{2} b - b^{3}\right )} x \sin \left (x\right ) + {\left (a b \sin \left (x\right ) + a^{2}\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \sin \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \cos \left (x\right )}\right ) + {\left (a^{3} - a b^{2}\right )} x + {\left (a^{2} b - b^{3}\right )} \cos \left (x\right )}{a^{3} b^{2} - a b^{4} + {\left (a^{2} b^{3} - b^{5}\right )} \sin \left (x\right )}\right ] \] Input:

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

Output:

[-1/2*(2*(a^2*b - b^3)*x*sin(x) + (a*b*sin(x) + a^2)*sqrt(-a^2 + b^2)*log( 
((2*a^2 - b^2)*cos(x)^2 - 2*a*b*sin(x) - a^2 - b^2 + 2*(a*cos(x)*sin(x) + 
b*cos(x))*sqrt(-a^2 + b^2))/(b^2*cos(x)^2 - 2*a*b*sin(x) - a^2 - b^2)) + 2 
*(a^3 - a*b^2)*x + 2*(a^2*b - b^3)*cos(x))/(a^3*b^2 - a*b^4 + (a^2*b^3 - b 
^5)*sin(x)), -((a^2*b - b^3)*x*sin(x) + (a*b*sin(x) + a^2)*sqrt(a^2 - b^2) 
*arctan(-(a*sin(x) + b)/(sqrt(a^2 - b^2)*cos(x))) + (a^3 - a*b^2)*x + (a^2 
*b - b^3)*cos(x))/(a^3*b^2 - a*b^4 + (a^2*b^3 - b^5)*sin(x))]
 

Sympy [F]

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

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

Output:

Integral((a*sec(x) + b*tan(x))**(-2), x)
 

Maxima [F(-2)]

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

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

Giac [A] (verification not implemented)

Time = 0.14 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.42 \[ \int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx=\frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (a\right ) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, x\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )} a}{\sqrt {a^{2} - b^{2}} b^{2}} - \frac {x}{b^{2}} - \frac {2 \, {\left (b \tan \left (\frac {1}{2} \, x\right ) + a\right )}}{{\left (a \tan \left (\frac {1}{2} \, x\right )^{2} + 2 \, b \tan \left (\frac {1}{2} \, x\right ) + a\right )} a b} \] Input:

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

Output:

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

Mupad [B] (verification not implemented)

Time = 15.67 (sec) , antiderivative size = 604, normalized size of antiderivative = 9.15 \[ \int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx=-\frac {x}{b^2}-\frac {\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )}{a}+\frac {2}{b}}{a\,{\mathrm {tan}\left (\frac {x}{2}\right )}^2+2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+a}-\frac {a\,\mathrm {atan}\left (\frac {\frac {a\,\left (\frac {32\,a^2}{b}+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a\,b^3-2\,a^3\,b\right )}{b^3}+\frac {a\,\left (32\,a\,b^2+64\,a^2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+\frac {a\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )\,1{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}}+\frac {a\,\left (\frac {32\,a^2}{b}+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a\,b^3-2\,a^3\,b\right )}{b^3}-\frac {a\,\left (32\,a\,b^2+64\,a^2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )-\frac {a\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )\,1{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}}}{\frac {128\,a^2\,\mathrm {tan}\left (\frac {x}{2}\right )}{b^3}+\frac {a\,\left (\frac {32\,a^2}{b}+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a\,b^3-2\,a^3\,b\right )}{b^3}+\frac {a\,\left (32\,a\,b^2+64\,a^2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+\frac {a\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}-\frac {a\,\left (\frac {32\,a^2}{b}+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a\,b^3-2\,a^3\,b\right )}{b^3}-\frac {a\,\left (32\,a\,b^2+64\,a^2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )-\frac {a\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}}\right )\,2{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}} \] Input:

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

Output:

- x/b^2 - ((2*tan(x/2))/a + 2/b)/(a + 2*b*tan(x/2) + a*tan(x/2)^2) - (a*at 
an(((a*((32*a^2)/b + (32*tan(x/2)*(2*a*b^3 - 2*a^3*b))/b^3 + (a*(32*a*b^2 
+ 64*a^2*b*tan(x/2) + (a*(32*a^2*b^3 + (32*tan(x/2)*(3*a*b^7 - 2*a^3*b^5)) 
/b^3))/(b^2*(b^2 - a^2)^(1/2))))/(b^2*(b^2 - a^2)^(1/2)))*1i)/(b^2*(b^2 - 
a^2)^(1/2)) + (a*((32*a^2)/b + (32*tan(x/2)*(2*a*b^3 - 2*a^3*b))/b^3 - (a* 
(32*a*b^2 + 64*a^2*b*tan(x/2) - (a*(32*a^2*b^3 + (32*tan(x/2)*(3*a*b^7 - 2 
*a^3*b^5))/b^3))/(b^2*(b^2 - a^2)^(1/2))))/(b^2*(b^2 - a^2)^(1/2)))*1i)/(b 
^2*(b^2 - a^2)^(1/2)))/((128*a^2*tan(x/2))/b^3 + (a*((32*a^2)/b + (32*tan( 
x/2)*(2*a*b^3 - 2*a^3*b))/b^3 + (a*(32*a*b^2 + 64*a^2*b*tan(x/2) + (a*(32* 
a^2*b^3 + (32*tan(x/2)*(3*a*b^7 - 2*a^3*b^5))/b^3))/(b^2*(b^2 - a^2)^(1/2) 
)))/(b^2*(b^2 - a^2)^(1/2))))/(b^2*(b^2 - a^2)^(1/2)) - (a*((32*a^2)/b + ( 
32*tan(x/2)*(2*a*b^3 - 2*a^3*b))/b^3 - (a*(32*a*b^2 + 64*a^2*b*tan(x/2) - 
(a*(32*a^2*b^3 + (32*tan(x/2)*(3*a*b^7 - 2*a^3*b^5))/b^3))/(b^2*(b^2 - a^2 
)^(1/2))))/(b^2*(b^2 - a^2)^(1/2))))/(b^2*(b^2 - a^2)^(1/2))))*2i)/(b^2*(b 
^2 - a^2)^(1/2))
 

Reduce [B] (verification not implemented)

Time = 0.17 (sec) , antiderivative size = 148, normalized size of antiderivative = 2.24 \[ \int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx=\frac {2 \sqrt {a^{2}-b^{2}}\, \mathit {atan} \left (\frac {\tan \left (\frac {x}{2}\right ) a +b}{\sqrt {a^{2}-b^{2}}}\right ) \sin \left (x \right ) a b +2 \sqrt {a^{2}-b^{2}}\, \mathit {atan} \left (\frac {\tan \left (\frac {x}{2}\right ) a +b}{\sqrt {a^{2}-b^{2}}}\right ) a^{2}-\cos \left (x \right ) a^{2} b +\cos \left (x \right ) b^{3}-\sin \left (x \right ) a^{2} b x +\sin \left (x \right ) b^{3} x -a^{3} x +a \,b^{2} x}{b^{2} \left (\sin \left (x \right ) a^{2} b -\sin \left (x \right ) b^{3}+a^{3}-a \,b^{2}\right )} \] Input:

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

Output:

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