Integrand size = 31, antiderivative size = 86 \[ \int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} \left (1+x+x^2\right )^2} \, dx=\frac {(1+x) \sqrt {1-x+x^2}}{1+x+x^2}+\sqrt {2} \arctan \left (\frac {\sqrt {2} (1+x)}{\sqrt {1-x+x^2}}\right )-\frac {\text {arctanh}\left (\frac {\sqrt {\frac {2}{3}} (1-x)}{\sqrt {1-x+x^2}}\right )}{\sqrt {6}} \]
[Out]
Time = 0.07 (sec) , antiderivative size = 86, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.161, Rules used = {1074, 1049, 1043, 212, 210} \[ \int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} \left (1+x+x^2\right )^2} \, dx=\sqrt {2} \arctan \left (\frac {\sqrt {2} (x+1)}{\sqrt {x^2-x+1}}\right )-\frac {\text {arctanh}\left (\frac {\sqrt {\frac {2}{3}} (1-x)}{\sqrt {x^2-x+1}}\right )}{\sqrt {6}}+\frac {\sqrt {x^2-x+1} (x+1)}{x^2+x+1} \]
[In]
[Out]
Rule 210
Rule 212
Rule 1043
Rule 1049
Rule 1074
Rubi steps \begin{align*} \text {integral}& = \frac {(1+x) \sqrt {1-x+x^2}}{1+x+x^2}+\frac {1}{12} \int \frac {18-6 x}{\sqrt {1-x+x^2} \left (1+x+x^2\right )} \, dx \\ & = \frac {(1+x) \sqrt {1-x+x^2}}{1+x+x^2}+\frac {1}{48} \int \frac {24+24 x}{\sqrt {1-x+x^2} \left (1+x+x^2\right )} \, dx-\frac {1}{48} \int \frac {-48+48 x}{\sqrt {1-x+x^2} \left (1+x+x^2\right )} \, dx \\ & = \frac {(1+x) \sqrt {1-x+x^2}}{1+x+x^2}+24 \text {Subst}\left (\int \frac {1}{1728-2 x^2} \, dx,x,\frac {-24+24 x}{\sqrt {1-x+x^2}}\right )+288 \text {Subst}\left (\int \frac {1}{-20736-2 x^2} \, dx,x,\frac {-144-144 x}{\sqrt {1-x+x^2}}\right ) \\ & = \frac {(1+x) \sqrt {1-x+x^2}}{1+x+x^2}+\sqrt {2} \arctan \left (\frac {\sqrt {2} (1+x)}{\sqrt {1-x+x^2}}\right )-\frac {\text {arctanh}\left (\frac {\sqrt {\frac {2}{3}} (1-x)}{\sqrt {1-x+x^2}}\right )}{\sqrt {6}} \\ \end{align*}
Result contains higher order function than in optimal. Order 9 vs. order 3 in optimal.
Time = 0.30 (sec) , antiderivative size = 239, normalized size of antiderivative = 2.78 \[ \int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} \left (1+x+x^2\right )^2} \, dx=\frac {(1+x) \sqrt {1-x+x^2}}{1+x+x^2}-\text {RootSum}\left [3+6 \text {$\#$1}+\text {$\#$1}^2-2 \text {$\#$1}^3+\text {$\#$1}^4\&,\frac {19 \log \left (-x+\sqrt {1-x+x^2}-\text {$\#$1}\right )+6 \log \left (-x+\sqrt {1-x+x^2}-\text {$\#$1}\right ) \text {$\#$1}}{3+\text {$\#$1}-3 \text {$\#$1}^2+2 \text {$\#$1}^3}\&\right ]-\frac {1}{2} \text {RootSum}\left [3+6 \text {$\#$1}+\text {$\#$1}^2-2 \text {$\#$1}^3+\text {$\#$1}^4\&,\frac {-36 \log \left (-x+\sqrt {1-x+x^2}-\text {$\#$1}\right )-6 \log \left (-x+\sqrt {1-x+x^2}-\text {$\#$1}\right ) \text {$\#$1}+\log \left (-x+\sqrt {1-x+x^2}-\text {$\#$1}\right ) \text {$\#$1}^2}{3+\text {$\#$1}-3 \text {$\#$1}^2+2 \text {$\#$1}^3}\&\right ] \]
[In]
[Out]
Leaf count of result is larger than twice the leaf count of optimal. \(157\) vs. \(2(71)=142\).
Time = 1.06 (sec) , antiderivative size = 158, normalized size of antiderivative = 1.84
method | result | size |
risch | \(\frac {\left (1+x \right ) \sqrt {x^{2}-x +1}}{x^{2}+x +1}+\frac {\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \left (6 \sqrt {2}\, \arctan \left (\frac {2 \sqrt {2}\, \left (1+x \right )}{\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \left (1-x \right )}\right )-\sqrt {6}\, \operatorname {arctanh}\left (\frac {\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \sqrt {6}}{4}\right )\right )}{6 \sqrt {\frac {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}{\left (\frac {1+x}{1-x}+1\right )^{2}}}\, \left (\frac {1+x}{1-x}+1\right )}\) | \(158\) |
default | \(\frac {\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \left (3 \sqrt {2}\, \arctan \left (\frac {2 \sqrt {2}\, \left (1+x \right )}{\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \left (1-x \right )}\right )-\sqrt {6}\, \operatorname {arctanh}\left (\frac {\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \sqrt {6}}{4}\right )\right )}{2 \sqrt {\frac {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}{\left (\frac {1+x}{1-x}+1\right )^{2}}}\, \left (\frac {1+x}{1-x}+1\right )}-\frac {\frac {9 \sqrt {2}\, \arctan \left (\frac {2 \sqrt {2}\, \left (1+x \right )}{\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \left (1-x \right )}\right ) \sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \left (1+x \right )^{2}}{\left (1-x \right )^{2}}-\frac {6 \sqrt {6}\, \operatorname {arctanh}\left (\frac {\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \sqrt {6}}{4}\right ) \sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3 \sqrt {2}\, \arctan \left (\frac {2 \sqrt {2}\, \left (1+x \right )}{\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \left (1-x \right )}\right ) \sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}-2 \sqrt {6}\, \operatorname {arctanh}\left (\frac {\sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}\, \sqrt {6}}{4}\right ) \sqrt {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}-\frac {12 \left (1+x \right )^{3}}{\left (1-x \right )^{3}}-\frac {36 \left (1+x \right )}{1-x}}{6 \sqrt {\frac {\frac {\left (1+x \right )^{2}}{\left (1-x \right )^{2}}+3}{\left (\frac {1+x}{1-x}+1\right )^{2}}}\, \left (\frac {1+x}{1-x}+1\right ) \left (\frac {3 \left (1+x \right )^{2}}{\left (1-x \right )^{2}}+1\right )}\) | \(455\) |
trager | \(\frac {\left (1+x \right ) \sqrt {x^{2}-x +1}}{x^{2}+x +1}-\operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right ) \ln \left (-\frac {-3456 x \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{5}-6312 x \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{3}+1560 \sqrt {x^{2}-x +1}\, \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{2}+2688 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{3}-2635 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right ) x +143 \sqrt {x^{2}-x +1}+1736 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )}{24 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{2} x +7 x -8}\right )+\frac {24 \ln \left (\frac {-1728 x \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{5}+744 x \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{3}+1560 \sqrt {x^{2}-x +1}\, \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{2}-1344 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{3}-76 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right ) x +1287 \sqrt {x^{2}-x +1}+224 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )}{24 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{2} x +15 x +8}\right ) \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{3}}{13}+\frac {22 \ln \left (\frac {-1728 x \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{5}+744 x \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{3}+1560 \sqrt {x^{2}-x +1}\, \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{2}-1344 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{3}-76 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right ) x +1287 \sqrt {x^{2}-x +1}+224 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )}{24 \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )^{2} x +15 x +8}\right ) \operatorname {RootOf}\left (576 \textit {\_Z}^{4}+528 \textit {\_Z}^{2}+169\right )}{13}\) | \(525\) |
[In]
[Out]
Result contains complex when optimal does not.
Time = 0.26 (sec) , antiderivative size = 285, normalized size of antiderivative = 3.31 \[ \int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} \left (1+x+x^2\right )^2} \, dx=\frac {\sqrt {6} {\left (x^{2} + x + 1\right )} \sqrt {4 i \, \sqrt {3} - 11} \log \left (\sqrt {6} {\left (5 i \, \sqrt {3} - 9\right )} \sqrt {4 i \, \sqrt {3} - 11} - 78 \, x - 39 i \, \sqrt {3} + 78 \, \sqrt {x^{2} - x + 1} - 39\right ) - \sqrt {6} {\left (x^{2} + x + 1\right )} \sqrt {-4 i \, \sqrt {3} - 11} \log \left (\sqrt {6} {\left (5 i \, \sqrt {3} + 9\right )} \sqrt {-4 i \, \sqrt {3} - 11} - 78 \, x + 39 i \, \sqrt {3} + 78 \, \sqrt {x^{2} - x + 1} - 39\right ) - \sqrt {6} {\left (x^{2} + x + 1\right )} \sqrt {4 i \, \sqrt {3} - 11} \log \left (\sqrt {6} \sqrt {4 i \, \sqrt {3} - 11} {\left (-5 i \, \sqrt {3} + 9\right )} - 78 \, x - 39 i \, \sqrt {3} + 78 \, \sqrt {x^{2} - x + 1} - 39\right ) + \sqrt {6} {\left (x^{2} + x + 1\right )} \sqrt {-4 i \, \sqrt {3} - 11} \log \left (\sqrt {6} \sqrt {-4 i \, \sqrt {3} - 11} {\left (-5 i \, \sqrt {3} - 9\right )} - 78 \, x + 39 i \, \sqrt {3} + 78 \, \sqrt {x^{2} - x + 1} - 39\right ) + 12 \, x^{2} + 12 \, \sqrt {x^{2} - x + 1} {\left (x + 1\right )} + 12 \, x + 12}{12 \, {\left (x^{2} + x + 1\right )}} \]
[In]
[Out]
\[ \int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} \left (1+x+x^2\right )^2} \, dx=\int \frac {3 x^{2} - x + 1}{\sqrt {x^{2} - x + 1} \left (x^{2} + x + 1\right )^{2}}\, dx \]
[In]
[Out]
\[ \int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} \left (1+x+x^2\right )^2} \, dx=\int { \frac {3 \, x^{2} - x + 1}{{\left (x^{2} + x + 1\right )}^{2} \sqrt {x^{2} - x + 1}} \,d x } \]
[In]
[Out]
Leaf count of result is larger than twice the leaf count of optimal. 304 vs. \(2 (69) = 138\).
Time = 0.32 (sec) , antiderivative size = 304, normalized size of antiderivative = 3.53 \[ \int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} \left (1+x+x^2\right )^2} \, dx=-\frac {1}{3} \, \sqrt {6} \sqrt {3} \arctan \left (-\frac {2 \, x + \sqrt {6} - 2 \, \sqrt {x^{2} - x + 1} + 1}{\sqrt {3} + \sqrt {2}}\right ) + \frac {1}{3} \, \sqrt {6} \sqrt {3} \arctan \left (-\frac {2 \, x - \sqrt {6} - 2 \, \sqrt {x^{2} - x + 1} + 1}{\sqrt {3} - \sqrt {2}}\right ) + \frac {1}{12} \, \sqrt {6} \log \left (4 \, {\left (\sqrt {6} \sqrt {3} + 3 \, \sqrt {3}\right )}^{2} + 36 \, {\left (2 \, x + \sqrt {6} - 2 \, \sqrt {x^{2} - x + 1} + 1\right )}^{2}\right ) - \frac {1}{12} \, \sqrt {6} \log \left (4 \, {\left (\sqrt {6} \sqrt {3} - 3 \, \sqrt {3}\right )}^{2} + 36 \, {\left (2 \, x - \sqrt {6} - 2 \, \sqrt {x^{2} - x + 1} + 1\right )}^{2}\right ) + \frac {{\left (x - \sqrt {x^{2} - x + 1}\right )}^{3} + 4 \, {\left (x - \sqrt {x^{2} - x + 1}\right )}^{2} - 10 \, x + 10 \, \sqrt {x^{2} - x + 1} + 5}{{\left (x - \sqrt {x^{2} - x + 1}\right )}^{4} + 2 \, {\left (x - \sqrt {x^{2} - x + 1}\right )}^{3} + {\left (x - \sqrt {x^{2} - x + 1}\right )}^{2} - 6 \, x + 6 \, \sqrt {x^{2} - x + 1} + 3} \]
[In]
[Out]
Timed out. \[ \int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} \left (1+x+x^2\right )^2} \, dx=\int \frac {3\,x^2-x+1}{\sqrt {x^2-x+1}\,{\left (x^2+x+1\right )}^2} \,d x \]
[In]
[Out]