Optimal. Leaf size=43 \[ \frac {x}{a-b}-\frac {\sqrt {b} \tan ^{-1}\left (\frac {\sqrt {b} \tan (x)}{\sqrt {a}}\right )}{\sqrt {a} (a-b)} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.11, antiderivative size = 43, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, integrand size = 20, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.150, Rules used = {391, 203, 205} \[ \frac {x}{a-b}-\frac {\sqrt {b} \tan ^{-1}\left (\frac {\sqrt {b} \tan (x)}{\sqrt {a}}\right )}{\sqrt {a} (a-b)} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 203
Rule 205
Rule 391
Rubi steps
\begin {align*} \int \frac {\cos ^2(x)}{a \cos ^2(x)+b \sin ^2(x)} \, dx &=\operatorname {Subst}\left (\int \frac {1}{\left (1+x^2\right ) \left (a+b x^2\right )} \, dx,x,\tan (x)\right )\\ &=\frac {\operatorname {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (x)\right )}{a-b}-\frac {b \operatorname {Subst}\left (\int \frac {1}{a+b x^2} \, dx,x,\tan (x)\right )}{a-b}\\ &=\frac {x}{a-b}-\frac {\sqrt {b} \tan ^{-1}\left (\frac {\sqrt {b} \tan (x)}{\sqrt {a}}\right )}{\sqrt {a} (a-b)}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A] time = 0.05, size = 36, normalized size = 0.84 \[ \frac {x-\frac {\sqrt {b} \tan ^{-1}\left (\frac {\sqrt {b} \tan (x)}{\sqrt {a}}\right )}{\sqrt {a}}}{a-b} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
fricas [A] time = 1.49, size = 181, normalized size = 4.21 \[ \left [-\frac {\sqrt {-\frac {b}{a}} \log \left (\frac {{\left (a^{2} + 6 \, a b + b^{2}\right )} \cos \relax (x)^{4} - 2 \, {\left (3 \, a b + b^{2}\right )} \cos \relax (x)^{2} - 4 \, {\left ({\left (a^{2} + a b\right )} \cos \relax (x)^{3} - a b \cos \relax (x)\right )} \sqrt {-\frac {b}{a}} \sin \relax (x) + b^{2}}{{\left (a^{2} - 2 \, a b + b^{2}\right )} \cos \relax (x)^{4} + 2 \, {\left (a b - b^{2}\right )} \cos \relax (x)^{2} + b^{2}}\right ) - 4 \, x}{4 \, {\left (a - b\right )}}, \frac {\sqrt {\frac {b}{a}} \arctan \left (\frac {{\left ({\left (a + b\right )} \cos \relax (x)^{2} - b\right )} \sqrt {\frac {b}{a}}}{2 \, b \cos \relax (x) \sin \relax (x)}\right ) + 2 \, x}{2 \, {\left (a - b\right )}}\right ] \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
giac [A] time = 0.14, size = 48, normalized size = 1.12 \[ -\frac {{\left (\pi \left \lfloor \frac {x}{\pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\relax (b) + \arctan \left (\frac {b \tan \relax (x)}{\sqrt {a b}}\right )\right )} b}{\sqrt {a b} {\left (a - b\right )}} + \frac {x}{a - b} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maple [A] time = 0.10, size = 36, normalized size = 0.84 \[ -\frac {b \arctan \left (\frac {\tan \relax (x ) b}{\sqrt {a b}}\right )}{\left (a -b \right ) \sqrt {a b}}+\frac {x}{a -b} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maxima [A] time = 0.41, size = 35, normalized size = 0.81 \[ -\frac {b \arctan \left (\frac {b \tan \relax (x)}{\sqrt {a b}}\right )}{\sqrt {a b} {\left (a - b\right )}} + \frac {x}{a - b} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
mupad [B] time = 2.67, size = 48, normalized size = 1.12 \[ \left \{\begin {array}{cl} \frac {2\,x+\sin \left (2\,x\right )}{4\,b} & \text {\ if\ \ }a=b\\ \frac {x-\frac {\sqrt {b}\,\mathrm {atan}\left (\frac {\sqrt {b}\,\mathrm {tan}\relax (x)}{\sqrt {a}}\right )}{\sqrt {a}}}{a-b} & \text {\ if\ \ }a\neq b \end {array}\right . \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
sympy [A] time = 1.62, size = 267, normalized size = 6.21 \[ \begin {cases} \tilde {\infty } \left (- x - \frac {\cos {\relax (x )}}{\sin {\relax (x )}}\right ) & \text {for}\: a = 0 \wedge b = 0 \\\frac {x \sin ^{2}{\relax (x )}}{2 b \sin ^{2}{\relax (x )} + 2 b \cos ^{2}{\relax (x )}} + \frac {x \cos ^{2}{\relax (x )}}{2 b \sin ^{2}{\relax (x )} + 2 b \cos ^{2}{\relax (x )}} + \frac {\sin {\relax (x )} \cos {\relax (x )}}{2 b \sin ^{2}{\relax (x )} + 2 b \cos ^{2}{\relax (x )}} & \text {for}\: a = b \\\frac {x}{a} & \text {for}\: b = 0 \\\frac {- x - \frac {\cos {\relax (x )}}{\sin {\relax (x )}}}{b} & \text {for}\: a = 0 \\\frac {2 i a \sqrt {b} x \sqrt {\frac {1}{a}}}{2 i a^{2} \sqrt {b} \sqrt {\frac {1}{a}} - 2 i a b^{\frac {3}{2}} \sqrt {\frac {1}{a}}} + \frac {b \log {\left (- i \sqrt {b} \sqrt {\frac {1}{a}} \sin {\relax (x )} + \cos {\relax (x )} \right )}}{2 i a^{2} \sqrt {b} \sqrt {\frac {1}{a}} - 2 i a b^{\frac {3}{2}} \sqrt {\frac {1}{a}}} - \frac {b \log {\left (i \sqrt {b} \sqrt {\frac {1}{a}} \sin {\relax (x )} + \cos {\relax (x )} \right )}}{2 i a^{2} \sqrt {b} \sqrt {\frac {1}{a}} - 2 i a b^{\frac {3}{2}} \sqrt {\frac {1}{a}}} & \text {otherwise} \end {cases} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________