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

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

Optimal result

Integrand size = 93, antiderivative size = 34 \[ \int \frac {e^{\frac {1}{2} \left (-x+2 x^2-x^3-e^x \left (1-2 x+x^2\right )\right )} \left (-2+5 e^{\frac {1}{2} \left (x-2 x^2+x^3+e^x \left (1-2 x+x^2\right )\right )}-x+4 x^2-3 x^3+e^x \left (x-x^3\right )\right )}{x^2} \, dx=e^4-\frac {5}{x}-\frac {-2 e^{-\frac {1}{2} (-1+x)^2 \left (e^x+x\right )}+x}{x} \]

[Out]

exp(4)-(x-2/exp((-1+x)^2*(1/2*exp(x)+1/2*x)))/x-5/x

Rubi [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(82\) vs. \(2(34)=68\).

Time = 11.42 (sec) , antiderivative size = 82, normalized size of antiderivative = 2.41, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.032, Rules used = {6873, 6874, 2326} \[ \int \frac {e^{\frac {1}{2} \left (-x+2 x^2-x^3-e^x \left (1-2 x+x^2\right )\right )} \left (-2+5 e^{\frac {1}{2} \left (x-2 x^2+x^3+e^x \left (1-2 x+x^2\right )\right )}-x+4 x^2-3 x^3+e^x \left (x-x^3\right )\right )}{x^2} \, dx=\frac {2 e^{-\frac {1}{2} (1-x)^2 \left (x+e^x\right )} \left (e^x x^3+3 x^3-4 x^2-e^x x+x\right )}{x^2 \left (\left (e^x+1\right ) (1-x)^2-2 (1-x) \left (x+e^x\right )\right )}-\frac {5}{x} \]

[In]

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

[Out]

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

Rule 2326

Int[(y_.)*(F_)^(u_)*((v_) + (w_)), x_Symbol] :> With[{z = v*(y/(Log[F]*D[u, x]))}, Simp[F^u*z, x] /; EqQ[D[z,
x], w*y]] /; FreeQ[F, x]

Rule 6873

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

Rule 6874

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

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

Mathematica [A] (verified)

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

[In]

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

[Out]

(-5 + 2/E^(((-1 + x)^2*(E^x + x))/2))/x

Maple [A] (verified)

Time = 0.13 (sec) , antiderivative size = 24, normalized size of antiderivative = 0.71

method result size
risch \(-\frac {5}{x}+\frac {2 \,{\mathrm e}^{-\frac {\left (-1+x \right )^{2} \left ({\mathrm e}^{x}+x \right )}{2}}}{x}\) \(24\)
norman \(\frac {\left (2-5 \,{\mathrm e}^{\frac {\left (x^{2}-2 x +1\right ) {\mathrm e}^{x}}{2}+\frac {x^{3}}{2}-x^{2}+\frac {x}{2}}\right ) {\mathrm e}^{-\frac {\left (x^{2}-2 x +1\right ) {\mathrm e}^{x}}{2}-\frac {x^{3}}{2}+x^{2}-\frac {x}{2}}}{x}\) \(65\)
parallelrisch \(\frac {\left (4-10 \,{\mathrm e}^{\frac {\left (x^{2}-2 x +1\right ) {\mathrm e}^{x}}{2}+\frac {x^{3}}{2}-x^{2}+\frac {x}{2}}\right ) {\mathrm e}^{-\frac {\left (x^{2}-2 x +1\right ) {\mathrm e}^{x}}{2}-\frac {x^{3}}{2}+x^{2}-\frac {x}{2}}}{2 x}\) \(66\)

[In]

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

[Out]

-5/x+2/x*exp(-1/2*(-1+x)^2*(exp(x)+x))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 61 vs. \(2 (29) = 58\).

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

[In]

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

[Out]

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

Sympy [A] (verification not implemented)

Time = 0.10 (sec) , antiderivative size = 32, normalized size of antiderivative = 0.94 \[ \int \frac {e^{\frac {1}{2} \left (-x+2 x^2-x^3-e^x \left (1-2 x+x^2\right )\right )} \left (-2+5 e^{\frac {1}{2} \left (x-2 x^2+x^3+e^x \left (1-2 x+x^2\right )\right )}-x+4 x^2-3 x^3+e^x \left (x-x^3\right )\right )}{x^2} \, dx=\frac {2 e^{- \frac {x^{3}}{2} + x^{2} - \frac {x}{2} - \left (\frac {x^{2}}{2} - x + \frac {1}{2}\right ) e^{x}}}{x} - \frac {5}{x} \]

[In]

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

[Out]

2*exp(-x**3/2 + x**2 - x/2 - (x**2/2 - x + 1/2)*exp(x))/x - 5/x

Maxima [F]

\[ \int \frac {e^{\frac {1}{2} \left (-x+2 x^2-x^3-e^x \left (1-2 x+x^2\right )\right )} \left (-2+5 e^{\frac {1}{2} \left (x-2 x^2+x^3+e^x \left (1-2 x+x^2\right )\right )}-x+4 x^2-3 x^3+e^x \left (x-x^3\right )\right )}{x^2} \, dx=\int { -\frac {{\left (3 \, x^{3} - 4 \, x^{2} + {\left (x^{3} - x\right )} e^{x} + x - 5 \, e^{\left (\frac {1}{2} \, x^{3} - x^{2} + \frac {1}{2} \, {\left (x^{2} - 2 \, x + 1\right )} e^{x} + \frac {1}{2} \, x\right )} + 2\right )} e^{\left (-\frac {1}{2} \, x^{3} + x^{2} - \frac {1}{2} \, {\left (x^{2} - 2 \, x + 1\right )} e^{x} - \frac {1}{2} \, x\right )}}{x^{2}} \,d x } \]

[In]

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

[Out]

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

Giac [F]

\[ \int \frac {e^{\frac {1}{2} \left (-x+2 x^2-x^3-e^x \left (1-2 x+x^2\right )\right )} \left (-2+5 e^{\frac {1}{2} \left (x-2 x^2+x^3+e^x \left (1-2 x+x^2\right )\right )}-x+4 x^2-3 x^3+e^x \left (x-x^3\right )\right )}{x^2} \, dx=\int { -\frac {{\left (3 \, x^{3} - 4 \, x^{2} + {\left (x^{3} - x\right )} e^{x} + x - 5 \, e^{\left (\frac {1}{2} \, x^{3} - x^{2} + \frac {1}{2} \, {\left (x^{2} - 2 \, x + 1\right )} e^{x} + \frac {1}{2} \, x\right )} + 2\right )} e^{\left (-\frac {1}{2} \, x^{3} + x^{2} - \frac {1}{2} \, {\left (x^{2} - 2 \, x + 1\right )} e^{x} - \frac {1}{2} \, x\right )}}{x^{2}} \,d x } \]

[In]

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

[Out]

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

Mupad [B] (verification not implemented)

Time = 0.42 (sec) , antiderivative size = 39, normalized size of antiderivative = 1.15 \[ \int \frac {e^{\frac {1}{2} \left (-x+2 x^2-x^3-e^x \left (1-2 x+x^2\right )\right )} \left (-2+5 e^{\frac {1}{2} \left (x-2 x^2+x^3+e^x \left (1-2 x+x^2\right )\right )}-x+4 x^2-3 x^3+e^x \left (x-x^3\right )\right )}{x^2} \, dx=\frac {2\,{\mathrm {e}}^{x\,{\mathrm {e}}^x-\frac {{\mathrm {e}}^x}{2}-\frac {x^2\,{\mathrm {e}}^x}{2}-\frac {x}{2}+x^2-\frac {x^3}{2}}}{x}-\frac {5}{x} \]

[In]

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

[Out]

(2*exp(x*exp(x) - exp(x)/2 - (x^2*exp(x))/2 - x/2 + x^2 - x^3/2))/x - 5/x