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))} \]
[Out]
Time = 0.13 (sec) , antiderivative size = 66, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.545, Rules used = {4476, 2772, 2814, 2739, 632, 210} \[ \int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx=\frac {2 a \arctan \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} \]
[In]
[Out]
Rule 210
Rule 632
Rule 2739
Rule 2772
Rule 2814
Rule 4476
Rubi steps \begin{align*} \text {integral}& = \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) \text {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) \text {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 \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))} \\ \end{align*}
Leaf count is larger than twice the leaf count of optimal. \(344\) vs. \(2(66)=132\).
Time = 1.61 (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))} \]
[In]
[Out]
Time = 1.68 (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\) |
[In]
[Out]
Leaf count of result is larger than twice the leaf count of optimal. 121 vs. \(2 (60) = 120\).
Time = 0.29 (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 ] \]
[In]
[Out]
\[ \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 \]
[In]
[Out]
Exception generated. \[ \int \frac {1}{(a \sec (x)+b \tan (x))^2} \, dx=\text {Exception raised: ValueError} \]
[In]
[Out]
none
Time = 0.27 (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} \]
[In]
[Out]
Time = 29.68 (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}} \]
[In]
[Out]