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

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

[Out]

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

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 30, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 1, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.034, Rules used = {2099} \[ \int \frac {1+4 x-2 x^2+x^4}{1-x-x^2+x^3} \, dx=\frac {x^2}{2}+x+\frac {2}{1-x}+\log (1-x)-\log (x+1) \]

[In]

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

[Out]

2/(1 - x) + x + x^2/2 + Log[1 - x] - Log[1 + x]

Rule 2099

Int[(P_)^(p_)*(Q_)^(q_.), x_Symbol] :> With[{PP = Factor[P]}, Int[ExpandIntegrand[PP^p*Q^q, x], x] /;  !SumQ[N
onfreeFactors[PP, x]]] /; FreeQ[q, x] && PolyQ[P, x] && PolyQ[Q, x] && IntegerQ[p] && NeQ[P, x]

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

Mathematica [A] (verified)

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

[In]

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

[Out]

-2/(-1 + x) + (1 + x)^2/2 + Log[1 - x] - Log[1 + x]

Maple [A] (verified)

Time = 0.05 (sec) , antiderivative size = 25, normalized size of antiderivative = 0.83

method result size
default \(\frac {x^{2}}{2}+x -\ln \left (x +1\right )+\ln \left (x -1\right )-\frac {2}{x -1}\) \(25\)
risch \(\frac {x^{2}}{2}+x -\ln \left (x +1\right )+\ln \left (x -1\right )-\frac {2}{x -1}\) \(25\)
norman \(\frac {\frac {1}{2} x^{2}+\frac {1}{2} x^{3}-3}{x -1}-\ln \left (x +1\right )+\ln \left (x -1\right )\) \(30\)
parallelrisch \(\frac {x^{3}+2 \ln \left (x -1\right ) x -2 \ln \left (x +1\right ) x +x^{2}-6-2 \ln \left (x -1\right )+2 \ln \left (x +1\right )}{2 x -2}\) \(42\)

[In]

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

[Out]

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

Fricas [A] (verification not implemented)

none

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

[In]

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

[Out]

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

Sympy [A] (verification not implemented)

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

[In]

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

[Out]

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

Maxima [A] (verification not implemented)

none

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

[In]

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

[Out]

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

Giac [A] (verification not implemented)

none

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

[In]

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

[Out]

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

Mupad [B] (verification not implemented)

Time = 9.44 (sec) , antiderivative size = 22, normalized size of antiderivative = 0.73 \[ \int \frac {1+4 x-2 x^2+x^4}{1-x-x^2+x^3} \, dx=x-\frac {2}{x-1}+\frac {x^2}{2}+\mathrm {atan}\left (x\,1{}\mathrm {i}\right )\,2{}\mathrm {i} \]

[In]

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

[Out]

x + atan(x*1i)*2i - 2/(x - 1) + x^2/2