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.03, 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 = {2738, 211}
\begin {gather*} \frac {2 \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 211
Rule 2738
Rubi steps
\begin {align*} \int \frac {1}{a+b \cos (x)} \, dx &=2 \text {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 \begin {gather*} -\frac {2 \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {x}{2}\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.04, size = 36, normalized size = 0.86
method | result | size |
default | \(\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 )}}\) | \(36\) |
risch | \(-\frac {\ln \left ({\mathrm e}^{i x}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}}+\frac {\ln \left ({\mathrm e}^{i x}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}}\) | \(125\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 1.06, size = 137, normalized size = 3.26 \begin {gather*} \left [-\frac {\sqrt {-a^{2} + b^{2}} \log \left (\frac {2 \, a b \cos \left (x\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (x\right ) + b\right )} \sin \left (x\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (x\right )^{2} + 2 \, a b \cos \left (x\right ) + a^{2}}\right )}{2 \, {\left (a^{2} - b^{2}\right )}}, \frac {\arctan \left (-\frac {a \cos \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (x\right )}\right )}{\sqrt {a^{2} - b^{2}}}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 144 vs.
\(2 (34) = 68\).
time = 1.76, size = 144, normalized size = 3.43 \begin {gather*} \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 {\tan {\left (\frac {x}{2} \right )}}{b} & \text {for}\: a = b \\\frac {1}{b \tan {\left (\frac {x}{2} \right )}} & \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} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 1.17, size = 61, normalized size = 1.45 \begin {gather*} -\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}}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 0.59, size = 38, normalized size = 0.90 \begin {gather*} \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}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________