Optimal. Leaf size=47 \[ -\frac {2 \tanh ^{-1}\left (\frac {b-(1-a) \tan \left (\frac {x}{2}\right )}{\sqrt {1-a^2+b^2}}\right )}{\sqrt {1-a^2+b^2}} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.04, antiderivative size = 47, normalized size of antiderivative = 1.00, number of steps
used = 3, number of rules used = 3, integrand size = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.300, Rules used = {3203, 632, 212}
\begin {gather*} -\frac {2 \tanh ^{-1}\left (\frac {b-(1-a) \tan \left (\frac {x}{2}\right )}{\sqrt {-a^2+b^2+1}}\right )}{\sqrt {-a^2+b^2+1}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 212
Rule 632
Rule 3203
Rubi steps
\begin {align*} \int \frac {1}{a+\cos (x)+b \sin (x)} \, dx &=2 \text {Subst}\left (\int \frac {1}{1+a+2 b x+(-1+a) x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )\\ &=-\left (4 \text {Subst}\left (\int \frac {1}{4 \left (1-a^2+b^2\right )-x^2} \, dx,x,2 b+2 (-1+a) \tan \left (\frac {x}{2}\right )\right )\right )\\ &=-\frac {2 \tanh ^{-1}\left (\frac {b-(1-a) \tan \left (\frac {x}{2}\right )}{\sqrt {1-a^2+b^2}}\right )}{\sqrt {1-a^2+b^2}}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.04, size = 44, normalized size = 0.94 \begin {gather*} \frac {2 \tan ^{-1}\left (\frac {b+(-1+a) \tan \left (\frac {x}{2}\right )}{\sqrt {-1+a^2-b^2}}\right )}{\sqrt {-1+a^2-b^2}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Mathics [C] Result contains higher order function than in optimal. Order 9 vs. order 3 in
optimal.
time = 242.83, size = 477, normalized size = 10.15 \begin {gather*} \text {Piecewise}\left [\left \{\left \{\frac {\text {Log}\left [\frac {1}{b}+\text {Tan}\left [\frac {x}{2}\right ]\right ]}{b},a\text {==}1\right \},\left \{\frac {32+24 b^2 \sqrt {1+b^2}+40 b^2+2 b^4 \sqrt {1+b^2}+10 b^4+32 \sqrt {1+b^2}}{-16 b-16 b \sqrt {1+b^2}+32 b^2 \sqrt {1+b^2} \text {Tan}\left [\frac {x}{2}\right ]+48 b^2 \text {Tan}\left [\frac {x}{2}\right ]-20 b^3-12 b^3 \sqrt {1+b^2}+6 b^4 \sqrt {1+b^2} \text {Tan}\left [\frac {x}{2}\right ]+18 b^4 \text {Tan}\left [\frac {x}{2}\right ]-5 b^5-b^5 \sqrt {1+b^2}+b^6 \text {Tan}\left [\frac {x}{2}\right ]+32 \sqrt {1+b^2} \text {Tan}\left [\frac {x}{2}\right ]+32 \text {Tan}\left [\frac {x}{2}\right ]},a\text {==}-\sqrt {1+b^2}\right \},\left \{\frac {32-24 b^2 \sqrt {1+b^2}+40 b^2-2 b^4 \sqrt {1+b^2}+10 b^4-32 \sqrt {1+b^2}}{-16 b+16 b \sqrt {1+b^2}-32 b^2 \sqrt {1+b^2} \text {Tan}\left [\frac {x}{2}\right ]+48 b^2 \text {Tan}\left [\frac {x}{2}\right ]-20 b^3+12 b^3 \sqrt {1+b^2}-6 b^4 \sqrt {1+b^2} \text {Tan}\left [\frac {x}{2}\right ]+18 b^4 \text {Tan}\left [\frac {x}{2}\right ]-5 b^5+b^5 \sqrt {1+b^2}+b^6 \text {Tan}\left [\frac {x}{2}\right ]-32 \sqrt {1+b^2} \text {Tan}\left [\frac {x}{2}\right ]+32 \text {Tan}\left [\frac {x}{2}\right ]},a\text {==}\sqrt {1+b^2}\right \}\right \},-\frac {\text {Log}\left [\frac {b}{-1+a}+\text {Tan}\left [\frac {x}{2}\right ]+\frac {\sqrt {1-a^2+b^2}}{-1+a}\right ]}{\sqrt {1-a^2+b^2}}+\frac {\text {Log}\left [\frac {b}{-1+a}+\text {Tan}\left [\frac {x}{2}\right ]-\frac {\sqrt {1-a^2+b^2}}{-1+a}\right ]}{\sqrt {1-a^2+b^2}}\right ] \end {gather*}
Warning: Unable to verify antiderivative.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.09, size = 43, normalized size = 0.91
method | result | size |
default | \(\frac {2 \arctan \left (\frac {2 \left (a -1\right ) \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}-1}}\right )}{\sqrt {a^{2}-b^{2}-1}}\) | \(43\) |
risch | \(-\frac {\ln \left ({\mathrm e}^{i x}+\frac {i a b \sqrt {-a^{2}+b^{2}+1}+i a^{2}-i b^{2}-a^{2} b +b^{3}+a \sqrt {-a^{2}+b^{2}+1}-i+b}{\left (b^{2}+1\right ) \sqrt {-a^{2}+b^{2}+1}}\right )}{\sqrt {-a^{2}+b^{2}+1}}+\frac {\ln \left ({\mathrm e}^{i x}+\frac {i a b \sqrt {-a^{2}+b^{2}+1}-i a^{2}+i b^{2}+a^{2} b -b^{3}+a \sqrt {-a^{2}+b^{2}+1}+i-b}{\left (b^{2}+1\right ) \sqrt {-a^{2}+b^{2}+1}}\right )}{\sqrt {-a^{2}+b^{2}+1}}\) | \(198\) |
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 = 0.34, size = 287, normalized size = 6.11 \begin {gather*} \left [-\frac {\sqrt {-a^{2} + b^{2} + 1} \log \left (-\frac {b^{4} + {\left (a^{2} + 3\right )} b^{2} - {\left (2 \, a^{2} b^{2} - b^{4} - 2 \, a^{2} + 1\right )} \cos \left (x\right )^{2} - a^{2} + 2 \, {\left (a b^{2} + a\right )} \cos \left (x\right ) + 2 \, {\left (a b^{3} + a b - {\left (b^{3} - {\left (2 \, a^{2} - 1\right )} b\right )} \cos \left (x\right )\right )} \sin \left (x\right ) - 2 \, {\left (2 \, a b \cos \left (x\right )^{2} - a b + {\left (b^{3} + b\right )} \cos \left (x\right ) - {\left (b^{2} - {\left (a b^{2} - a\right )} \cos \left (x\right ) + 1\right )} \sin \left (x\right )\right )} \sqrt {-a^{2} + b^{2} + 1} + 2}{{\left (b^{2} - 1\right )} \cos \left (x\right )^{2} - a^{2} - b^{2} - 2 \, a \cos \left (x\right ) - 2 \, {\left (a b + b \cos \left (x\right )\right )} \sin \left (x\right )}\right )}{2 \, {\left (a^{2} - b^{2} - 1\right )}}, \frac {\arctan \left (-\frac {{\left (a b \sin \left (x\right ) + b^{2} + a \cos \left (x\right ) + 1\right )} \sqrt {a^{2} - b^{2} - 1}}{{\left (b^{3} - {\left (a^{2} - 1\right )} b\right )} \cos \left (x\right ) + {\left (a^{2} - b^{2} - 1\right )} \sin \left (x\right )}\right )}{\sqrt {a^{2} - b^{2} - 1}}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [A]
time = 65.07, size = 1872, normalized size = 39.83
result too large to display
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.00, size = 69, normalized size = 1.47 \begin {gather*} \frac {2\cdot 2 \left (\arctan \left (\frac {a \tan \left (\frac {x}{2}\right )+b-\tan \left (\frac {x}{2}\right )}{\sqrt {a^{2}-b^{2}-1}}\right )+\pi \mathrm {sign}\left (2 a-2\right ) \left \lfloor \frac {x}{2 \pi }+\frac 1{2}\right \rfloor \right )}{2 \sqrt {a^{2}-b^{2}-1}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 0.26, size = 58, normalized size = 1.23 \begin {gather*} \left \{\begin {array}{cl} \frac {\ln \left (b\,\mathrm {tan}\left (\frac {x}{2}\right )+1\right )}{b} & \text {\ if\ \ }a=1\\ \frac {2\,\mathrm {atan}\left (\frac {b+\mathrm {tan}\left (\frac {x}{2}\right )\,\left (a-1\right )}{\sqrt {a^2-b^2-1}}\right )}{\sqrt {a^2-b^2-1}} & \text {\ if\ \ }a\neq 1 \end {array}\right . \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________