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

Optimal. Leaf size=66 \[ \frac {2 a \tan ^{-1}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {\cos (x)}{b (a+b \sin (x))}-\frac {x}{b^2} \]

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.13, antiderivative size = 66, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, integrand size = 11, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.546, Rules used = {4391, 2693, 2735, 2660, 618, 204} \[ \frac {2 a \tan ^{-1}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {\cos (x)}{b (a+b \sin (x))}-\frac {x}{b^2} \]

Antiderivative was successfully verified.

[In]

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

[Out]

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

Rule 204

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

Rule 618

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

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(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 2693

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] + Dist[(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] /; FreeQ[{a, b, e, f, g}, x] && NeQ[a
^2 - b^2, 0] && LtQ[m, -1] && GtQ[p, 1] && IntegersQ[2*m, 2*p]

Rule 2735

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*x)/d
, x] - Dist[(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 4391

Int[(u_.)*((b_.)*sec[(c_.) + (d_.)*(x_)]^(n_.) + (a_.)*tan[(c_.) + (d_.)*(x_)]^(n_.))^(p_), x_Symbol] :> Int[A
ctivateTrig[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]

Rubi steps

\begin {align*} \int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx &=\int \frac {\cos ^2(x)}{(a+b \sin (x))^2} \, dx\\ &=-\frac {\cos (x)}{b (a+b \sin (x))}-\frac {\int \frac {\sin (x)}{a+b \sin (x)} \, dx}{b}\\ &=-\frac {x}{b^2}-\frac {\cos (x)}{b (a+b \sin (x))}+\frac {a \int \frac {1}{a+b \sin (x)} \, dx}{b^2}\\ &=-\frac {x}{b^2}-\frac {\cos (x)}{b (a+b \sin (x))}+\frac {(2 a) \operatorname {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^2}\\ &=-\frac {x}{b^2}-\frac {\cos (x)}{b (a+b \sin (x))}-\frac {(4 a) \operatorname {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{b^2}\\ &=-\frac {x}{b^2}+\frac {2 a \tan ^{-1}\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))}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B]  time = 2.02, size = 344, normalized size = 5.21 \[ \frac {(\sin (x)+1) \cos (x) \left (2 a (a-b) \sqrt {1-\sin (x)} (a+b \sin (x)) \tanh ^{-1}\left (\frac {\sqrt {a-b} \sqrt {-\frac {b (\sin (x)+1)}{a-b}}}{\sqrt {a+b} \sqrt {-\frac {b (\sin (x)-1)}{a+b}}}\right )+\sqrt {a+b} \left (-(b-a) \sqrt {\frac {b-b \sin (x)}{a+b}} \left (\sqrt {a-b} (a+b) \sqrt {1-\sin (x)} \sqrt {-\frac {b (\sin (x)+1)}{a-b}}+2 \sqrt {b} (a+b \sin (x)) \sinh ^{-1}\left (\frac {\sqrt {a-b} \sqrt {-\frac {b (\sin (x)+1)}{a-b}}}{\sqrt {2} \sqrt {b}}\right )\right )-2 a \sqrt {a-b} \sqrt {1-\sin (x)} (a+b \sin (x)) \tanh ^{-1}\left (\frac {\sqrt {\frac {b (\sin (x)+1)}{b-a}}}{\sqrt {\frac {b-b \sin (x)}{a+b}}}\right )\right )\right )}{(a-b)^{5/2} (a+b)^{3/2} \sqrt {1-\sin (x)} \left (-\frac {b (\sin (x)+1)}{a-b}\right )^{3/2} \sqrt {\frac {b-b \sin (x)}{a+b}} (a+b \sin (x))} \]

Antiderivative was successfully verified.

[In]

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

[Out]

(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*S
in[x])/(a + b)]*(Sqrt[a - b]*(a + b)*Sqrt[1 - Sin[x]]*Sqrt[-((b*(1 + Sin[x]))/(a - b))] + 2*Sqrt[b]*ArcSinh[(S
qrt[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]))

________________________________________________________________________________________

fricas [B]  time = 1.06, size = 308, normalized size = 4.67 \[ \left [-\frac {2 \, {\left (a^{2} b - b^{3}\right )} x \sin \relax (x) + {\left (a b \sin \relax (x) + a^{2}\right )} \sqrt {-a^{2} + b^{2}} \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \relax (x)^{2} - 2 \, a b \sin \relax (x) - a^{2} - b^{2} + 2 \, {\left (a \cos \relax (x) \sin \relax (x) + b \cos \relax (x)\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \relax (x)^{2} - 2 \, a b \sin \relax (x) - a^{2} - b^{2}}\right ) + 2 \, {\left (a^{3} - a b^{2}\right )} x + 2 \, {\left (a^{2} b - b^{3}\right )} \cos \relax (x)}{2 \, {\left (a^{3} b^{2} - a b^{4} + {\left (a^{2} b^{3} - b^{5}\right )} \sin \relax (x)\right )}}, -\frac {{\left (a^{2} b - b^{3}\right )} x \sin \relax (x) + {\left (a b \sin \relax (x) + a^{2}\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \sin \relax (x) + b}{\sqrt {a^{2} - b^{2}} \cos \relax (x)}\right ) + {\left (a^{3} - a b^{2}\right )} x + {\left (a^{2} b - b^{3}\right )} \cos \relax (x)}{a^{3} b^{2} - a b^{4} + {\left (a^{2} b^{3} - b^{5}\right )} \sin \relax (x)}\right ] \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

[-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))]

________________________________________________________________________________________

giac [A]  time = 0.17, size = 94, normalized size = 1.42 \[ \frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\relax (a) + \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} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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)

________________________________________________________________________________________

maple [A]  time = 0.16, size = 106, normalized size = 1.61 \[ -\frac {2 \tan \left (\frac {x}{2}\right )}{\left (a \left (\tan ^{2}\left (\frac {x}{2}\right )\right )+2 b \tan \left (\frac {x}{2}\right )+a \right ) a}-\frac {2}{b \left (a \left (\tan ^{2}\left (\frac {x}{2}\right )\right )+2 b \tan \left (\frac {x}{2}\right )+a \right )}+\frac {2 a \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{b^{2} \sqrt {a^{2}-b^{2}}}-\frac {2 \arctan \left (\tan \left (\frac {x}{2}\right )\right )}{b^{2}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

maxima [F(-2)]  time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*b^2-4*a^2>0)', see `assume?`
 for more details)Is 4*b^2-4*a^2 positive or negative?

________________________________________________________________________________________

mupad [B]  time = 2.81, size = 604, normalized size = 9.15 \[ -\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}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

- x/b^2 - ((2*tan(x/2))/a + 2/b)/(a + 2*b*tan(x/2) + a*tan(x/2)^2) - (a*atan(((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))

________________________________________________________________________________________

sympy [F]  time = 0.00, size = 0, normalized size = 0.00 \[ \int \frac {1}{\left (a \sec {\relax (x )} + b \tan {\relax (x )}\right )^{2}}\, dx \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________