Integrand size = 9, antiderivative size = 371 \[ \int \log ^2\left (1+x+x^2\right ) \, dx=8 x-4 \sqrt {3} \arctan \left (\frac {1+2 x}{\sqrt {3}}\right )-\frac {1}{2} \left (1-i \sqrt {3}\right ) \log ^2\left (1-i \sqrt {3}+2 x\right )-\left (1+i \sqrt {3}\right ) \log \left (\frac {i \left (1-i \sqrt {3}+2 x\right )}{2 \sqrt {3}}\right ) \log \left (1+i \sqrt {3}+2 x\right )-\frac {1}{2} \left (1+i \sqrt {3}\right ) \log ^2\left (1+i \sqrt {3}+2 x\right )-\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (-\frac {i \left (1+i \sqrt {3}+2 x\right )}{2 \sqrt {3}}\right )-2 \log \left (1+x+x^2\right )-4 x \log \left (1+x+x^2\right )+\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+\left (1+i \sqrt {3}\right ) \log \left (1+i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )-\left (1+i \sqrt {3}\right ) \operatorname {PolyLog}\left (2,-\frac {i-\sqrt {3}+2 i x}{2 \sqrt {3}}\right )-\left (1-i \sqrt {3}\right ) \operatorname {PolyLog}\left (2,\frac {i+\sqrt {3}+2 i x}{2 \sqrt {3}}\right ) \]
[Out]
Time = 0.37 (sec) , antiderivative size = 371, normalized size of antiderivative = 1.00, number of steps used = 27, number of rules used = 14, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 1.556, Rules used = {2603, 2608, 787, 648, 632, 210, 642, 2604, 2465, 2437, 2338, 2441, 2440, 2438} \[ \int \log ^2\left (1+x+x^2\right ) \, dx=-4 \sqrt {3} \arctan \left (\frac {2 x+1}{\sqrt {3}}\right )-\left (1+i \sqrt {3}\right ) \operatorname {PolyLog}\left (2,-\frac {2 i x-\sqrt {3}+i}{2 \sqrt {3}}\right )-\left (1-i \sqrt {3}\right ) \operatorname {PolyLog}\left (2,\frac {2 i x+\sqrt {3}+i}{2 \sqrt {3}}\right )+x \log ^2\left (x^2+x+1\right )+\left (1-i \sqrt {3}\right ) \log \left (x^2+x+1\right ) \log \left (2 x-i \sqrt {3}+1\right )-4 x \log \left (x^2+x+1\right )+\left (1+i \sqrt {3}\right ) \log \left (2 x+i \sqrt {3}+1\right ) \log \left (x^2+x+1\right )-2 \log \left (x^2+x+1\right )+8 x-\frac {1}{2} \left (1-i \sqrt {3}\right ) \log ^2\left (2 x-i \sqrt {3}+1\right )-\frac {1}{2} \left (1+i \sqrt {3}\right ) \log ^2\left (2 x+i \sqrt {3}+1\right )-\left (1-i \sqrt {3}\right ) \log \left (-\frac {i \left (2 x+i \sqrt {3}+1\right )}{2 \sqrt {3}}\right ) \log \left (2 x-i \sqrt {3}+1\right )-\left (1+i \sqrt {3}\right ) \log \left (\frac {i \left (2 x-i \sqrt {3}+1\right )}{2 \sqrt {3}}\right ) \log \left (2 x+i \sqrt {3}+1\right ) \]
[In]
[Out]
Rule 210
Rule 632
Rule 642
Rule 648
Rule 787
Rule 2338
Rule 2437
Rule 2438
Rule 2440
Rule 2441
Rule 2465
Rule 2603
Rule 2604
Rule 2608
Rubi steps \begin{align*} \text {integral}& = x \log ^2\left (1+x+x^2\right )-2 \int \frac {x (1+2 x) \log \left (1+x+x^2\right )}{1+x+x^2} \, dx \\ & = x \log ^2\left (1+x+x^2\right )-2 \int \left (2 \log \left (1+x+x^2\right )-\frac {(2+x) \log \left (1+x+x^2\right )}{1+x+x^2}\right ) \, dx \\ & = x \log ^2\left (1+x+x^2\right )+2 \int \frac {(2+x) \log \left (1+x+x^2\right )}{1+x+x^2} \, dx-4 \int \log \left (1+x+x^2\right ) \, dx \\ & = -4 x \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )+2 \int \left (\frac {\left (1-i \sqrt {3}\right ) \log \left (1+x+x^2\right )}{1-i \sqrt {3}+2 x}+\frac {\left (1+i \sqrt {3}\right ) \log \left (1+x+x^2\right )}{1+i \sqrt {3}+2 x}\right ) \, dx+4 \int \frac {x (1+2 x)}{1+x+x^2} \, dx \\ & = 8 x-4 x \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )+4 \int \frac {-2-x}{1+x+x^2} \, dx+\left (2 \left (1-i \sqrt {3}\right )\right ) \int \frac {\log \left (1+x+x^2\right )}{1-i \sqrt {3}+2 x} \, dx+\left (2 \left (1+i \sqrt {3}\right )\right ) \int \frac {\log \left (1+x+x^2\right )}{1+i \sqrt {3}+2 x} \, dx \\ & = 8 x-4 x \log \left (1+x+x^2\right )+\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+\left (1+i \sqrt {3}\right ) \log \left (1+i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )-2 \int \frac {1+2 x}{1+x+x^2} \, dx-6 \int \frac {1}{1+x+x^2} \, dx+\left (-1-i \sqrt {3}\right ) \int \frac {(1+2 x) \log \left (1+i \sqrt {3}+2 x\right )}{1+x+x^2} \, dx+\left (-1+i \sqrt {3}\right ) \int \frac {(1+2 x) \log \left (1-i \sqrt {3}+2 x\right )}{1+x+x^2} \, dx \\ & = 8 x-2 \log \left (1+x+x^2\right )-4 x \log \left (1+x+x^2\right )+\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+\left (1+i \sqrt {3}\right ) \log \left (1+i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )+12 \text {Subst}\left (\int \frac {1}{-3-x^2} \, dx,x,1+2 x\right )+\left (-1-i \sqrt {3}\right ) \int \left (\frac {2 \log \left (1+i \sqrt {3}+2 x\right )}{1-i \sqrt {3}+2 x}+\frac {2 \log \left (1+i \sqrt {3}+2 x\right )}{1+i \sqrt {3}+2 x}\right ) \, dx+\left (-1+i \sqrt {3}\right ) \int \left (\frac {2 \log \left (1-i \sqrt {3}+2 x\right )}{1-i \sqrt {3}+2 x}+\frac {2 \log \left (1-i \sqrt {3}+2 x\right )}{1+i \sqrt {3}+2 x}\right ) \, dx \\ & = 8 x-4 \sqrt {3} \tan ^{-1}\left (\frac {1+2 x}{\sqrt {3}}\right )-2 \log \left (1+x+x^2\right )-4 x \log \left (1+x+x^2\right )+\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+\left (1+i \sqrt {3}\right ) \log \left (1+i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )-\left (2 \left (1-i \sqrt {3}\right )\right ) \int \frac {\log \left (1-i \sqrt {3}+2 x\right )}{1-i \sqrt {3}+2 x} \, dx-\left (2 \left (1-i \sqrt {3}\right )\right ) \int \frac {\log \left (1-i \sqrt {3}+2 x\right )}{1+i \sqrt {3}+2 x} \, dx-\left (2 \left (1+i \sqrt {3}\right )\right ) \int \frac {\log \left (1+i \sqrt {3}+2 x\right )}{1-i \sqrt {3}+2 x} \, dx-\left (2 \left (1+i \sqrt {3}\right )\right ) \int \frac {\log \left (1+i \sqrt {3}+2 x\right )}{1+i \sqrt {3}+2 x} \, dx \\ & = 8 x-4 \sqrt {3} \tan ^{-1}\left (\frac {1+2 x}{\sqrt {3}}\right )-\left (1+i \sqrt {3}\right ) \log \left (\frac {i \left (1-i \sqrt {3}+2 x\right )}{2 \sqrt {3}}\right ) \log \left (1+i \sqrt {3}+2 x\right )-\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (-\frac {i \left (1+i \sqrt {3}+2 x\right )}{2 \sqrt {3}}\right )-2 \log \left (1+x+x^2\right )-4 x \log \left (1+x+x^2\right )+\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+\left (1+i \sqrt {3}\right ) \log \left (1+i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )-\left (1-i \sqrt {3}\right ) \text {Subst}\left (\int \frac {\log (x)}{x} \, dx,x,1-i \sqrt {3}+2 x\right )+\left (2 \left (1-i \sqrt {3}\right )\right ) \int \frac {\log \left (\frac {2 \left (1+i \sqrt {3}+2 x\right )}{-2 \left (1-i \sqrt {3}\right )+2 \left (1+i \sqrt {3}\right )}\right )}{1-i \sqrt {3}+2 x} \, dx-\left (1+i \sqrt {3}\right ) \text {Subst}\left (\int \frac {\log (x)}{x} \, dx,x,1+i \sqrt {3}+2 x\right )+\left (2 \left (1+i \sqrt {3}\right )\right ) \int \frac {\log \left (\frac {2 \left (1-i \sqrt {3}+2 x\right )}{2 \left (1-i \sqrt {3}\right )-2 \left (1+i \sqrt {3}\right )}\right )}{1+i \sqrt {3}+2 x} \, dx \\ & = 8 x-4 \sqrt {3} \tan ^{-1}\left (\frac {1+2 x}{\sqrt {3}}\right )-\frac {1}{2} \left (1-i \sqrt {3}\right ) \log ^2\left (1-i \sqrt {3}+2 x\right )-\left (1+i \sqrt {3}\right ) \log \left (\frac {i \left (1-i \sqrt {3}+2 x\right )}{2 \sqrt {3}}\right ) \log \left (1+i \sqrt {3}+2 x\right )-\frac {1}{2} \left (1+i \sqrt {3}\right ) \log ^2\left (1+i \sqrt {3}+2 x\right )-\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (-\frac {i \left (1+i \sqrt {3}+2 x\right )}{2 \sqrt {3}}\right )-2 \log \left (1+x+x^2\right )-4 x \log \left (1+x+x^2\right )+\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+\left (1+i \sqrt {3}\right ) \log \left (1+i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )+\left (1-i \sqrt {3}\right ) \text {Subst}\left (\int \frac {\log \left (1+\frac {2 x}{-2 \left (1-i \sqrt {3}\right )+2 \left (1+i \sqrt {3}\right )}\right )}{x} \, dx,x,1-i \sqrt {3}+2 x\right )+\left (1+i \sqrt {3}\right ) \text {Subst}\left (\int \frac {\log \left (1+\frac {2 x}{2 \left (1-i \sqrt {3}\right )-2 \left (1+i \sqrt {3}\right )}\right )}{x} \, dx,x,1+i \sqrt {3}+2 x\right ) \\ & = 8 x-4 \sqrt {3} \tan ^{-1}\left (\frac {1+2 x}{\sqrt {3}}\right )-\frac {1}{2} \left (1-i \sqrt {3}\right ) \log ^2\left (1-i \sqrt {3}+2 x\right )-\left (1+i \sqrt {3}\right ) \log \left (\frac {i \left (1-i \sqrt {3}+2 x\right )}{2 \sqrt {3}}\right ) \log \left (1+i \sqrt {3}+2 x\right )-\frac {1}{2} \left (1+i \sqrt {3}\right ) \log ^2\left (1+i \sqrt {3}+2 x\right )-\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (-\frac {i \left (1+i \sqrt {3}+2 x\right )}{2 \sqrt {3}}\right )-2 \log \left (1+x+x^2\right )-4 x \log \left (1+x+x^2\right )+\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+\left (1+i \sqrt {3}\right ) \log \left (1+i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )-\left (1+i \sqrt {3}\right ) \text {Li}_2\left (-\frac {i-\sqrt {3}+2 i x}{2 \sqrt {3}}\right )-\left (1-i \sqrt {3}\right ) \text {Li}_2\left (\frac {i+\sqrt {3}+2 i x}{2 \sqrt {3}}\right ) \\ \end{align*}
Time = 0.11 (sec) , antiderivative size = 365, normalized size of antiderivative = 0.98 \[ \int \log ^2\left (1+x+x^2\right ) \, dx=8 x-4 \sqrt {3} \arctan \left (\frac {1+2 x}{\sqrt {3}}\right )+i \left (i+\sqrt {3}\right ) \log \left (\frac {-i+\sqrt {3}-2 i x}{2 \sqrt {3}}\right ) \log \left (1-i \sqrt {3}+2 x\right )+\frac {1}{2} i \left (i+\sqrt {3}\right ) \log ^2\left (1-i \sqrt {3}+2 x\right )-\left (1+i \sqrt {3}\right ) \log \left (\frac {i+\sqrt {3}+2 i x}{2 \sqrt {3}}\right ) \log \left (1+i \sqrt {3}+2 x\right )-\frac {1}{2} \left (1+i \sqrt {3}\right ) \log ^2\left (1+i \sqrt {3}+2 x\right )-2 \log \left (1+x+x^2\right )-4 x \log \left (1+x+x^2\right )+\left (1-i \sqrt {3}\right ) \log \left (1-i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+\left (1+i \sqrt {3}\right ) \log \left (1+i \sqrt {3}+2 x\right ) \log \left (1+x+x^2\right )+x \log ^2\left (1+x+x^2\right )-\left (1+i \sqrt {3}\right ) \operatorname {PolyLog}\left (2,\frac {-i+\sqrt {3}-2 i x}{2 \sqrt {3}}\right )+i \left (i+\sqrt {3}\right ) \operatorname {PolyLog}\left (2,\frac {i+\sqrt {3}+2 i x}{2 \sqrt {3}}\right ) \]
[In]
[Out]
\[\int \ln \left (x^{2}+x +1\right )^{2}d x\]
[In]
[Out]
\[ \int \log ^2\left (1+x+x^2\right ) \, dx=\int { \log \left (x^{2} + x + 1\right )^{2} \,d x } \]
[In]
[Out]
Exception generated. \[ \int \log ^2\left (1+x+x^2\right ) \, dx=\text {Exception raised: RecursionError} \]
[In]
[Out]
\[ \int \log ^2\left (1+x+x^2\right ) \, dx=\int { \log \left (x^{2} + x + 1\right )^{2} \,d x } \]
[In]
[Out]
\[ \int \log ^2\left (1+x+x^2\right ) \, dx=\int { \log \left (x^{2} + x + 1\right )^{2} \,d x } \]
[In]
[Out]
Timed out. \[ \int \log ^2\left (1+x+x^2\right ) \, dx=\int {\ln \left (x^2+x+1\right )}^2 \,d x \]
[In]
[Out]