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

Optimal. Leaf size=30 \[ \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]
time = 0.02, antiderivative size = 30, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 1, integrand size = 29, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.034, Rules used = {2099} \begin {gather*} \frac {x^2}{2}+x+\frac {2}{1-x}+\log (1-x)-\log (x+1) \end {gather*}

Antiderivative was successfully verified.

[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*} \int \frac {1+4 x-2 x^2+x^4}{1-x-x^2+x^3} \, dx &=\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]
time = 0.01, size = 29, normalized size = 0.97 \begin {gather*} -\frac {2}{-1+x}+\frac {1}{2} (1+x)^2+\log (1-x)-\log (1+x) \end {gather*}

Antiderivative was successfully verified.

[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]

________________________________________________________________________________________

Mathics [A]
time = 1.83, size = 32, normalized size = 1.07 \begin {gather*} \frac {-4+\left (-1+x\right ) \left (2 x+x^2-2 \text {Log}\left [1+x\right ]+2 \text {Log}\left [-1+x\right ]\right )}{-2+2 x} \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

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

________________________________________________________________________________________

Maple [A]
time = 0.02, size = 25, normalized size = 0.83

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

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Maxima [A]
time = 0.27, size = 24, normalized size = 0.80 \begin {gather*} \frac {1}{2} \, x^{2} + x - \frac {2}{x - 1} - \log \left (x + 1\right ) + \log \left (x - 1\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[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)

________________________________________________________________________________________

Fricas [A]
time = 0.34, size = 36, normalized size = 1.20 \begin {gather*} \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 )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[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]
time = 0.05, size = 20, normalized size = 0.67 \begin {gather*} \frac {x^{2}}{2} + x + \log {\left (x - 1 \right )} - \log {\left (x + 1 \right )} - \frac {2}{x - 1} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[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)

________________________________________________________________________________________

Giac [A]
time = 0.00, size = 27, normalized size = 0.90 \begin {gather*} \frac {1}{2} x^{2}+x-\frac {2}{x-1}-\ln \left |x+1\right |+\ln \left |x-1\right | \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Mupad [B]
time = 0.05, size = 22, normalized size = 0.73 \begin {gather*} x-\frac {2}{x-1}+\frac {x^2}{2}+\mathrm {atan}\left (x\,1{}\mathrm {i}\right )\,2{}\mathrm {i} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[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

________________________________________________________________________________________