\(\int e^{2+3 x+x^2} (5+17 x+13 x^2+2 x^3+e^x (1+4 x+2 x^2)) \, dx\) [6310]

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

Optimal result

Integrand size = 40, antiderivative size = 18 \[ \int e^{2+3 x+x^2} \left (5+17 x+13 x^2+2 x^3+e^x \left (1+4 x+2 x^2\right )\right ) \, dx=e^{1+x+(1+x)^2} x \left (5+e^x+x\right ) \]

[Out]

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

Rubi [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(51\) vs. \(2(18)=36\).

Time = 0.29 (sec) , antiderivative size = 51, normalized size of antiderivative = 2.83, number of steps used = 24, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.150, Rules used = {6874, 2266, 2235, 2272, 2273, 2326} \[ \int e^{2+3 x+x^2} \left (5+17 x+13 x^2+2 x^3+e^x \left (1+4 x+2 x^2\right )\right ) \, dx=e^{x^2+3 x+2} x^2+5 e^{x^2+3 x+2} x+\frac {e^{x^2+4 x+2} \left (x^2+2 x\right )}{x+2} \]

[In]

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

[Out]

5*E^(2 + 3*x + x^2)*x + E^(2 + 3*x + x^2)*x^2 + (E^(2 + 4*x + x^2)*(2*x + x^2))/(2 + 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 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 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 2273

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

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 6874

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

Rubi steps \begin{align*} \text {integral}& = \int \left (5 e^{2+3 x+x^2}+17 e^{2+3 x+x^2} x+13 e^{2+3 x+x^2} x^2+2 e^{2+3 x+x^2} x^3+e^{2+4 x+x^2} \left (1+4 x+2 x^2\right )\right ) \, dx \\ & = 2 \int e^{2+3 x+x^2} x^3 \, dx+5 \int e^{2+3 x+x^2} \, dx+13 \int e^{2+3 x+x^2} x^2 \, dx+17 \int e^{2+3 x+x^2} x \, dx+\int e^{2+4 x+x^2} \left (1+4 x+2 x^2\right ) \, dx \\ & = \frac {17}{2} e^{2+3 x+x^2}+\frac {13}{2} e^{2+3 x+x^2} x+e^{2+3 x+x^2} x^2+\frac {e^{2+4 x+x^2} \left (2 x+x^2\right )}{2+x}-2 \int e^{2+3 x+x^2} x \, dx-3 \int e^{2+3 x+x^2} x^2 \, dx-\frac {13}{2} \int e^{2+3 x+x^2} \, dx-\frac {39}{2} \int e^{2+3 x+x^2} x \, dx-\frac {51}{2} \int e^{2+3 x+x^2} \, dx+\frac {5 \int e^{\frac {1}{4} (3+2 x)^2} \, dx}{\sqrt [4]{e}} \\ & = -\frac {9}{4} e^{2+3 x+x^2}+5 e^{2+3 x+x^2} x+e^{2+3 x+x^2} x^2+\frac {e^{2+4 x+x^2} \left (2 x+x^2\right )}{2+x}+\frac {5 \sqrt {\pi } \text {erfi}\left (\frac {1}{2} (3+2 x)\right )}{2 \sqrt [4]{e}}+\frac {3}{2} \int e^{2+3 x+x^2} \, dx+3 \int e^{2+3 x+x^2} \, dx+\frac {9}{2} \int e^{2+3 x+x^2} x \, dx+\frac {117}{4} \int e^{2+3 x+x^2} \, dx-\frac {13 \int e^{\frac {1}{4} (3+2 x)^2} \, dx}{2 \sqrt [4]{e}}-\frac {51 \int e^{\frac {1}{4} (3+2 x)^2} \, dx}{2 \sqrt [4]{e}} \\ & = 5 e^{2+3 x+x^2} x+e^{2+3 x+x^2} x^2+\frac {e^{2+4 x+x^2} \left (2 x+x^2\right )}{2+x}-\frac {27 \sqrt {\pi } \text {erfi}\left (\frac {1}{2} (3+2 x)\right )}{2 \sqrt [4]{e}}-\frac {27}{4} \int e^{2+3 x+x^2} \, dx+\frac {3 \int e^{\frac {1}{4} (3+2 x)^2} \, dx}{2 \sqrt [4]{e}}+\frac {3 \int e^{\frac {1}{4} (3+2 x)^2} \, dx}{\sqrt [4]{e}}+\frac {117 \int e^{\frac {1}{4} (3+2 x)^2} \, dx}{4 \sqrt [4]{e}} \\ & = 5 e^{2+3 x+x^2} x+e^{2+3 x+x^2} x^2+\frac {e^{2+4 x+x^2} \left (2 x+x^2\right )}{2+x}+\frac {27 \sqrt {\pi } \text {erfi}\left (\frac {1}{2} (3+2 x)\right )}{8 \sqrt [4]{e}}-\frac {27 \int e^{\frac {1}{4} (3+2 x)^2} \, dx}{4 \sqrt [4]{e}} \\ & = 5 e^{2+3 x+x^2} x+e^{2+3 x+x^2} x^2+\frac {e^{2+4 x+x^2} \left (2 x+x^2\right )}{2+x} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.42 (sec) , antiderivative size = 18, normalized size of antiderivative = 1.00 \[ \int e^{2+3 x+x^2} \left (5+17 x+13 x^2+2 x^3+e^x \left (1+4 x+2 x^2\right )\right ) \, dx=e^{2+3 x+x^2} x \left (5+e^x+x\right ) \]

[In]

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

[Out]

E^(2 + 3*x + x^2)*x*(5 + E^x + x)

Maple [A] (verified)

Time = 0.09 (sec) , antiderivative size = 21, normalized size of antiderivative = 1.17

method result size
risch \(\left (x^{2}+{\mathrm e}^{x} x +5 x \right ) {\mathrm e}^{\left (2+x \right ) \left (1+x \right )}\) \(21\)
norman \(x^{2} {\mathrm e}^{x^{2}+3 x +2}+{\mathrm e}^{x} x \,{\mathrm e}^{x^{2}+3 x +2}+5 x \,{\mathrm e}^{x^{2}+3 x +2}\) \(40\)
parallelrisch \(x^{2} {\mathrm e}^{x^{2}+3 x +2}+{\mathrm e}^{x} x \,{\mathrm e}^{x^{2}+3 x +2}+5 x \,{\mathrm e}^{x^{2}+3 x +2}\) \(40\)
default \(-\frac {i {\mathrm e}^{2} \sqrt {\pi }\, {\mathrm e}^{-4} \operatorname {erf}\left (i x +2 i\right )}{2}-\frac {5 i {\mathrm e}^{2} \sqrt {\pi }\, {\mathrm e}^{-\frac {9}{4}} \operatorname {erf}\left (i x +\frac {3}{2} i\right )}{2}+17 \,{\mathrm e}^{2} \left (\frac {{\mathrm e}^{x^{2}+3 x}}{2}+\frac {3 i \sqrt {\pi }\, {\mathrm e}^{-\frac {9}{4}} \operatorname {erf}\left (i x +\frac {3}{2} i\right )}{4}\right )+13 \,{\mathrm e}^{2} \left (\frac {x \,{\mathrm e}^{x^{2}+3 x}}{2}-\frac {3 \,{\mathrm e}^{x^{2}+3 x}}{4}-\frac {7 i \sqrt {\pi }\, {\mathrm e}^{-\frac {9}{4}} \operatorname {erf}\left (i x +\frac {3}{2} i\right )}{8}\right )+2 \,{\mathrm e}^{2} \left (\frac {x^{2} {\mathrm e}^{x^{2}+3 x}}{2}-\frac {3 x \,{\mathrm e}^{x^{2}+3 x}}{4}+\frac {5 \,{\mathrm e}^{x^{2}+3 x}}{8}+\frac {9 i \sqrt {\pi }\, {\mathrm e}^{-\frac {9}{4}} \operatorname {erf}\left (i x +\frac {3}{2} i\right )}{16}\right )+4 \,{\mathrm e}^{2} \left (\frac {{\mathrm e}^{x^{2}+4 x}}{2}+i \sqrt {\pi }\, {\mathrm e}^{-4} \operatorname {erf}\left (i x +2 i\right )\right )+2 \,{\mathrm e}^{2} \left (\frac {x \,{\mathrm e}^{x^{2}+4 x}}{2}-{\mathrm e}^{x^{2}+4 x}-\frac {7 i \sqrt {\pi }\, {\mathrm e}^{-4} \operatorname {erf}\left (i x +2 i\right )}{4}\right )\) \(239\)
parts \(-\frac {i {\mathrm e}^{2} \sqrt {\pi }\, {\mathrm e}^{-4} \operatorname {erf}\left (i x +2 i\right )}{2}-\frac {5 i {\mathrm e}^{2} \sqrt {\pi }\, {\mathrm e}^{-\frac {9}{4}} \operatorname {erf}\left (i x +\frac {3}{2} i\right )}{2}+17 \,{\mathrm e}^{2} \left (\frac {{\mathrm e}^{x^{2}+3 x}}{2}+\frac {3 i \sqrt {\pi }\, {\mathrm e}^{-\frac {9}{4}} \operatorname {erf}\left (i x +\frac {3}{2} i\right )}{4}\right )+13 \,{\mathrm e}^{2} \left (\frac {x \,{\mathrm e}^{x^{2}+3 x}}{2}-\frac {3 \,{\mathrm e}^{x^{2}+3 x}}{4}-\frac {7 i \sqrt {\pi }\, {\mathrm e}^{-\frac {9}{4}} \operatorname {erf}\left (i x +\frac {3}{2} i\right )}{8}\right )+2 \,{\mathrm e}^{2} \left (\frac {x^{2} {\mathrm e}^{x^{2}+3 x}}{2}-\frac {3 x \,{\mathrm e}^{x^{2}+3 x}}{4}+\frac {5 \,{\mathrm e}^{x^{2}+3 x}}{8}+\frac {9 i \sqrt {\pi }\, {\mathrm e}^{-\frac {9}{4}} \operatorname {erf}\left (i x +\frac {3}{2} i\right )}{16}\right )+4 \,{\mathrm e}^{2} \left (\frac {{\mathrm e}^{x^{2}+4 x}}{2}+i \sqrt {\pi }\, {\mathrm e}^{-4} \operatorname {erf}\left (i x +2 i\right )\right )+2 \,{\mathrm e}^{2} \left (\frac {x \,{\mathrm e}^{x^{2}+4 x}}{2}-{\mathrm e}^{x^{2}+4 x}-\frac {7 i \sqrt {\pi }\, {\mathrm e}^{-4} \operatorname {erf}\left (i x +2 i\right )}{4}\right )\) \(239\)

[In]

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

[Out]

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

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 21, normalized size of antiderivative = 1.17 \[ \int e^{2+3 x+x^2} \left (5+17 x+13 x^2+2 x^3+e^x \left (1+4 x+2 x^2\right )\right ) \, dx={\left (x^{2} + x e^{x} + 5 \, x\right )} e^{\left (x^{2} + 3 \, x + 2\right )} \]

[In]

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

[Out]

(x^2 + x*e^x + 5*x)*e^(x^2 + 3*x + 2)

Sympy [A] (verification not implemented)

Time = 0.10 (sec) , antiderivative size = 20, normalized size of antiderivative = 1.11 \[ \int e^{2+3 x+x^2} \left (5+17 x+13 x^2+2 x^3+e^x \left (1+4 x+2 x^2\right )\right ) \, dx=\left (x^{2} + x e^{x} + 5 x\right ) e^{x^{2} + 3 x + 2} \]

[In]

integrate(((2*x**2+4*x+1)*exp(x)+2*x**3+13*x**2+17*x+5)*exp(x**2+3*x+2),x)

[Out]

(x**2 + x*exp(x) + 5*x)*exp(x**2 + 3*x + 2)

Maxima [C] (verification not implemented)

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

Time = 0.28 (sec) , antiderivative size = 372, normalized size of antiderivative = 20.67 \[ \int e^{2+3 x+x^2} \left (5+17 x+13 x^2+2 x^3+e^x \left (1+4 x+2 x^2\right )\right ) \, dx=-\frac {5}{2} i \, \sqrt {\pi } \operatorname {erf}\left (i \, x + \frac {3}{2} i\right ) e^{\left (-\frac {1}{4}\right )} - \frac {1}{2} i \, \sqrt {\pi } \operatorname {erf}\left (i \, x + 2 i\right ) e^{\left (-2\right )} + \frac {1}{8} \, {\left (\frac {36 \, {\left (2 \, x + 3\right )}^{3} \Gamma \left (\frac {3}{2}, -\frac {1}{4} \, {\left (2 \, x + 3\right )}^{2}\right )}{\left (-{\left (2 \, x + 3\right )}^{2}\right )^{\frac {3}{2}}} - \frac {27 \, \sqrt {\pi } {\left (2 \, x + 3\right )} {\left (\operatorname {erf}\left (\frac {1}{2} \, \sqrt {-{\left (2 \, x + 3\right )}^{2}}\right ) - 1\right )}}{\sqrt {-{\left (2 \, x + 3\right )}^{2}}} + 54 \, e^{\left (\frac {1}{4} \, {\left (2 \, x + 3\right )}^{2}\right )} - 8 \, \Gamma \left (2, -\frac {1}{4} \, {\left (2 \, x + 3\right )}^{2}\right )\right )} e^{\left (-\frac {1}{4}\right )} - \frac {13}{8} \, {\left (\frac {4 \, {\left (2 \, x + 3\right )}^{3} \Gamma \left (\frac {3}{2}, -\frac {1}{4} \, {\left (2 \, x + 3\right )}^{2}\right )}{\left (-{\left (2 \, x + 3\right )}^{2}\right )^{\frac {3}{2}}} - \frac {9 \, \sqrt {\pi } {\left (2 \, x + 3\right )} {\left (\operatorname {erf}\left (\frac {1}{2} \, \sqrt {-{\left (2 \, x + 3\right )}^{2}}\right ) - 1\right )}}{\sqrt {-{\left (2 \, x + 3\right )}^{2}}} + 12 \, e^{\left (\frac {1}{4} \, {\left (2 \, x + 3\right )}^{2}\right )}\right )} e^{\left (-\frac {1}{4}\right )} - \frac {17}{4} \, {\left (\frac {3 \, \sqrt {\pi } {\left (2 \, x + 3\right )} {\left (\operatorname {erf}\left (\frac {1}{2} \, \sqrt {-{\left (2 \, x + 3\right )}^{2}}\right ) - 1\right )}}{\sqrt {-{\left (2 \, x + 3\right )}^{2}}} - 2 \, e^{\left (\frac {1}{4} \, {\left (2 \, x + 3\right )}^{2}\right )}\right )} e^{\left (-\frac {1}{4}\right )} - {\left (\frac {{\left (x + 2\right )}^{3} \Gamma \left (\frac {3}{2}, -{\left (x + 2\right )}^{2}\right )}{\left (-{\left (x + 2\right )}^{2}\right )^{\frac {3}{2}}} - \frac {4 \, \sqrt {\pi } {\left (x + 2\right )} {\left (\operatorname {erf}\left (\sqrt {-{\left (x + 2\right )}^{2}}\right ) - 1\right )}}{\sqrt {-{\left (x + 2\right )}^{2}}} + 4 \, e^{\left ({\left (x + 2\right )}^{2}\right )}\right )} e^{\left (-2\right )} - 2 \, {\left (\frac {2 \, \sqrt {\pi } {\left (x + 2\right )} {\left (\operatorname {erf}\left (\sqrt {-{\left (x + 2\right )}^{2}}\right ) - 1\right )}}{\sqrt {-{\left (x + 2\right )}^{2}}} - e^{\left ({\left (x + 2\right )}^{2}\right )}\right )} e^{\left (-2\right )} \]

[In]

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

[Out]

-5/2*I*sqrt(pi)*erf(I*x + 3/2*I)*e^(-1/4) - 1/2*I*sqrt(pi)*erf(I*x + 2*I)*e^(-2) + 1/8*(36*(2*x + 3)^3*gamma(3
/2, -1/4*(2*x + 3)^2)/(-(2*x + 3)^2)^(3/2) - 27*sqrt(pi)*(2*x + 3)*(erf(1/2*sqrt(-(2*x + 3)^2)) - 1)/sqrt(-(2*
x + 3)^2) + 54*e^(1/4*(2*x + 3)^2) - 8*gamma(2, -1/4*(2*x + 3)^2))*e^(-1/4) - 13/8*(4*(2*x + 3)^3*gamma(3/2, -
1/4*(2*x + 3)^2)/(-(2*x + 3)^2)^(3/2) - 9*sqrt(pi)*(2*x + 3)*(erf(1/2*sqrt(-(2*x + 3)^2)) - 1)/sqrt(-(2*x + 3)
^2) + 12*e^(1/4*(2*x + 3)^2))*e^(-1/4) - 17/4*(3*sqrt(pi)*(2*x + 3)*(erf(1/2*sqrt(-(2*x + 3)^2)) - 1)/sqrt(-(2
*x + 3)^2) - 2*e^(1/4*(2*x + 3)^2))*e^(-1/4) - ((x + 2)^3*gamma(3/2, -(x + 2)^2)/(-(x + 2)^2)^(3/2) - 4*sqrt(p
i)*(x + 2)*(erf(sqrt(-(x + 2)^2)) - 1)/sqrt(-(x + 2)^2) + 4*e^((x + 2)^2))*e^(-2) - 2*(2*sqrt(pi)*(x + 2)*(erf
(sqrt(-(x + 2)^2)) - 1)/sqrt(-(x + 2)^2) - e^((x + 2)^2))*e^(-2)

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 35 vs. \(2 (16) = 32\).

Time = 0.28 (sec) , antiderivative size = 35, normalized size of antiderivative = 1.94 \[ \int e^{2+3 x+x^2} \left (5+17 x+13 x^2+2 x^3+e^x \left (1+4 x+2 x^2\right )\right ) \, dx=x e^{\left (x^{2} + 4 \, x + 2\right )} + \frac {1}{4} \, {\left ({\left (2 \, x + 3\right )}^{2} + 8 \, x - 9\right )} e^{\left (x^{2} + 3 \, x + 2\right )} \]

[In]

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

[Out]

x*e^(x^2 + 4*x + 2) + 1/4*((2*x + 3)^2 + 8*x - 9)*e^(x^2 + 3*x + 2)

Mupad [B] (verification not implemented)

Time = 11.07 (sec) , antiderivative size = 16, normalized size of antiderivative = 0.89 \[ \int e^{2+3 x+x^2} \left (5+17 x+13 x^2+2 x^3+e^x \left (1+4 x+2 x^2\right )\right ) \, dx=x\,{\mathrm {e}}^{x^2+3\,x+2}\,\left (x+{\mathrm {e}}^x+5\right ) \]

[In]

int(exp(3*x + x^2 + 2)*(17*x + exp(x)*(4*x + 2*x^2 + 1) + 13*x^2 + 2*x^3 + 5),x)

[Out]

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