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

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

Optimal result

Integrand size = 25, antiderivative size = 36 \[ \int \frac {2-4 x^2+x^3}{\left (1+x^2\right ) \left (2+x^2\right )} \, dx=6 \arctan (x)-5 \sqrt {2} \arctan \left (\frac {x}{\sqrt {2}}\right )-\frac {1}{2} \log \left (1+x^2\right )+\log \left (2+x^2\right ) \]

[Out]

6*arctan(x)-1/2*ln(x^2+1)+ln(x^2+2)-5*arctan(1/2*x*2^(1/2))*2^(1/2)

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 36, normalized size of antiderivative = 1.00, number of steps used = 8, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.160, Rules used = {6857, 649, 209, 266} \[ \int \frac {2-4 x^2+x^3}{\left (1+x^2\right ) \left (2+x^2\right )} \, dx=6 \arctan (x)-5 \sqrt {2} \arctan \left (\frac {x}{\sqrt {2}}\right )-\frac {1}{2} \log \left (x^2+1\right )+\log \left (x^2+2\right ) \]

[In]

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

[Out]

6*ArcTan[x] - 5*Sqrt[2]*ArcTan[x/Sqrt[2]] - Log[1 + x^2]/2 + Log[2 + x^2]

Rule 209

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

Rule 266

Int[(x_)^(m_.)/((a_) + (b_.)*(x_)^(n_)), x_Symbol] :> Simp[Log[RemoveContent[a + b*x^n, x]]/(b*n), x] /; FreeQ
[{a, b, m, n}, x] && EqQ[m, n - 1]

Rule 649

Int[((d_) + (e_.)*(x_))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Dist[d, Int[1/(a + c*x^2), x], x] + Dist[e, Int[x/
(a + c*x^2), x], x] /; FreeQ[{a, c, d, e}, x] &&  !NiceSqrtQ[(-a)*c]

Rule 6857

Int[(u_)/((a_) + (b_.)*(x_)^(n_)), x_Symbol] :> With[{v = RationalFunctionExpand[u/(a + b*x^n), x]}, Int[v, x]
 /; SumQ[v]] /; FreeQ[{a, b}, x] && IGtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \int \left (\frac {6-x}{1+x^2}+\frac {2 (-5+x)}{2+x^2}\right ) \, dx \\ & = 2 \int \frac {-5+x}{2+x^2} \, dx+\int \frac {6-x}{1+x^2} \, dx \\ & = 2 \int \frac {x}{2+x^2} \, dx+6 \int \frac {1}{1+x^2} \, dx-10 \int \frac {1}{2+x^2} \, dx-\int \frac {x}{1+x^2} \, dx \\ & = 6 \tan ^{-1}(x)-5 \sqrt {2} \tan ^{-1}\left (\frac {x}{\sqrt {2}}\right )-\frac {1}{2} \log \left (1+x^2\right )+\log \left (2+x^2\right ) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.01 (sec) , antiderivative size = 36, normalized size of antiderivative = 1.00 \[ \int \frac {2-4 x^2+x^3}{\left (1+x^2\right ) \left (2+x^2\right )} \, dx=6 \arctan (x)-5 \sqrt {2} \arctan \left (\frac {x}{\sqrt {2}}\right )-\frac {1}{2} \log \left (1+x^2\right )+\log \left (2+x^2\right ) \]

[In]

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

[Out]

6*ArcTan[x] - 5*Sqrt[2]*ArcTan[x/Sqrt[2]] - Log[1 + x^2]/2 + Log[2 + x^2]

Maple [A] (verified)

Time = 0.79 (sec) , antiderivative size = 32, normalized size of antiderivative = 0.89

method result size
default \(6 \arctan \left (x \right )-\frac {\ln \left (x^{2}+1\right )}{2}+\ln \left (x^{2}+2\right )-5 \arctan \left (\frac {x \sqrt {2}}{2}\right ) \sqrt {2}\) \(32\)
risch \(6 \arctan \left (x \right )-\frac {\ln \left (x^{2}+1\right )}{2}+\ln \left (x^{2}+2\right )-5 \arctan \left (\frac {x \sqrt {2}}{2}\right ) \sqrt {2}\) \(32\)

[In]

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

[Out]

6*arctan(x)-1/2*ln(x^2+1)+ln(x^2+2)-5*arctan(1/2*x*2^(1/2))*2^(1/2)

Fricas [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 31, normalized size of antiderivative = 0.86 \[ \int \frac {2-4 x^2+x^3}{\left (1+x^2\right ) \left (2+x^2\right )} \, dx=-5 \, \sqrt {2} \arctan \left (\frac {1}{2} \, \sqrt {2} x\right ) + 6 \, \arctan \left (x\right ) + \log \left (x^{2} + 2\right ) - \frac {1}{2} \, \log \left (x^{2} + 1\right ) \]

[In]

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

[Out]

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

Sympy [A] (verification not implemented)

Time = 0.09 (sec) , antiderivative size = 36, normalized size of antiderivative = 1.00 \[ \int \frac {2-4 x^2+x^3}{\left (1+x^2\right ) \left (2+x^2\right )} \, dx=- \frac {\log {\left (x^{2} + 1 \right )}}{2} + \log {\left (x^{2} + 2 \right )} + 6 \operatorname {atan}{\left (x \right )} - 5 \sqrt {2} \operatorname {atan}{\left (\frac {\sqrt {2} x}{2} \right )} \]

[In]

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

[Out]

-log(x**2 + 1)/2 + log(x**2 + 2) + 6*atan(x) - 5*sqrt(2)*atan(sqrt(2)*x/2)

Maxima [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 31, normalized size of antiderivative = 0.86 \[ \int \frac {2-4 x^2+x^3}{\left (1+x^2\right ) \left (2+x^2\right )} \, dx=-5 \, \sqrt {2} \arctan \left (\frac {1}{2} \, \sqrt {2} x\right ) + 6 \, \arctan \left (x\right ) + \log \left (x^{2} + 2\right ) - \frac {1}{2} \, \log \left (x^{2} + 1\right ) \]

[In]

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

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 31, normalized size of antiderivative = 0.86 \[ \int \frac {2-4 x^2+x^3}{\left (1+x^2\right ) \left (2+x^2\right )} \, dx=-5 \, \sqrt {2} \arctan \left (\frac {1}{2} \, \sqrt {2} x\right ) + 6 \, \arctan \left (x\right ) + \log \left (x^{2} + 2\right ) - \frac {1}{2} \, \log \left (x^{2} + 1\right ) \]

[In]

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

[Out]

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

Mupad [B] (verification not implemented)

Time = 0.06 (sec) , antiderivative size = 56, normalized size of antiderivative = 1.56 \[ \int \frac {2-4 x^2+x^3}{\left (1+x^2\right ) \left (2+x^2\right )} \, dx=\ln \left (x-\mathrm {i}\right )\,\left (-\frac {1}{2}-3{}\mathrm {i}\right )+\ln \left (x+1{}\mathrm {i}\right )\,\left (-\frac {1}{2}+3{}\mathrm {i}\right )+\ln \left (x-\sqrt {2}\,1{}\mathrm {i}\right )\,\left (1+\frac {\sqrt {2}\,5{}\mathrm {i}}{2}\right )-\ln \left (x+\sqrt {2}\,1{}\mathrm {i}\right )\,\left (-1+\frac {\sqrt {2}\,5{}\mathrm {i}}{2}\right ) \]

[In]

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

[Out]

log(x - 2^(1/2)*1i)*((2^(1/2)*5i)/2 + 1) - log(x + 1i)*(1/2 - 3i) - log(x - 1i)*(1/2 + 3i) - log(x + 2^(1/2)*1
i)*((2^(1/2)*5i)/2 - 1)