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]
________________________________________________________________________________________
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]
[Out]
Rule 204
Rule 618
Rule 2660
Rule 2693
Rule 2735
Rule 4391
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________