Optimal. Leaf size=68 \[ -\frac {a \sin (x)}{a^2+b^2}-\frac {b \cos (x)}{a^2+b^2}-\frac {a^2 \tanh ^{-1}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.08, antiderivative size = 68, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, integrand size = 16, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3099, 3074, 206, 2638} \[ -\frac {a \sin (x)}{a^2+b^2}-\frac {b \cos (x)}{a^2+b^2}-\frac {a^2 \tanh ^{-1}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 206
Rule 2638
Rule 3074
Rule 3099
Rubi steps
\begin {align*} \int \frac {\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx &=-\frac {a \sin (x)}{a^2+b^2}+\frac {a^2 \int \frac {1}{a \cos (x)+b \sin (x)} \, dx}{a^2+b^2}+\frac {b \int \sin (x) \, dx}{a^2+b^2}\\ &=-\frac {b \cos (x)}{a^2+b^2}-\frac {a \sin (x)}{a^2+b^2}-\frac {a^2 \operatorname {Subst}\left (\int \frac {1}{a^2+b^2-x^2} \, dx,x,b \cos (x)-a \sin (x)\right )}{a^2+b^2}\\ &=-\frac {a^2 \tanh ^{-1}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac {b \cos (x)}{a^2+b^2}-\frac {a \sin (x)}{a^2+b^2}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A] time = 0.16, size = 62, normalized size = 0.91 \[ \frac {2 a^2 \tanh ^{-1}\left (\frac {a \tan \left (\frac {x}{2}\right )-b}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac {a \sin (x)+b \cos (x)}{a^2+b^2} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
fricas [B] time = 0.48, size = 144, normalized size = 2.12 \[ \frac {\sqrt {a^{2} + b^{2}} a^{2} \log \left (-\frac {2 \, a b \cos \relax (x) \sin \relax (x) + {\left (a^{2} - b^{2}\right )} \cos \relax (x)^{2} - 2 \, a^{2} - b^{2} + 2 \, \sqrt {a^{2} + b^{2}} {\left (b \cos \relax (x) - a \sin \relax (x)\right )}}{2 \, a b \cos \relax (x) \sin \relax (x) + {\left (a^{2} - b^{2}\right )} \cos \relax (x)^{2} + b^{2}}\right ) - 2 \, {\left (a^{2} b + b^{3}\right )} \cos \relax (x) - 2 \, {\left (a^{3} + a b^{2}\right )} \sin \relax (x)}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
giac [A] time = 0.26, size = 94, normalized size = 1.38 \[ -\frac {a^{2} \log \left (\frac {{\left | 2 \, a \tan \left (\frac {1}{2} \, x\right ) - 2 \, b - 2 \, \sqrt {a^{2} + b^{2}} \right |}}{{\left | 2 \, a \tan \left (\frac {1}{2} \, x\right ) - 2 \, b + 2 \, \sqrt {a^{2} + b^{2}} \right |}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} - \frac {2 \, {\left (a \tan \left (\frac {1}{2} \, x\right ) + b\right )}}{{\left (a^{2} + b^{2}\right )} {\left (\tan \left (\frac {1}{2} \, x\right )^{2} + 1\right )}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maple [A] time = 0.49, size = 84, normalized size = 1.24 \[ \frac {8 a^{2} \arctanh \left (\frac {2 a \tan \left (\frac {x}{2}\right )-2 b}{2 \sqrt {a^{2}+b^{2}}}\right )}{\left (4 a^{2}+4 b^{2}\right ) \sqrt {a^{2}+b^{2}}}+\frac {-2 a \tan \left (\frac {x}{2}\right )-2 b}{\left (a^{2}+b^{2}\right ) \left (\tan ^{2}\left (\frac {x}{2}\right )+1\right )} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maxima [A] time = 0.43, size = 106, normalized size = 1.56 \[ -\frac {a^{2} \log \left (\frac {b - \frac {a \sin \relax (x)}{\cos \relax (x) + 1} + \sqrt {a^{2} + b^{2}}}{b - \frac {a \sin \relax (x)}{\cos \relax (x) + 1} - \sqrt {a^{2} + b^{2}}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} - \frac {2 \, {\left (b + \frac {a \sin \relax (x)}{\cos \relax (x) + 1}\right )}}{a^{2} + b^{2} + \frac {{\left (a^{2} + b^{2}\right )} \sin \relax (x)^{2}}{{\left (\cos \relax (x) + 1\right )}^{2}}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
mupad [B] time = 0.58, size = 94, normalized size = 1.38 \[ -\frac {\frac {2\,b}{a^2+b^2}+\frac {2\,a\,\mathrm {tan}\left (\frac {x}{2}\right )}{a^2+b^2}}{{\mathrm {tan}\left (\frac {x}{2}\right )}^2+1}-\frac {2\,a^2\,\mathrm {atanh}\left (\frac {2\,a^2\,b+2\,b^3-2\,a\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (a^2+b^2\right )}{2\,{\left (a^2+b^2\right )}^{3/2}}\right )}{{\left (a^2+b^2\right )}^{3/2}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
sympy [F(-1)] time = 0.00, size = 0, normalized size = 0.00 \[ \text {Timed out} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________