\(\int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} (1+x+x^2)^2} \, dx\) [24]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [B] (verified)
   Fricas [C] (verification not implemented)
   Sympy [F]
   Maxima [F]
   Giac [B] (verification not implemented)
   Mupad [F(-1)]

Optimal result

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]

arctan((1+x)*2^(1/2)/(x^2-x+1)^(1/2))*2^(1/2)-1/6*arctanh(1/3*(1-x)*6^(1/2)/(x^2-x+1)^(1/2))*6^(1/2)+(1+x)*(x^
2-x+1)^(1/2)/(x^2+x+1)

Rubi [A] (verified)

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]

Int[(1 - x + 3*x^2)/(Sqrt[1 - x + x^2]*(1 + x + x^2)^2),x]

[Out]

((1 + x)*Sqrt[1 - x + x^2])/(1 + x + x^2) + Sqrt[2]*ArcTan[(Sqrt[2]*(1 + x))/Sqrt[1 - x + x^2]] - ArcTanh[(Sqr
t[2/3]*(1 - x))/Sqrt[1 - x + x^2]]/Sqrt[6]

Rule 210

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(-(Rt[-a, 2]*Rt[-b, 2])^(-1))*ArcTan[Rt[-b, 2]*(x/Rt[-a, 2])
], x] /; FreeQ[{a, b}, x] && PosQ[a/b] && (LtQ[a, 0] || LtQ[b, 0])

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 1043

Int[((g_.) + (h_.)*(x_))/(((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)*Sqrt[(d_.) + (e_.)*(x_) + (f_.)*(x_)^2]), x_Symb
ol] :> Dist[-2*g*(g*b - 2*a*h), Subst[Int[1/Simp[g*(g*b - 2*a*h)*(b^2 - 4*a*c) - (b*d - a*e)*x^2, x], x], x, S
imp[g*b - 2*a*h - (b*h - 2*g*c)*x, x]/Sqrt[d + e*x + f*x^2]], x] /; FreeQ[{a, b, c, d, e, f, g, h}, x] && NeQ[
b^2 - 4*a*c, 0] && NeQ[e^2 - 4*d*f, 0] && NeQ[b*d - a*e, 0] && EqQ[h^2*(b*d - a*e) - 2*g*h*(c*d - a*f) + g^2*(
c*e - b*f), 0]

Rule 1049

Int[((g_.) + (h_.)*(x_))/(((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)*Sqrt[(d_.) + (e_.)*(x_) + (f_.)*(x_)^2]), x_Symb
ol] :> With[{q = Rt[(c*d - a*f)^2 - (b*d - a*e)*(c*e - b*f), 2]}, Dist[1/(2*q), Int[Simp[h*(b*d - a*e) - g*(c*
d - a*f - q) - (g*(c*e - b*f) - h*(c*d - a*f + q))*x, x]/((a + b*x + c*x^2)*Sqrt[d + e*x + f*x^2]), x], x] - D
ist[1/(2*q), Int[Simp[h*(b*d - a*e) - g*(c*d - a*f + q) - (g*(c*e - b*f) - h*(c*d - a*f - q))*x, x]/((a + b*x
+ c*x^2)*Sqrt[d + e*x + f*x^2]), x], x]] /; FreeQ[{a, b, c, d, e, f, g, h}, x] && NeQ[b^2 - 4*a*c, 0] && NeQ[e
^2 - 4*d*f, 0] && NeQ[b*d - a*e, 0] && NegQ[b^2 - 4*a*c]

Rule 1074

Int[((a_) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_)*((A_.) + (B_.)*(x_) + (C_.)*(x_)^2)*((d_) + (e_.)*(x_) + (f_.)*(x_
)^2)^(q_), x_Symbol] :> Simp[(a + b*x + c*x^2)^(p + 1)*((d + e*x + f*x^2)^(q + 1)/((b^2 - 4*a*c)*((c*d - a*f)^
2 - (b*d - a*e)*(c*e - b*f))*(p + 1)))*((A*c - a*C)*(2*a*c*e - b*(c*d + a*f)) + (A*b - a*B)*(2*c^2*d + b^2*f -
 c*(b*e + 2*a*f)) + c*(A*(2*c^2*d + b^2*f - c*(b*e + 2*a*f)) - B*(b*c*d - 2*a*c*e + a*b*f) + C*(b^2*d - a*b*e
- 2*a*(c*d - a*f)))*x), x] + Dist[1/((b^2 - 4*a*c)*((c*d - a*f)^2 - (b*d - a*e)*(c*e - b*f))*(p + 1)), Int[(a
+ b*x + c*x^2)^(p + 1)*(d + e*x + f*x^2)^q*Simp[(b*B - 2*A*c - 2*a*C)*((c*d - a*f)^2 - (b*d - a*e)*(c*e - b*f)
)*(p + 1) + (b^2*(C*d + A*f) - b*(B*c*d + A*c*e + a*C*e + a*B*f) + 2*(A*c*(c*d - a*f) - a*(c*C*d - B*c*e - a*C
*f)))*(a*f*(p + 1) - c*d*(p + 2)) - e*((A*c - a*C)*(2*a*c*e - b*(c*d + a*f)) + (A*b - a*B)*(2*c^2*d + b^2*f -
c*(b*e + 2*a*f)))*(p + q + 2) - (2*f*((A*c - a*C)*(2*a*c*e - b*(c*d + a*f)) + (A*b - a*B)*(2*c^2*d + b^2*f - c
*(b*e + 2*a*f)))*(p + q + 2) - (b^2*(C*d + A*f) - b*(B*c*d + A*c*e + a*C*e + a*B*f) + 2*(A*c*(c*d - a*f) - a*(
c*C*d - B*c*e - a*C*f)))*(b*f*(p + 1) - c*e*(2*p + q + 4)))*x - c*f*(b^2*(C*d + A*f) - b*(B*c*d + A*c*e + a*C*
e + a*B*f) + 2*(A*c*(c*d - a*f) - a*(c*C*d - B*c*e - a*C*f)))*(2*p + 2*q + 5)*x^2, x], x], x] /; FreeQ[{a, b,
c, d, e, f, A, B, C, q}, x] && NeQ[b^2 - 4*a*c, 0] && NeQ[e^2 - 4*d*f, 0] && LtQ[p, -1] && NeQ[(c*d - a*f)^2 -
 (b*d - a*e)*(c*e - b*f), 0] &&  !( !IntegerQ[p] && ILtQ[q, -1]) &&  !IGtQ[q, 0]

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*}

Mathematica [C] (verified)

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]

Integrate[(1 - x + 3*x^2)/(Sqrt[1 - x + x^2]*(1 + x + x^2)^2),x]

[Out]

((1 + x)*Sqrt[1 - x + x^2])/(1 + x + x^2) - RootSum[3 + 6*#1 + #1^2 - 2*#1^3 + #1^4 & , (19*Log[-x + Sqrt[1 -
x + x^2] - #1] + 6*Log[-x + Sqrt[1 - x + x^2] - #1]*#1)/(3 + #1 - 3*#1^2 + 2*#1^3) & ] - RootSum[3 + 6*#1 + #1
^2 - 2*#1^3 + #1^4 & , (-36*Log[-x + Sqrt[1 - x + x^2] - #1] - 6*Log[-x + Sqrt[1 - x + x^2] - #1]*#1 + Log[-x
+ Sqrt[1 - x + x^2] - #1]*#1^2)/(3 + #1 - 3*#1^2 + 2*#1^3) & ]/2

Maple [B] (verified)

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]

int((3*x^2-x+1)/(x^2+x+1)^2/(x^2-x+1)^(1/2),x,method=_RETURNVERBOSE)

[Out]

(1+x)*(x^2-x+1)^(1/2)/(x^2+x+1)+1/6*((1+x)^2/(1-x)^2+3)^(1/2)*(6*2^(1/2)*arctan(2*2^(1/2)/((1+x)^2/(1-x)^2+3)^
(1/2)*(1+x)/(1-x))-6^(1/2)*arctanh(1/4*((1+x)^2/(1-x)^2+3)^(1/2)*6^(1/2)))/(((1+x)^2/(1-x)^2+3)/((1+x)/(1-x)+1
)^2)^(1/2)/((1+x)/(1-x)+1)

Fricas [C] (verification not implemented)

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]

integrate((3*x^2-x+1)/(x^2+x+1)^2/(x^2-x+1)^(1/2),x, algorithm="fricas")

[Out]

1/12*(sqrt(6)*(x^2 + x + 1)*sqrt(4*I*sqrt(3) - 11)*log(sqrt(6)*(5*I*sqrt(3) - 9)*sqrt(4*I*sqrt(3) - 11) - 78*x
 - 39*I*sqrt(3) + 78*sqrt(x^2 - x + 1) - 39) - sqrt(6)*(x^2 + x + 1)*sqrt(-4*I*sqrt(3) - 11)*log(sqrt(6)*(5*I*
sqrt(3) + 9)*sqrt(-4*I*sqrt(3) - 11) - 78*x + 39*I*sqrt(3) + 78*sqrt(x^2 - x + 1) - 39) - sqrt(6)*(x^2 + x + 1
)*sqrt(4*I*sqrt(3) - 11)*log(sqrt(6)*sqrt(4*I*sqrt(3) - 11)*(-5*I*sqrt(3) + 9) - 78*x - 39*I*sqrt(3) + 78*sqrt
(x^2 - x + 1) - 39) + sqrt(6)*(x^2 + x + 1)*sqrt(-4*I*sqrt(3) - 11)*log(sqrt(6)*sqrt(-4*I*sqrt(3) - 11)*(-5*I*
sqrt(3) - 9) - 78*x + 39*I*sqrt(3) + 78*sqrt(x^2 - x + 1) - 39) + 12*x^2 + 12*sqrt(x^2 - x + 1)*(x + 1) + 12*x
 + 12)/(x^2 + x + 1)

Sympy [F]

\[ \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]

integrate((3*x**2-x+1)/(x**2+x+1)**2/(x**2-x+1)**(1/2),x)

[Out]

Integral((3*x**2 - x + 1)/(sqrt(x**2 - x + 1)*(x**2 + x + 1)**2), x)

Maxima [F]

\[ \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]

integrate((3*x^2-x+1)/(x^2+x+1)^2/(x^2-x+1)^(1/2),x, algorithm="maxima")

[Out]

integrate((3*x^2 - x + 1)/((x^2 + x + 1)^2*sqrt(x^2 - x + 1)), x)

Giac [B] (verification not implemented)

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]

integrate((3*x^2-x+1)/(x^2+x+1)^2/(x^2-x+1)^(1/2),x, algorithm="giac")

[Out]

-1/3*sqrt(6)*sqrt(3)*arctan(-(2*x + sqrt(6) - 2*sqrt(x^2 - x + 1) + 1)/(sqrt(3) + sqrt(2))) + 1/3*sqrt(6)*sqrt
(3)*arctan(-(2*x - sqrt(6) - 2*sqrt(x^2 - x + 1) + 1)/(sqrt(3) - sqrt(2))) + 1/12*sqrt(6)*log(4*(sqrt(6)*sqrt(
3) + 3*sqrt(3))^2 + 36*(2*x + sqrt(6) - 2*sqrt(x^2 - x + 1) + 1)^2) - 1/12*sqrt(6)*log(4*(sqrt(6)*sqrt(3) - 3*
sqrt(3))^2 + 36*(2*x - sqrt(6) - 2*sqrt(x^2 - x + 1) + 1)^2) + ((x - sqrt(x^2 - x + 1))^3 + 4*(x - sqrt(x^2 -
x + 1))^2 - 10*x + 10*sqrt(x^2 - x + 1) + 5)/((x - sqrt(x^2 - x + 1))^4 + 2*(x - sqrt(x^2 - x + 1))^3 + (x - s
qrt(x^2 - x + 1))^2 - 6*x + 6*sqrt(x^2 - x + 1) + 3)

Mupad [F(-1)]

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]

int((3*x^2 - x + 1)/((x^2 - x + 1)^(1/2)*(x + x^2 + 1)^2),x)

[Out]

int((3*x^2 - x + 1)/((x^2 - x + 1)^(1/2)*(x + x^2 + 1)^2), x)