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

   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 = 24, antiderivative size = 24 \[ \int \frac {-1+x+4 x^3}{(-1+x) x^2 \left (1+x^2\right )} \, dx=-\frac {1}{x}+\arctan (x)+2 \log (1-x)-\log \left (1+x^2\right ) \]

[Out]

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

Rubi [A] (verified)

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

[In]

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

[Out]

-x^(-1) + ArcTan[x] + 2*Log[1 - x] - Log[1 + 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 {2}{-1+x}+\frac {1}{x^2}+\frac {1-2 x}{1+x^2}\right ) \, dx \\ & = -\frac {1}{x}+2 \log (1-x)+\int \frac {1-2 x}{1+x^2} \, dx \\ & = -\frac {1}{x}+2 \log (1-x)-2 \int \frac {x}{1+x^2} \, dx+\int \frac {1}{1+x^2} \, dx \\ & = -\frac {1}{x}+\tan ^{-1}(x)+2 \log (1-x)-\log \left (1+x^2\right ) \\ \end{align*}

Mathematica [A] (verified)

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

[In]

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

[Out]

-x^(-1) + ArcTan[x] + 2*Log[1 - x] - Log[1 + x^2]

Maple [A] (verified)

Time = 0.83 (sec) , antiderivative size = 23, normalized size of antiderivative = 0.96

method result size
default \(-\ln \left (x^{2}+1\right )+\arctan \left (x \right )-\frac {1}{x}+2 \ln \left (x -1\right )\) \(23\)
risch \(-\ln \left (x^{2}+1\right )+\arctan \left (x \right )-\frac {1}{x}+2 \ln \left (x -1\right )\) \(23\)
parallelrisch \(\frac {-i \ln \left (x -i\right ) x +i \ln \left (x +i\right ) x +4 \ln \left (x -1\right ) x -2 \ln \left (x -i\right ) x -2 \ln \left (x +i\right ) x -2}{2 x}\) \(49\)

[In]

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

[Out]

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

Fricas [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 26, normalized size of antiderivative = 1.08 \[ \int \frac {-1+x+4 x^3}{(-1+x) x^2 \left (1+x^2\right )} \, dx=\frac {x \arctan \left (x\right ) - x \log \left (x^{2} + 1\right ) + 2 \, x \log \left (x - 1\right ) - 1}{x} \]

[In]

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

[Out]

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

Sympy [A] (verification not implemented)

Time = 0.07 (sec) , antiderivative size = 19, normalized size of antiderivative = 0.79 \[ \int \frac {-1+x+4 x^3}{(-1+x) x^2 \left (1+x^2\right )} \, dx=2 \log {\left (x - 1 \right )} - \log {\left (x^{2} + 1 \right )} + \operatorname {atan}{\left (x \right )} - \frac {1}{x} \]

[In]

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

[Out]

2*log(x - 1) - log(x**2 + 1) + atan(x) - 1/x

Maxima [A] (verification not implemented)

none

Time = 0.36 (sec) , antiderivative size = 22, normalized size of antiderivative = 0.92 \[ \int \frac {-1+x+4 x^3}{(-1+x) x^2 \left (1+x^2\right )} \, dx=-\frac {1}{x} + \arctan \left (x\right ) - \log \left (x^{2} + 1\right ) + 2 \, \log \left (x - 1\right ) \]

[In]

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

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 23, normalized size of antiderivative = 0.96 \[ \int \frac {-1+x+4 x^3}{(-1+x) x^2 \left (1+x^2\right )} \, dx=-\frac {1}{x} + \arctan \left (x\right ) - \log \left (x^{2} + 1\right ) + 2 \, \log \left ({\left | x - 1 \right |}\right ) \]

[In]

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

[Out]

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

Mupad [B] (verification not implemented)

Time = 9.21 (sec) , antiderivative size = 30, normalized size of antiderivative = 1.25 \[ \int \frac {-1+x+4 x^3}{(-1+x) x^2 \left (1+x^2\right )} \, dx=2\,\ln \left (x-1\right )-\frac {1}{x}+\ln \left (x-\mathrm {i}\right )\,\left (-1-\frac {1}{2}{}\mathrm {i}\right )+\ln \left (x+1{}\mathrm {i}\right )\,\left (-1+\frac {1}{2}{}\mathrm {i}\right ) \]

[In]

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

[Out]

2*log(x - 1) - log(x - 1i)*(1 + 1i/2) - log(x + 1i)*(1 - 1i/2) - 1/x