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

3.1.24.1 Optimal result
3.1.24.2 Mathematica [C] (verified)
3.1.24.3 Rubi [A] (verified)
3.1.24.4 Maple [B] (verified)
3.1.24.5 Fricas [C] (verification not implemented)
3.1.24.6 Sympy [F]
3.1.24.7 Maxima [F]
3.1.24.8 Giac [B] (verification not implemented)
3.1.24.9 Mupad [F(-1)]
3.1.24.10 Reduce [F]

3.1.24.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}} \]

output
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)
 
3.1.24.2 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 ] \]

input
Integrate[(1 - x + 3*x^2)/(Sqrt[1 - x + x^2]*(1 + x + x^2)^2),x]
 
output
((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 + Sq 
rt[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
 
3.1.24.3 Rubi [A] (verified)

Time = 0.29 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.09, number of steps used = 8, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.226, Rules used = {2135, 27, 1368, 27, 1362, 217, 219}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {3 x^2-x+1}{\sqrt {x^2-x+1} \left (x^2+x+1\right )^2} \, dx\)

\(\Big \downarrow \) 2135

\(\displaystyle \frac {1}{12} \int \frac {6 (3-x)}{\sqrt {x^2-x+1} \left (x^2+x+1\right )}dx+\frac {\sqrt {x^2-x+1} (x+1)}{x^2+x+1}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {1}{2} \int \frac {3-x}{\sqrt {x^2-x+1} \left (x^2+x+1\right )}dx+\frac {\sqrt {x^2-x+1} (x+1)}{x^2+x+1}\)

\(\Big \downarrow \) 1368

\(\displaystyle \frac {1}{2} \left (\frac {1}{4} \int \frac {4 (x+1)}{\sqrt {x^2-x+1} \left (x^2+x+1\right )}dx-\frac {1}{4} \int -\frac {8 (1-x)}{\sqrt {x^2-x+1} \left (x^2+x+1\right )}dx\right )+\frac {\sqrt {x^2-x+1} (x+1)}{x^2+x+1}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {1}{2} \left (2 \int \frac {1-x}{\sqrt {x^2-x+1} \left (x^2+x+1\right )}dx+\int \frac {x+1}{\sqrt {x^2-x+1} \left (x^2+x+1\right )}dx\right )+\frac {\sqrt {x^2-x+1} (x+1)}{x^2+x+1}\)

\(\Big \downarrow \) 1362

\(\displaystyle \frac {1}{2} \left (2 \int \frac {1}{3-\frac {2 (1-x)^2}{x^2-x+1}}d\left (-\frac {1-x}{\sqrt {x^2-x+1}}\right )-12 \int \frac {1}{-\frac {18 (x+1)^2}{x^2-x+1}-9}d\frac {3 (x+1)}{\sqrt {x^2-x+1}}\right )+\frac {\sqrt {x^2-x+1} (x+1)}{x^2+x+1}\)

\(\Big \downarrow \) 217

\(\displaystyle \frac {1}{2} \left (2 \int \frac {1}{3-\frac {2 (1-x)^2}{x^2-x+1}}d\left (-\frac {1-x}{\sqrt {x^2-x+1}}\right )+2 \sqrt {2} \arctan \left (\frac {\sqrt {2} (x+1)}{\sqrt {x^2-x+1}}\right )\right )+\frac {\sqrt {x^2-x+1} (x+1)}{x^2+x+1}\)

\(\Big \downarrow \) 219

\(\displaystyle \frac {1}{2} \left (2 \sqrt {2} \arctan \left (\frac {\sqrt {2} (x+1)}{\sqrt {x^2-x+1}}\right )-\sqrt {\frac {2}{3}} \text {arctanh}\left (\frac {\sqrt {\frac {2}{3}} (1-x)}{\sqrt {x^2-x+1}}\right )\right )+\frac {\sqrt {x^2-x+1} (x+1)}{x^2+x+1}\)

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

3.1.24.3.1 Defintions of rubi rules used

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

rule 217
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 219
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] && (Gt 
Q[a, 0] || LtQ[b, 0])
 

rule 1362
Int[((g_.) + (h_.)*(x_))/(((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)*Sqrt[(d_.) + 
(e_.)*(x_) + (f_.)*(x_)^2]), x_Symbol] :> Simp[-2*g*(g*b - 2*a*h)   Subst[I 
nt[1/Simp[g*(g*b - 2*a*h)*(b^2 - 4*a*c) - (b*d - a*e)*x^2, x], x], x, Simp[ 
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] && Ne 
Q[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 1368
Int[((g_.) + (h_.)*(x_))/(((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)*Sqrt[(d_.) + 
(e_.)*(x_) + (f_.)*(x_)^2]), x_Symbol] :> With[{q = Rt[(c*d - a*f)^2 - (b*d 
 - a*e)*(c*e - b*f), 2]}, Simp[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)*Sqr 
t[d + e*x + f*x^2]), x], x] - Simp[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] && N 
eQ[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 2135
Int[(Px_)*((a_) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_)*((d_) + (e_.)*(x_) + (f_. 
)*(x_)^2)^(q_), x_Symbol] :> With[{A = Coeff[Px, x, 0], B = Coeff[Px, x, 1] 
, C = Coeff[Px, x, 2]}, 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] + Simp[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]] /; F 
reeQ[{a, b, c, d, e, f, q}, x] && PolyQ[Px, x, 2] && 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]
 
3.1.24.4 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\)

input
int((3*x^2-x+1)/(x^2+x+1)^2/(x^2-x+1)^(1/2),x,method=_RETURNVERBOSE)
 
output
(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)*a 
rctan(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)
 
3.1.24.5 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 )}} \]

input
integrate((3*x^2-x+1)/(x^2+x+1)^2/(x^2-x+1)^(1/2),x, algorithm="fricas")
 
output
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*sq 
rt(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)*sqr 
t(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*sq 
rt(x^2 - x + 1) - 39) + 12*x^2 + 12*sqrt(x^2 - x + 1)*(x + 1) + 12*x + 12) 
/(x^2 + x + 1)
 
3.1.24.6 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 \]

input
integrate((3*x**2-x+1)/(x**2+x+1)**2/(x**2-x+1)**(1/2),x)
 
output
Integral((3*x**2 - x + 1)/(sqrt(x**2 - x + 1)*(x**2 + x + 1)**2), x)
 
3.1.24.7 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 } \]

input
integrate((3*x^2-x+1)/(x^2+x+1)^2/(x^2-x+1)^(1/2),x, algorithm="maxima")
 
output
integrate((3*x^2 - x + 1)/((x^2 + x + 1)^2*sqrt(x^2 - x + 1)), x)
 
3.1.24.8 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} \]

input
integrate((3*x^2-x+1)/(x^2+x+1)^2/(x^2-x+1)^(1/2),x, algorithm="giac")
 
output
-1/3*sqrt(6)*sqrt(3)*arctan(-(2*x + sqrt(6) - 2*sqrt(x^2 - x + 1) + 1)/(sq 
rt(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*s 
qrt(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 - sqrt(x^2 - x + 1))^2 - 6*x + 6*sqrt(x^2 - x 
 + 1) + 3)
 
3.1.24.9 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 \]

input
int((3*x^2 - x + 1)/((x^2 - x + 1)^(1/2)*(x + x^2 + 1)^2),x)
 
output
int((3*x^2 - x + 1)/((x^2 - x + 1)^(1/2)*(x + x^2 + 1)^2), x)
 
3.1.24.10 Reduce [F]

\[ \int \frac {1-x+3 x^2}{\sqrt {1-x+x^2} \left (1+x+x^2\right )^2} \, dx=\frac {4 \sqrt {x^{2}-x +1}\, x +6 \sqrt {x^{2}-x +1}+14 \left (\int \frac {\sqrt {x^{2}-x +1}}{x^{6}+x^{5}+2 x^{4}+x^{3}+2 x^{2}+x +1}d x \right ) x^{2}+14 \left (\int \frac {\sqrt {x^{2}-x +1}}{x^{6}+x^{5}+2 x^{4}+x^{3}+2 x^{2}+x +1}d x \right ) x +14 \left (\int \frac {\sqrt {x^{2}-x +1}}{x^{6}+x^{5}+2 x^{4}+x^{3}+2 x^{2}+x +1}d x \right )+16 \left (\int \frac {\sqrt {x^{2}-x +1}\, x^{2}}{x^{6}+x^{5}+2 x^{4}+x^{3}+2 x^{2}+x +1}d x \right ) x^{2}+16 \left (\int \frac {\sqrt {x^{2}-x +1}\, x^{2}}{x^{6}+x^{5}+2 x^{4}+x^{3}+2 x^{2}+x +1}d x \right ) x +16 \left (\int \frac {\sqrt {x^{2}-x +1}\, x^{2}}{x^{6}+x^{5}+2 x^{4}+x^{3}+2 x^{2}+x +1}d x \right )}{9 x^{2}+9 x +9} \]

input
int((3*x**2 - x + 1)/(sqrt(x**2 - x + 1)*(x**4 + 2*x**3 + 3*x**2 + 2*x + 1 
)),x)
 
output
(2*(2*sqrt(x**2 - x + 1)*x + 3*sqrt(x**2 - x + 1) + 7*int(sqrt(x**2 - x + 
1)/(x**6 + x**5 + 2*x**4 + x**3 + 2*x**2 + x + 1),x)*x**2 + 7*int(sqrt(x** 
2 - x + 1)/(x**6 + x**5 + 2*x**4 + x**3 + 2*x**2 + x + 1),x)*x + 7*int(sqr 
t(x**2 - x + 1)/(x**6 + x**5 + 2*x**4 + x**3 + 2*x**2 + x + 1),x) + 8*int( 
(sqrt(x**2 - x + 1)*x**2)/(x**6 + x**5 + 2*x**4 + x**3 + 2*x**2 + x + 1),x 
)*x**2 + 8*int((sqrt(x**2 - x + 1)*x**2)/(x**6 + x**5 + 2*x**4 + x**3 + 2* 
x**2 + x + 1),x)*x + 8*int((sqrt(x**2 - x + 1)*x**2)/(x**6 + x**5 + 2*x**4 
 + x**3 + 2*x**2 + x + 1),x)))/(9*(x**2 + x + 1))