Optimal. Leaf size=43 \[ \frac{\sqrt{a} \tan ^{-1}\left (\frac{\sqrt{b} \tan (x)}{\sqrt{a}}\right )}{\sqrt{b} (a-b)}-\frac{x}{a-b} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.149493, antiderivative size = 43, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 3, integrand size = 20, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.15, Rules used = {481, 203, 205} \[ \frac{\sqrt{a} \tan ^{-1}\left (\frac{\sqrt{b} \tan (x)}{\sqrt{a}}\right )}{\sqrt{b} (a-b)}-\frac{x}{a-b} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 481
Rule 203
Rule 205
Rubi steps
\begin{align*} \int \frac{\sin ^2(x)}{a \cos ^2(x)+b \sin ^2(x)} \, dx &=\operatorname{Subst}\left (\int \frac{x^2}{\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{a \operatorname{Subst}\left (\int \frac{1}{a+b x^2} \, dx,x,\tan (x)\right )}{a-b}\\ &=-\frac{x}{a-b}+\frac{\sqrt{a} \tan ^{-1}\left (\frac{\sqrt{b} \tan (x)}{\sqrt{a}}\right )}{(a-b) \sqrt{b}}\\ \end{align*}
Mathematica [A] time = 0.0989602, size = 36, normalized size = 0.84 \[ \frac{x-\frac{\sqrt{a} \tan ^{-1}\left (\frac{\sqrt{b} \tan (x)}{\sqrt{a}}\right )}{\sqrt{b}}}{b-a} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A] time = 0.051, size = 38, normalized size = 0.9 \begin{align*} -{\frac{\arctan \left ( \tan \left ( x \right ) \right ) }{a-b}}+{\frac{a}{a-b}\arctan \left ({b\tan \left ( x \right ){\frac{1}{\sqrt{ab}}}} \right ){\frac{1}{\sqrt{ab}}}} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A] time = 1.99184, size = 433, normalized size = 10.07 \begin{align*} \left [-\frac{\sqrt{-\frac{a}{b}} \log \left (\frac{{\left (a^{2} + 6 \, a b + b^{2}\right )} \cos \left (x\right )^{4} - 2 \,{\left (3 \, a b + b^{2}\right )} \cos \left (x\right )^{2} + 4 \,{\left ({\left (a b + b^{2}\right )} \cos \left (x\right )^{3} - b^{2} \cos \left (x\right )\right )} \sqrt{-\frac{a}{b}} \sin \left (x\right ) + b^{2}}{{\left (a^{2} - 2 \, a b + b^{2}\right )} \cos \left (x\right )^{4} + 2 \,{\left (a b - b^{2}\right )} \cos \left (x\right )^{2} + b^{2}}\right ) + 4 \, x}{4 \,{\left (a - b\right )}}, -\frac{\sqrt{\frac{a}{b}} \arctan \left (\frac{{\left ({\left (a + b\right )} \cos \left (x\right )^{2} - b\right )} \sqrt{\frac{a}{b}}}{2 \, a \cos \left (x\right ) \sin \left (x\right )}\right ) + 2 \, x}{2 \,{\left (a - b\right )}}\right ] \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [A] time = 2.53662, size = 241, normalized size = 5.6 \begin{align*} \begin{cases} \tilde{\infty } x & \text{for}\: a = 0 \wedge b = 0 \\\frac{x}{b} & \text{for}\: a = 0 \\\frac{x \sin ^{2}{\left (x \right )}}{2 b \sin ^{2}{\left (x \right )} + 2 b \cos ^{2}{\left (x \right )}} + \frac{x \cos ^{2}{\left (x \right )}}{2 b \sin ^{2}{\left (x \right )} + 2 b \cos ^{2}{\left (x \right )}} - \frac{\sin{\left (x \right )} \cos{\left (x \right )}}{2 b \sin ^{2}{\left (x \right )} + 2 b \cos ^{2}{\left (x \right )}} & \text{for}\: a = b \\\frac{- x + \frac{\sin{\left (x \right )}}{\cos{\left (x \right )}}}{a} & \text{for}\: b = 0 \\- \frac{2 i \sqrt{b} x \sqrt{\frac{1}{a}}}{2 i a \sqrt{b} \sqrt{\frac{1}{a}} - 2 i b^{\frac{3}{2}} \sqrt{\frac{1}{a}}} - \frac{\log{\left (- i \sqrt{b} \sqrt{\frac{1}{a}} \sin{\left (x \right )} + \cos{\left (x \right )} \right )}}{2 i a \sqrt{b} \sqrt{\frac{1}{a}} - 2 i b^{\frac{3}{2}} \sqrt{\frac{1}{a}}} + \frac{\log{\left (i \sqrt{b} \sqrt{\frac{1}{a}} \sin{\left (x \right )} + \cos{\left (x \right )} \right )}}{2 i a \sqrt{b} \sqrt{\frac{1}{a}} - 2 i b^{\frac{3}{2}} \sqrt{\frac{1}{a}}} & \text{otherwise} \end{cases} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] time = 1.21473, size = 151, normalized size = 3.51 \begin{align*} \frac{\pi \left \lfloor \frac{x}{\pi } + \frac{1}{2} \right \rfloor + \arctan \left (\frac{2 \, \sqrt{\frac{1}{2}} \tan \left (x\right )}{\sqrt{\frac{a + b + \sqrt{{\left (a + b\right )}^{2} - 4 \, a b}}{b}}}\right )}{{\left | -a + b \right |}} - \frac{\sqrt{a b}{\left (\pi \left \lfloor \frac{x}{\pi } + \frac{1}{2} \right \rfloor + \arctan \left (\frac{2 \, \sqrt{\frac{1}{2}} \tan \left (x\right )}{\sqrt{\frac{a + b - \sqrt{{\left (a + b\right )}^{2} - 4 \, a b}}{b}}}\right )\right )}{\left | b \right |}}{b^{2}{\left | -a + b \right |}} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]