Optimal. Leaf size=42 \[ \frac {2 \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.04, antiderivative size = 42, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, integrand size = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {2659, 205} \[ \frac {2 \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 205
Rule 2659
Rubi steps
\begin {align*} \int \frac {1}{a+b \cos (x)} \, dx &=2 \operatorname {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )\\ &=\frac {2 \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A] time = 0.03, size = 41, normalized size = 0.98 \[ -\frac {2 \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {x}{2}\right )}{\sqrt {b^2-a^2}}\right )}{\sqrt {b^2-a^2}} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
fricas [A] time = 0.84, size = 137, normalized size = 3.26 \[ \left [-\frac {\sqrt {-a^{2} + b^{2}} \log \left (\frac {2 \, a b \cos \relax (x) + {\left (2 \, a^{2} - b^{2}\right )} \cos \relax (x)^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \relax (x) + b\right )} \sin \relax (x) - a^{2} + 2 \, b^{2}}{b^{2} \cos \relax (x)^{2} + 2 \, a b \cos \relax (x) + a^{2}}\right )}{2 \, {\left (a^{2} - b^{2}\right )}}, \frac {\arctan \left (-\frac {a \cos \relax (x) + b}{\sqrt {a^{2} - b^{2}} \sin \relax (x)}\right )}{\sqrt {a^{2} - b^{2}}}\right ] \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
giac [A] time = 0.83, size = 61, normalized size = 1.45 \[ -\frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, x\right ) - b \tan \left (\frac {1}{2} \, x\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{\sqrt {a^{2} - b^{2}}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maple [A] time = 0.02, size = 36, normalized size = 0.86 \[ \frac {2 \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {x}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}} \]
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 = 0.59, size = 38, normalized size = 0.90 \[ \frac {2\,\mathrm {atan}\left (\frac {\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a-2\,b\right )}{2\,\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
sympy [A] time = 4.30, size = 144, normalized size = 3.43 \[ \begin {cases} \tilde {\infty } \left (- \log {\left (\tan {\left (\frac {x}{2} \right )} - 1 \right )} + \log {\left (\tan {\left (\frac {x}{2} \right )} + 1 \right )}\right ) & \text {for}\: a = 0 \wedge b = 0 \\\frac {1}{b \tan {\left (\frac {x}{2} \right )}} & \text {for}\: a = - b \\\frac {\tan {\left (\frac {x}{2} \right )}}{b} & \text {for}\: a = b \\\frac {\log {\left (- \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {x}{2} \right )} \right )}}{a \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {\log {\left (\sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {x}{2} \right )} \right )}}{a \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} & \text {otherwise} \end {cases} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________