3.104.30 \(\int \frac {2+x+x^2+e^x (-x+x^2)}{-x+x^2} \, dx\)

Optimal. Leaf size=20 \[ -8+e^x+x+\log \left (\left (1-\frac {1}{x}\right )^4 x^2\right ) \]

________________________________________________________________________________________

Rubi [A]  time = 0.20, antiderivative size = 17, normalized size of antiderivative = 0.85, number of steps used = 6, number of rules used = 4, integrand size = 27, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.148, Rules used = {1593, 6742, 2194, 893} \begin {gather*} x+e^x+4 \log (1-x)-2 \log (x) \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(2 + x + x^2 + E^x*(-x + x^2))/(-x + x^2),x]

[Out]

E^x + x + 4*Log[1 - x] - 2*Log[x]

Rule 893

Int[((d_.) + (e_.)*(x_))^(m_)*((f_.) + (g_.)*(x_))^(n_)*((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :
> Int[ExpandIntegrand[(d + e*x)^m*(f + g*x)^n*(a + b*x + c*x^2)^p, x], x] /; FreeQ[{a, b, c, d, e, f, g}, x] &
& NeQ[e*f - d*g, 0] && NeQ[b^2 - 4*a*c, 0] && NeQ[c*d^2 - b*d*e + a*e^2, 0] && IntegerQ[p] && ((EqQ[p, 1] && I
ntegersQ[m, n]) || (ILtQ[m, 0] && ILtQ[n, 0]))

Rule 1593

Int[(u_.)*((a_.)*(x_)^(p_.) + (b_.)*(x_)^(q_.))^(n_.), x_Symbol] :> Int[u*x^(n*p)*(a + b*x^(q - p))^n, x] /; F
reeQ[{a, b, p, q}, x] && IntegerQ[n] && PosQ[q - p]

Rule 2194

Int[((F_)^((c_.)*((a_.) + (b_.)*(x_))))^(n_.), x_Symbol] :> Simp[(F^(c*(a + b*x)))^n/(b*c*n*Log[F]), x] /; Fre
eQ[{F, a, b, c, n}, x]

Rule 6742

Int[u_, x_Symbol] :> With[{v = ExpandIntegrand[u, x]}, Int[v, x] /; SumQ[v]]

Rubi steps

\begin {gather*} \begin {aligned} \text {integral} &=\int \frac {2+x+x^2+e^x \left (-x+x^2\right )}{(-1+x) x} \, dx\\ &=\int \left (e^x+\frac {2+x+x^2}{(-1+x) x}\right ) \, dx\\ &=\int e^x \, dx+\int \frac {2+x+x^2}{(-1+x) x} \, dx\\ &=e^x+\int \left (1+\frac {4}{-1+x}-\frac {2}{x}\right ) \, dx\\ &=e^x+x+4 \log (1-x)-2 \log (x)\\ \end {aligned} \end {gather*}

________________________________________________________________________________________

Mathematica [A]  time = 0.05, size = 17, normalized size = 0.85 \begin {gather*} e^x+x+4 \log (1-x)-2 \log (x) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(2 + x + x^2 + E^x*(-x + x^2))/(-x + x^2),x]

[Out]

E^x + x + 4*Log[1 - x] - 2*Log[x]

________________________________________________________________________________________

fricas [A]  time = 0.65, size = 14, normalized size = 0.70 \begin {gather*} x + e^{x} + 4 \, \log \left (x - 1\right ) - 2 \, \log \relax (x) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(((x^2-x)*exp(x)+x^2+x+2)/(x^2-x),x, algorithm="fricas")

[Out]

x + e^x + 4*log(x - 1) - 2*log(x)

________________________________________________________________________________________

giac [A]  time = 0.13, size = 14, normalized size = 0.70 \begin {gather*} x + e^{x} + 4 \, \log \left (x - 1\right ) - 2 \, \log \relax (x) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(((x^2-x)*exp(x)+x^2+x+2)/(x^2-x),x, algorithm="giac")

[Out]

x + e^x + 4*log(x - 1) - 2*log(x)

________________________________________________________________________________________

maple [A]  time = 0.10, size = 15, normalized size = 0.75




method result size



default \(4 \ln \left (x -1\right )+x +{\mathrm e}^{x}-2 \ln \relax (x )\) \(15\)
norman \(4 \ln \left (x -1\right )+x +{\mathrm e}^{x}-2 \ln \relax (x )\) \(15\)
risch \(4 \ln \left (x -1\right )+x +{\mathrm e}^{x}-2 \ln \relax (x )\) \(15\)



Verification of antiderivative is not currently implemented for this CAS.

[In]

int(((x^2-x)*exp(x)+x^2+x+2)/(x^2-x),x,method=_RETURNVERBOSE)

[Out]

4*ln(x-1)+x+exp(x)-2*ln(x)

________________________________________________________________________________________

maxima [F]  time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} e E_{1}\left (-x + 1\right ) + x + \frac {x e^{x}}{x - 1} + \int \frac {e^{x}}{x^{2} - 2 \, x + 1}\,{d x} + 4 \, \log \left (x - 1\right ) - 2 \, \log \relax (x) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(((x^2-x)*exp(x)+x^2+x+2)/(x^2-x),x, algorithm="maxima")

[Out]

e*exp_integral_e(1, -x + 1) + x + x*e^x/(x - 1) + integrate(e^x/(x^2 - 2*x + 1), x) + 4*log(x - 1) - 2*log(x)

________________________________________________________________________________________

mupad [B]  time = 6.19, size = 14, normalized size = 0.70 \begin {gather*} x+4\,\ln \left (x-1\right )+{\mathrm {e}}^x-2\,\ln \relax (x) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(-(x - exp(x)*(x - x^2) + x^2 + 2)/(x - x^2),x)

[Out]

x + 4*log(x - 1) + exp(x) - 2*log(x)

________________________________________________________________________________________

sympy [A]  time = 0.15, size = 15, normalized size = 0.75 \begin {gather*} x + e^{x} - 2 \log {\relax (x )} + 4 \log {\left (x - 1 \right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(((x**2-x)*exp(x)+x**2+x+2)/(x**2-x),x)

[Out]

x + exp(x) - 2*log(x) + 4*log(x - 1)

________________________________________________________________________________________