\(\int e^{-4-x} (-9 e^2+e^{2 x}-4 e^{x+x^2} x+3 e^{1+x^2} (-2+4 x)+e^{2 x^2} (-1+4 x)) \, dx\) [8982]

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

Optimal result

Integrand size = 56, antiderivative size = 26 \[ \int e^{-4-x} \left (-9 e^2+e^{2 x}-4 e^{x+x^2} x+3 e^{1+x^2} (-2+4 x)+e^{2 x^2} (-1+4 x)\right ) \, dx=2+e^{-4-x} \left (3 e-e^x+e^{x^2}\right )^2 \]

[Out]

2+(exp(x^2)+exp(ln(3)+1)-exp(x))^2/exp(4+x)

Rubi [A] (verified)

Time = 0.40 (sec) , antiderivative size = 48, normalized size of antiderivative = 1.85, number of steps used = 14, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {6873, 6874, 2225, 2268, 2266, 2235, 2240, 2272} \[ \int e^{-4-x} \left (-9 e^2+e^{2 x}-4 e^{x+x^2} x+3 e^{1+x^2} (-2+4 x)+e^{2 x^2} (-1+4 x)\right ) \, dx=-2 e^{x^2-4}+6 e^{x^2-x-3}+e^{2 x^2-x-4}+9 e^{-x-2}+e^{x-4} \]

[In]

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

[Out]

9*E^(-2 - x) + E^(-4 + x) - 2*E^(-4 + x^2) + 6*E^(-3 - x + x^2) + E^(-4 - x + 2*x^2)

Rule 2225

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 2235

Int[(F_)^((a_.) + (b_.)*((c_.) + (d_.)*(x_))^2), x_Symbol] :> Simp[F^a*Sqrt[Pi]*(Erfi[(c + d*x)*Rt[b*Log[F], 2
]]/(2*d*Rt[b*Log[F], 2])), x] /; FreeQ[{F, a, b, c, d}, x] && PosQ[b]

Rule 2240

Int[(F_)^((a_.) + (b_.)*((c_.) + (d_.)*(x_))^(n_))*((e_.) + (f_.)*(x_))^(m_.), x_Symbol] :> Simp[(e + f*x)^n*(
F^(a + b*(c + d*x)^n)/(b*f*n*(c + d*x)^n*Log[F])), x] /; FreeQ[{F, a, b, c, d, e, f, n}, x] && EqQ[m, n - 1] &
& EqQ[d*e - c*f, 0]

Rule 2266

Int[(F_)^((a_.) + (b_.)*(x_) + (c_.)*(x_)^2), x_Symbol] :> Dist[F^(a - b^2/(4*c)), Int[F^((b + 2*c*x)^2/(4*c))
, x], x] /; FreeQ[{F, a, b, c}, x]

Rule 2268

Int[(F_)^((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)*((d_.) + (e_.)*(x_)), x_Symbol] :> Simp[e*(F^(a + b*x + c*x^2)/(2
*c*Log[F])), x] /; FreeQ[{F, a, b, c, d, e}, x] && EqQ[b*e - 2*c*d, 0]

Rule 2272

Int[(F_)^((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)*((d_.) + (e_.)*(x_)), x_Symbol] :> Simp[e*(F^(a + b*x + c*x^2)/(2
*c*Log[F])), x] - Dist[(b*e - 2*c*d)/(2*c), Int[F^(a + b*x + c*x^2), x], x] /; FreeQ[{F, a, b, c, d, e}, x] &&
 NeQ[b*e - 2*c*d, 0]

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 e^{-4-x} \left (3 e-e^x+e^{x^2}\right ) \left (-3 e-e^x-e^{x^2}+4 e^{x^2} x\right ) \, dx \\ & = \int \left (-9 e^{-2-x}+e^{-4+x}+e^{-4-x+2 x^2} (-1+4 x)+2 e^{-4-x+x^2} \left (-3 e+6 e x-2 e^x x\right )\right ) \, dx \\ & = 2 \int e^{-4-x+x^2} \left (-3 e+6 e x-2 e^x x\right ) \, dx-9 \int e^{-2-x} \, dx+\int e^{-4+x} \, dx+\int e^{-4-x+2 x^2} (-1+4 x) \, dx \\ & = 9 e^{-2-x}+e^{-4+x}+e^{-4-x+2 x^2}+2 \int \left (-3 e^{-3-x+x^2}-2 e^{-4+x^2} x+6 e^{-3-x+x^2} x\right ) \, dx \\ & = 9 e^{-2-x}+e^{-4+x}+e^{-4-x+2 x^2}-4 \int e^{-4+x^2} x \, dx-6 \int e^{-3-x+x^2} \, dx+12 \int e^{-3-x+x^2} x \, dx \\ & = 9 e^{-2-x}+e^{-4+x}-2 e^{-4+x^2}+6 e^{-3-x+x^2}+e^{-4-x+2 x^2}+6 \int e^{-3-x+x^2} \, dx-\frac {6 \int e^{\frac {1}{4} (-1+2 x)^2} \, dx}{e^{13/4}} \\ & = 9 e^{-2-x}+e^{-4+x}-2 e^{-4+x^2}+6 e^{-3-x+x^2}+e^{-4-x+2 x^2}-\frac {3 \sqrt {\pi } \text {erfi}\left (\frac {1}{2} (-1+2 x)\right )}{e^{13/4}}+\frac {6 \int e^{\frac {1}{4} (-1+2 x)^2} \, dx}{e^{13/4}} \\ & = 9 e^{-2-x}+e^{-4+x}-2 e^{-4+x^2}+6 e^{-3-x+x^2}+e^{-4-x+2 x^2} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.47 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.69 \[ \int e^{-4-x} \left (-9 e^2+e^{2 x}-4 e^{x+x^2} x+3 e^{1+x^2} (-2+4 x)+e^{2 x^2} (-1+4 x)\right ) \, dx=e^{-4-x} \left (9 e^2+e^{2 x}+e^{2 x^2}+6 e^{1+x^2}-2 e^{x+x^2}\right ) \]

[In]

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

[Out]

E^(-4 - x)*(9*E^2 + E^(2*x) + E^(2*x^2) + 6*E^(1 + x^2) - 2*E^(x + x^2))

Maple [A] (verified)

Time = 0.22 (sec) , antiderivative size = 45, normalized size of antiderivative = 1.73

method result size
risch \({\mathrm e}^{x -4}+9 \,{\mathrm e}^{-2-x}+{\mathrm e}^{2 x^{2}-x -4}+2 \left (-{\mathrm e}^{x}+3 \,{\mathrm e}\right ) {\mathrm e}^{x^{2}-x -4}\) \(45\)
parallelrisch \(\left (9 \,{\mathrm e}^{2}+2 \,{\mathrm e}^{x^{2}} {\mathrm e}^{\ln \left (3\right )+1}+{\mathrm e}^{2 x}-2 \,{\mathrm e}^{x} {\mathrm e}^{x^{2}}+{\mathrm e}^{2 x^{2}}\right ) {\mathrm e}^{-4-x}\) \(45\)
norman \(\left ({\mathrm e}^{-4} {\mathrm e}^{2 x}+{\mathrm e}^{-4} {\mathrm e}^{2 x^{2}}+9 \,{\mathrm e}^{-4} {\mathrm e}^{2}+6 \,{\mathrm e}^{-4} {\mathrm e} \,{\mathrm e}^{x^{2}}-2 \,{\mathrm e}^{x} {\mathrm e}^{-4} {\mathrm e}^{x^{2}}\right ) {\mathrm e}^{-x}\) \(61\)
parts \({\mathrm e}^{-4} {\mathrm e}^{x}+\frac {i {\mathrm e}^{-4} \sqrt {\pi }\, {\mathrm e}^{-\frac {1}{8}} \sqrt {2}\, \operatorname {erf}\left (i \sqrt {2}\, x -\frac {i \sqrt {2}}{4}\right )}{4}+4 \,{\mathrm e}^{-4} \left (\frac {{\mathrm e}^{2 x^{2}-x}}{4}-\frac {i \sqrt {\pi }\, {\mathrm e}^{-\frac {1}{8}} \sqrt {2}\, \operatorname {erf}\left (i \sqrt {2}\, x -\frac {i \sqrt {2}}{4}\right )}{16}\right )+9 \,{\mathrm e}^{2} {\mathrm e}^{-4-x}-2 \,{\mathrm e}^{-4} {\mathrm e}^{x^{2}}+2 \,{\mathrm e}^{\ln \left (3\right )+1} {\mathrm e}^{-4} {\mathrm e}^{x^{2}-x}\) \(127\)
default \({\mathrm e}^{-4} {\mathrm e}^{x}-2 \,{\mathrm e}^{-4} {\mathrm e}^{x^{2}}+9 \,{\mathrm e}^{-4} {\mathrm e}^{-x} {\mathrm e}^{2}+\frac {i {\mathrm e}^{-4} \sqrt {\pi }\, {\mathrm e}^{-\frac {1}{8}} \sqrt {2}\, \operatorname {erf}\left (i \sqrt {2}\, x -\frac {i \sqrt {2}}{4}\right )}{4}+4 \,{\mathrm e}^{-4} \left (\frac {{\mathrm e}^{2 x^{2}-x}}{4}-\frac {i \sqrt {\pi }\, {\mathrm e}^{-\frac {1}{8}} \sqrt {2}\, \operatorname {erf}\left (i \sqrt {2}\, x -\frac {i \sqrt {2}}{4}\right )}{16}\right )+3 i {\mathrm e}^{-4} {\mathrm e} \sqrt {\pi }\, {\mathrm e}^{-\frac {1}{4}} \operatorname {erf}\left (i x -\frac {1}{2} i\right )+12 \,{\mathrm e}^{-4} {\mathrm e} \left (\frac {{\mathrm e}^{x^{2}-x}}{2}-\frac {i \sqrt {\pi }\, {\mathrm e}^{-\frac {1}{4}} \operatorname {erf}\left (i x -\frac {1}{2} i\right )}{4}\right )\) \(165\)

[In]

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

[Out]

exp(x-4)+9*exp(-2-x)+exp(2*x^2-x-4)+2*(-exp(x)+3*exp(1))*exp(x^2-x-4)

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 85 vs. \(2 (25) = 50\).

Time = 0.25 (sec) , antiderivative size = 85, normalized size of antiderivative = 3.27 \[ \int e^{-4-x} \left (-9 e^2+e^{2 x}-4 e^{x+x^2} x+3 e^{1+x^2} (-2+4 x)+e^{2 x^2} (-1+4 x)\right ) \, dx=\frac {1}{27} \, {\left (9 \, {\left (9 \, e^{4} - 2 \, e^{\left (x^{2} + x + 2\right )}\right )} e^{\left (2 \, x^{2} + 2 \, \log \left (3\right ) + 2\right )} + e^{\left (4 \, x^{2} + 4 \, \log \left (3\right ) + 4\right )} + 18 \, e^{\left (3 \, x^{2} + 3 \, \log \left (3\right ) + 5\right )} + 81 \, e^{\left (2 \, x^{2} + 2 \, x + 4\right )}\right )} e^{\left (-2 \, x^{2} - x - \log \left (3\right ) - 8\right )} \]

[In]

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

[Out]

1/27*(9*(9*e^4 - 2*e^(x^2 + x + 2))*e^(2*x^2 + 2*log(3) + 2) + e^(4*x^2 + 4*log(3) + 4) + 18*e^(3*x^2 + 3*log(
3) + 5) + 81*e^(2*x^2 + 2*x + 4))*e^(-2*x^2 - x - log(3) - 8)

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 63 vs. \(2 (22) = 44\).

Time = 0.14 (sec) , antiderivative size = 63, normalized size of antiderivative = 2.42 \[ \int e^{-4-x} \left (-9 e^2+e^{2 x}-4 e^{x+x^2} x+3 e^{1+x^2} (-2+4 x)+e^{2 x^2} (-1+4 x)\right ) \, dx=\frac {\left (\left (- 2 e^{4} e^{2 x} + 6 e^{5} e^{x}\right ) e^{x^{2}} + e^{4} e^{x} e^{2 x^{2}}\right ) e^{- 2 x}}{e^{8}} + \frac {e^{2} e^{x} + 9 e^{4} e^{- x}}{e^{6}} \]

[In]

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

[Out]

((-2*exp(4)*exp(2*x) + 6*exp(5)*exp(x))*exp(x**2) + exp(4)*exp(x)*exp(2*x**2))*exp(-8)*exp(-2*x) + (exp(2)*exp
(x) + 9*exp(4)*exp(-x))*exp(-6)

Maxima [C] (verification not implemented)

Result contains higher order function than in optimal. Order 4 vs. order 3.

Time = 0.31 (sec) , antiderivative size = 178, normalized size of antiderivative = 6.85 \[ \int e^{-4-x} \left (-9 e^2+e^{2 x}-4 e^{x+x^2} x+3 e^{1+x^2} (-2+4 x)+e^{2 x^2} (-1+4 x)\right ) \, dx=\frac {1}{4} i \, \sqrt {2} \sqrt {\pi } \operatorname {erf}\left (i \, \sqrt {2} x - \frac {1}{4} i \, \sqrt {2}\right ) e^{\left (-\frac {33}{8}\right )} + 3 i \, \sqrt {\pi } \operatorname {erf}\left (i \, x - \frac {1}{2} i\right ) e^{\left (-\frac {13}{4}\right )} + \frac {1}{4} \, \sqrt {2} {\left (\frac {\sqrt {2} \sqrt {\frac {1}{2}} \sqrt {\pi } {\left (4 \, x - 1\right )} {\left (\operatorname {erf}\left (\frac {1}{2} \, \sqrt {\frac {1}{2}} \sqrt {-{\left (4 \, x - 1\right )}^{2}}\right ) - 1\right )}}{\sqrt {-{\left (4 \, x - 1\right )}^{2}}} + 2 \, \sqrt {2} e^{\left (\frac {1}{8} \, {\left (4 \, x - 1\right )}^{2}\right )}\right )} e^{\left (-\frac {33}{8}\right )} + 3 \, {\left (\frac {\sqrt {\pi } {\left (2 \, x - 1\right )} {\left (\operatorname {erf}\left (\frac {1}{2} \, \sqrt {-{\left (2 \, x - 1\right )}^{2}}\right ) - 1\right )}}{\sqrt {-{\left (2 \, x - 1\right )}^{2}}} + 2 \, e^{\left (\frac {1}{4} \, {\left (2 \, x - 1\right )}^{2}\right )}\right )} e^{\left (-\frac {13}{4}\right )} - 2 \, e^{\left (x^{2} - 4\right )} + e^{\left (x - 4\right )} + 9 \, e^{\left (-x - 2\right )} \]

[In]

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

[Out]

1/4*I*sqrt(2)*sqrt(pi)*erf(I*sqrt(2)*x - 1/4*I*sqrt(2))*e^(-33/8) + 3*I*sqrt(pi)*erf(I*x - 1/2*I)*e^(-13/4) +
1/4*sqrt(2)*(sqrt(2)*sqrt(1/2)*sqrt(pi)*(4*x - 1)*(erf(1/2*sqrt(1/2)*sqrt(-(4*x - 1)^2)) - 1)/sqrt(-(4*x - 1)^
2) + 2*sqrt(2)*e^(1/8*(4*x - 1)^2))*e^(-33/8) + 3*(sqrt(pi)*(2*x - 1)*(erf(1/2*sqrt(-(2*x - 1)^2)) - 1)/sqrt(-
(2*x - 1)^2) + 2*e^(1/4*(2*x - 1)^2))*e^(-13/4) - 2*e^(x^2 - 4) + e^(x - 4) + 9*e^(-x - 2)

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.77 \[ \int e^{-4-x} \left (-9 e^2+e^{2 x}-4 e^{x+x^2} x+3 e^{1+x^2} (-2+4 x)+e^{2 x^2} (-1+4 x)\right ) \, dx={\left (e^{\left (2 \, x^{2} - x + 5\right )} + 6 \, e^{\left (x^{2} - x + 6\right )} - 2 \, e^{\left (x^{2} + 5\right )} + e^{\left (x + 5\right )} + 9 \, e^{\left (-x + 7\right )}\right )} e^{\left (-9\right )} \]

[In]

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

[Out]

(e^(2*x^2 - x + 5) + 6*e^(x^2 - x + 6) - 2*e^(x^2 + 5) + e^(x + 5) + 9*e^(-x + 7))*e^(-9)

Mupad [B] (verification not implemented)

Time = 12.31 (sec) , antiderivative size = 47, normalized size of antiderivative = 1.81 \[ \int e^{-4-x} \left (-9 e^2+e^{2 x}-4 e^{x+x^2} x+3 e^{1+x^2} (-2+4 x)+e^{2 x^2} (-1+4 x)\right ) \, dx=9\,{\mathrm {e}}^{-x}\,{\mathrm {e}}^{-2}-2\,{\mathrm {e}}^{x^2}\,{\mathrm {e}}^{-4}+{\mathrm {e}}^{-4}\,{\mathrm {e}}^x+6\,{\mathrm {e}}^{-x}\,{\mathrm {e}}^{x^2}\,{\mathrm {e}}^{-3}+{\mathrm {e}}^{-x}\,{\mathrm {e}}^{-4}\,{\mathrm {e}}^{2\,x^2} \]

[In]

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

[Out]

9*exp(-x)*exp(-2) - 2*exp(x^2)*exp(-4) + exp(-4)*exp(x) + 6*exp(-x)*exp(x^2)*exp(-3) + exp(-x)*exp(-4)*exp(2*x
^2)