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

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

Optimal result

Integrand size = 21, antiderivative size = 56 \[ \int \frac {3+x}{\left (1+x^2\right ) \sqrt {1+x+x^2}} \, dx=-2 \sqrt {2} \arctan \left (\frac {1-x}{\sqrt {2} \sqrt {1+x+x^2}}\right )+\sqrt {2} \text {arctanh}\left (\frac {1+x}{\sqrt {2} \sqrt {1+x+x^2}}\right ) \] Output:

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

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 9 vs. order 3 in optimal.

Time = 0.11 (sec) , antiderivative size = 103, normalized size of antiderivative = 1.84 \[ \int \frac {3+x}{\left (1+x^2\right ) \sqrt {1+x+x^2}} \, dx=\frac {1}{2} \text {RootSum}\left [2-4 \text {$\#$1}+2 \text {$\#$1}^2+\text {$\#$1}^4\&,\frac {2 \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}{-1+\text {$\#$1}+\text {$\#$1}^3}\&\right ] \] Input:

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

Output:

RootSum[2 - 4*#1 + 2*#1^2 + #1^4 & , (2*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)/(-1 + #1 + #1^3) & ]/2
 

Rubi [A] (verified)

Time = 0.20 (sec) , antiderivative size = 56, 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.238, Rules used = {1369, 27, 1363, 216, 220}

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 {x+3}{\left (x^2+1\right ) \sqrt {x^2+x+1}} \, dx\)

\(\Big \downarrow \) 1369

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

\(\Big \downarrow \) 27

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

\(\Big \downarrow \) 1363

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

\(\Big \downarrow \) 216

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

\(\Big \downarrow \) 220

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

Input:

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

Output:

-2*Sqrt[2]*ArcTan[(1 - x)/(Sqrt[2]*Sqrt[1 + x + x^2])] + Sqrt[2]*ArcTanh[( 
1 + x)/(Sqrt[2]*Sqrt[1 + x + x^2])]
 

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 216
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*A 
rcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /; FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a 
, 0] || GtQ[b, 0])
 

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

rule 1363
Int[((g_) + (h_.)*(x_))/(((a_) + (c_.)*(x_)^2)*Sqrt[(d_.) + (e_.)*(x_) + (f 
_.)*(x_)^2]), x_Symbol] :> Simp[-2*a*g*h   Subst[Int[1/Simp[2*a^2*g*h*c + a 
*e*x^2, x], x], x, Simp[a*h - g*c*x, x]/Sqrt[d + e*x + f*x^2]], x] /; FreeQ 
[{a, c, d, e, f, g, h}, x] && EqQ[a*h^2*e + 2*g*h*(c*d - a*f) - g^2*c*e, 0]
 

rule 1369
Int[((g_.) + (h_.)*(x_))/(((a_) + (c_.)*(x_)^2)*Sqrt[(d_.) + (e_.)*(x_) + ( 
f_.)*(x_)^2]), x_Symbol] :> With[{q = Rt[(c*d - a*f)^2 + a*c*e^2, 2]}, Simp 
[1/(2*q)   Int[Simp[(-a)*h*e - g*(c*d - a*f - q) + (h*(c*d - a*f + q) - g*c 
*e)*x, x]/((a + c*x^2)*Sqrt[d + e*x + f*x^2]), x], x] - Simp[1/(2*q)   Int[ 
Simp[(-a)*h*e - g*(c*d - a*f + q) + (h*(c*d - a*f - q) - g*c*e)*x, x]/((a + 
 c*x^2)*Sqrt[d + e*x + f*x^2]), x], x]] /; FreeQ[{a, c, d, e, f, g, h}, x] 
&& NeQ[e^2 - 4*d*f, 0] && NegQ[(-a)*c]
 
Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(127\) vs. \(2(46)=92\).

Time = 0.69 (sec) , antiderivative size = 128, normalized size of antiderivative = 2.29

method result size
default \(\frac {\sqrt {\frac {\left (-1+x \right )^{2}}{\left (-1-x \right )^{2}}+3}\, \sqrt {2}\, \left (\operatorname {arctanh}\left (\frac {\sqrt {\frac {\left (-1+x \right )^{2}}{\left (-1-x \right )^{2}}+3}\, \sqrt {2}}{2}\right )-2 \arctan \left (\frac {\sqrt {2}\, \left (-1+x \right )}{\sqrt {\frac {\left (-1+x \right )^{2}}{\left (-1-x \right )^{2}}+3}\, \left (-1-x \right )}\right )\right )}{\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 )}\) \(128\)
trager \(-\operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right ) \ln \left (\frac {12 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{4} x +92 x \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{2}+40 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{2}-64 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right ) \sqrt {x^{2}+x +1}+175 x +140}{2 x \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{2}+3 x +4}\right )-\frac {2 \ln \left (-\frac {12 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{5} x +172 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{3} x -40 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{3}-320 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{2} \sqrt {x^{2}+x +1}-217 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right ) x -620 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )-960 \sqrt {x^{2}+x +1}}{2 x \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{2}+3 x -4}\right ) \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{3}}{5}-\frac {6 \ln \left (-\frac {12 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{5} x +172 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{3} x -40 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{3}-320 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{2} \sqrt {x^{2}+x +1}-217 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right ) x -620 \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )-960 \sqrt {x^{2}+x +1}}{2 x \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )^{2}+3 x -4}\right ) \operatorname {RootOf}\left (4 \textit {\_Z}^{4}+12 \textit {\_Z}^{2}+25\right )}{5}\) \(453\)

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 146 vs. \(2 (44) = 88\).

Time = 0.07 (sec) , antiderivative size = 146, normalized size of antiderivative = 2.61 \[ \int \frac {3+x}{\left (1+x^2\right ) \sqrt {1+x+x^2}} \, dx=-2 \, \sqrt {2} \arctan \left (-\sqrt {2} {\left (x + 1\right )} + \sqrt {x^{2} + x + 1} {\left (\sqrt {2} + 2\right )} - 2 \, x - 1\right ) - 2 \, \sqrt {2} \arctan \left (-\sqrt {2} {\left (x + 1\right )} + \sqrt {x^{2} + x + 1} {\left (\sqrt {2} - 2\right )} + 2 \, x + 1\right ) - \frac {1}{2} \, \sqrt {2} \log \left (2 \, x^{2} - \sqrt {x^{2} + x + 1} {\left (2 \, x + \sqrt {2}\right )} + \sqrt {2} {\left (x - 1\right )} + x + 3\right ) + \frac {1}{2} \, \sqrt {2} \log \left (2 \, x^{2} - \sqrt {x^{2} + x + 1} {\left (2 \, x - \sqrt {2}\right )} - \sqrt {2} {\left (x - 1\right )} + x + 3\right ) \] Input:

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

Output:

-2*sqrt(2)*arctan(-sqrt(2)*(x + 1) + sqrt(x^2 + x + 1)*(sqrt(2) + 2) - 2*x 
 - 1) - 2*sqrt(2)*arctan(-sqrt(2)*(x + 1) + sqrt(x^2 + x + 1)*(sqrt(2) - 2 
) + 2*x + 1) - 1/2*sqrt(2)*log(2*x^2 - sqrt(x^2 + x + 1)*(2*x + sqrt(2)) + 
 sqrt(2)*(x - 1) + x + 3) + 1/2*sqrt(2)*log(2*x^2 - sqrt(x^2 + x + 1)*(2*x 
 - sqrt(2)) - sqrt(2)*(x - 1) + x + 3)
 

Sympy [F]

\[ \int \frac {3+x}{\left (1+x^2\right ) \sqrt {1+x+x^2}} \, dx=\int \frac {x + 3}{\left (x^{2} + 1\right ) \sqrt {x^{2} + x + 1}}\, dx \] Input:

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

Output:

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

Maxima [F]

\[ \int \frac {3+x}{\left (1+x^2\right ) \sqrt {1+x+x^2}} \, dx=\int { \frac {x + 3}{\sqrt {x^{2} + x + 1} {\left (x^{2} + 1\right )}} \,d x } \] Input:

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

Output:

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

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 152 vs. \(2 (44) = 88\).

Time = 0.13 (sec) , antiderivative size = 152, normalized size of antiderivative = 2.71 \[ \int \frac {3+x}{\left (1+x^2\right ) \sqrt {1+x+x^2}} \, dx=-\frac {1}{2} \, \sqrt {2} {\left (\pi + 4 \, \arctan \left (-{\left (x - \sqrt {x^{2} + x + 1}\right )} {\left (\sqrt {2} + 2\right )} - \sqrt {2} - 1\right )\right )} + \frac {1}{2} \, \sqrt {2} {\left (\pi + 4 \, \arctan \left ({\left (x - \sqrt {x^{2} + x + 1}\right )} {\left (\sqrt {2} - 2\right )} + \sqrt {2} - 1\right )\right )} - \frac {1}{2} \, \sqrt {2} \log \left ({\left (x + \sqrt {2} - \sqrt {x^{2} + x + 1} - 1\right )}^{2} + {\left (x - \sqrt {x^{2} + x + 1} + 1\right )}^{2}\right ) + \frac {1}{2} \, \sqrt {2} \log \left ({\left (x - \sqrt {2} - \sqrt {x^{2} + x + 1} - 1\right )}^{2} + {\left (x - \sqrt {x^{2} + x + 1} + 1\right )}^{2}\right ) \] Input:

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

Output:

-1/2*sqrt(2)*(pi + 4*arctan(-(x - sqrt(x^2 + x + 1))*(sqrt(2) + 2) - sqrt( 
2) - 1)) + 1/2*sqrt(2)*(pi + 4*arctan((x - sqrt(x^2 + x + 1))*(sqrt(2) - 2 
) + sqrt(2) - 1)) - 1/2*sqrt(2)*log((x + sqrt(2) - sqrt(x^2 + x + 1) - 1)^ 
2 + (x - sqrt(x^2 + x + 1) + 1)^2) + 1/2*sqrt(2)*log((x - sqrt(2) - sqrt(x 
^2 + x + 1) - 1)^2 + (x - sqrt(x^2 + x + 1) + 1)^2)
 

Mupad [F(-1)]

Timed out. \[ \int \frac {3+x}{\left (1+x^2\right ) \sqrt {1+x+x^2}} \, dx=\int \frac {x+3}{\left (x^2+1\right )\,\sqrt {x^2+x+1}} \,d x \] Input:

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

Output:

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

Reduce [F]

\[ \int \frac {3+x}{\left (1+x^2\right ) \sqrt {1+x+x^2}} \, dx=3 \left (\int \frac {\sqrt {x^{2}+x +1}}{x^{4}+x^{3}+2 x^{2}+x +1}d x \right )+\int \frac {\sqrt {x^{2}+x +1}\, x}{x^{4}+x^{3}+2 x^{2}+x +1}d x \] Input:

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

Output:

3*int(sqrt(x**2 + x + 1)/(x**4 + x**3 + 2*x**2 + x + 1),x) + int((sqrt(x** 
2 + x + 1)*x)/(x**4 + x**3 + 2*x**2 + x + 1),x)