3.3.52 \(\int x (1+e^x \sin (x))^2 \, dx\) [252]

Optimal. Leaf size=128 \[ -\frac {3 e^{2 x}}{32}+\frac {1}{8} e^{2 x} x+\frac {x^2}{2}+e^x \cos (x)-e^x x \cos (x)-\frac {1}{32} e^{2 x} \cos (2 x)+e^x x \sin (x)+\frac {1}{16} e^{2 x} \cos (x) \sin (x)-\frac {1}{4} e^{2 x} x \cos (x) \sin (x)-\frac {1}{16} e^{2 x} \sin ^2(x)+\frac {1}{4} e^{2 x} x \sin ^2(x)+\frac {1}{32} e^{2 x} \sin (2 x) \]

[Out]

-3/32*exp(2*x)+1/8*exp(2*x)*x+1/2*x^2+exp(x)*cos(x)-exp(x)*x*cos(x)-1/32*exp(2*x)*cos(2*x)+exp(x)*x*sin(x)+1/1
6*exp(2*x)*cos(x)*sin(x)-1/4*exp(2*x)*x*cos(x)*sin(x)-1/16*exp(2*x)*sin(x)^2+1/4*exp(2*x)*x*sin(x)^2+1/32*exp(
2*x)*sin(2*x)

________________________________________________________________________________________

Rubi [A]
time = 0.12, antiderivative size = 128, normalized size of antiderivative = 1.00, number of steps used = 14, number of rules used = 8, integrand size = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.667, Rules used = {6874, 4517, 4553, 4518, 4519, 2225, 4557, 12} \begin {gather*} \frac {x^2}{2}+\frac {1}{8} e^{2 x} x-\frac {3 e^{2 x}}{32}+\frac {1}{4} e^{2 x} x \sin ^2(x)-\frac {1}{16} e^{2 x} \sin ^2(x)+e^x x \sin (x)+\frac {1}{32} e^{2 x} \sin (2 x)-e^x x \cos (x)+e^x \cos (x)-\frac {1}{32} e^{2 x} \cos (2 x)-\frac {1}{4} e^{2 x} x \sin (x) \cos (x)+\frac {1}{16} e^{2 x} \sin (x) \cos (x) \end {gather*}

Antiderivative was successfully verified.

[In]

Int[x*(1 + E^x*Sin[x])^2,x]

[Out]

(-3*E^(2*x))/32 + (E^(2*x)*x)/8 + x^2/2 + E^x*Cos[x] - E^x*x*Cos[x] - (E^(2*x)*Cos[2*x])/32 + E^x*x*Sin[x] + (
E^(2*x)*Cos[x]*Sin[x])/16 - (E^(2*x)*x*Cos[x]*Sin[x])/4 - (E^(2*x)*Sin[x]^2)/16 + (E^(2*x)*x*Sin[x]^2)/4 + (E^
(2*x)*Sin[2*x])/32

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

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 4517

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

Rule 4518

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

Rule 4519

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

Rule 4553

Int[(F_)^((c_.)*((a_.) + (b_.)*(x_)))*((f_.)*(x_))^(m_.)*Sin[(d_.) + (e_.)*(x_)]^(n_.), x_Symbol] :> Module[{u
 = IntHide[F^(c*(a + b*x))*Sin[d + e*x]^n, x]}, Dist[(f*x)^m, u, x] - Dist[f*m, Int[(f*x)^(m - 1)*u, x], x]] /
; FreeQ[{F, a, b, c, d, e, f}, x] && IGtQ[n, 0] && GtQ[m, 0]

Rule 4557

Int[Cos[(f_.) + (g_.)*(x_)]^(n_.)*(F_)^((c_.)*((a_.) + (b_.)*(x_)))*Sin[(d_.) + (e_.)*(x_)]^(m_.), x_Symbol] :
> Int[ExpandTrigReduce[F^(c*(a + b*x)), Sin[d + e*x]^m*Cos[f + g*x]^n, x], x] /; FreeQ[{F, a, b, c, d, e, f, g
}, x] && IGtQ[m, 0] && IGtQ[n, 0]

Rule 6874

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

Rubi steps

\begin {align*} \int x \left (1+e^x \sin (x)\right )^2 \, dx &=\int \left (x+2 e^x x \sin (x)+e^{2 x} x \sin ^2(x)\right ) \, dx\\ &=\frac {x^2}{2}+2 \int e^x x \sin (x) \, dx+\int e^{2 x} x \sin ^2(x) \, dx\\ &=\frac {1}{8} e^{2 x} x+\frac {x^2}{2}-e^x x \cos (x)+e^x x \sin (x)-\frac {1}{4} e^{2 x} x \cos (x) \sin (x)+\frac {1}{4} e^{2 x} x \sin ^2(x)-2 \int \left (-\frac {1}{2} e^x \cos (x)+\frac {1}{2} e^x \sin (x)\right ) \, dx-\int \left (\frac {e^{2 x}}{8}-\frac {1}{4} e^{2 x} \cos (x) \sin (x)+\frac {1}{4} e^{2 x} \sin ^2(x)\right ) \, dx\\ &=\frac {1}{8} e^{2 x} x+\frac {x^2}{2}-e^x x \cos (x)+e^x x \sin (x)-\frac {1}{4} e^{2 x} x \cos (x) \sin (x)+\frac {1}{4} e^{2 x} x \sin ^2(x)-\frac {1}{8} \int e^{2 x} \, dx+\frac {1}{4} \int e^{2 x} \cos (x) \sin (x) \, dx-\frac {1}{4} \int e^{2 x} \sin ^2(x) \, dx+\int e^x \cos (x) \, dx-\int e^x \sin (x) \, dx\\ &=-\frac {e^{2 x}}{16}+\frac {1}{8} e^{2 x} x+\frac {x^2}{2}+e^x \cos (x)-e^x x \cos (x)+e^x x \sin (x)+\frac {1}{16} e^{2 x} \cos (x) \sin (x)-\frac {1}{4} e^{2 x} x \cos (x) \sin (x)-\frac {1}{16} e^{2 x} \sin ^2(x)+\frac {1}{4} e^{2 x} x \sin ^2(x)-\frac {1}{16} \int e^{2 x} \, dx+\frac {1}{4} \int \frac {1}{2} e^{2 x} \sin (2 x) \, dx\\ &=-\frac {3 e^{2 x}}{32}+\frac {1}{8} e^{2 x} x+\frac {x^2}{2}+e^x \cos (x)-e^x x \cos (x)+e^x x \sin (x)+\frac {1}{16} e^{2 x} \cos (x) \sin (x)-\frac {1}{4} e^{2 x} x \cos (x) \sin (x)-\frac {1}{16} e^{2 x} \sin ^2(x)+\frac {1}{4} e^{2 x} x \sin ^2(x)+\frac {1}{8} \int e^{2 x} \sin (2 x) \, dx\\ &=-\frac {3 e^{2 x}}{32}+\frac {1}{8} e^{2 x} x+\frac {x^2}{2}+e^x \cos (x)-e^x x \cos (x)-\frac {1}{32} e^{2 x} \cos (2 x)+e^x x \sin (x)+\frac {1}{16} e^{2 x} \cos (x) \sin (x)-\frac {1}{4} e^{2 x} x \cos (x) \sin (x)-\frac {1}{16} e^{2 x} \sin ^2(x)+\frac {1}{4} e^{2 x} x \sin ^2(x)+\frac {1}{32} e^{2 x} \sin (2 x)\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.12, size = 67, normalized size = 0.52 \begin {gather*} \frac {1}{8} \left (4 x^2+e^{2 x} (-1+2 x)-8 e^x (-1+x) \cos (x)-e^{2 x} x \cos (2 x)+8 e^x x \sin (x)-e^{2 x} (-1+2 x) \cos (x) \sin (x)\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[x*(1 + E^x*Sin[x])^2,x]

[Out]

(4*x^2 + E^(2*x)*(-1 + 2*x) - 8*E^x*(-1 + x)*Cos[x] - E^(2*x)*x*Cos[2*x] + 8*E^x*x*Sin[x] - E^(2*x)*(-1 + 2*x)
*Cos[x]*Sin[x])/8

________________________________________________________________________________________

Mathics [A]
time = 3.08, size = 72, normalized size = 0.56 \begin {gather*} -\sqrt {2} x \text {Cos}\left [\frac {\text {Pi}}{4}+x\right ] E^x-\frac {\sqrt {2} x E^{2 x} \text {Sin}\left [\frac {\text {Pi}}{4}+2 x\right ]}{8}+\frac {x E^{2 x}}{4}+\frac {x^2}{2}-\frac {E^{2 x}}{8}+\frac {E^{2 x} \text {Sin}\left [2 x\right ]}{16}+\text {Cos}\left [x\right ] E^x \end {gather*}

Antiderivative was successfully verified.

[In]

mathics('Integrate[x*(E^x*Sin[x]+1)^2,x]')

[Out]

-Sqrt[2] x Cos[Pi / 4 + x] E ^ x - Sqrt[2] x E ^ (2 x) Sin[Pi / 4 + 2 x] / 8 + x E ^ (2 x) / 4 + x ^ 2 / 2 - E
 ^ (2 x) / 8 + E ^ (2 x) Sin[2 x] / 16 + Cos[x] E ^ x

________________________________________________________________________________________

Maple [A]
time = 0.04, size = 63, normalized size = 0.49

method result size
default \(\frac {x^{2}}{2}+2 \left (-\frac {x}{2}+\frac {1}{2}\right ) {\mathrm e}^{x} \cos \left (x \right )+{\mathrm e}^{x} x \sin \left (x \right )+\frac {{\mathrm e}^{2 x} x}{4}-\frac {{\mathrm e}^{2 x}}{8}-\frac {x \,{\mathrm e}^{2 x} \cos \left (2 x \right )}{8}+\frac {\left (-\frac {x}{4}+\frac {1}{8}\right ) {\mathrm e}^{2 x} \sin \left (2 x \right )}{2}\) \(63\)
risch \(\frac {x^{2}}{2}+\left (-\frac {1}{8}+\frac {x}{4}\right ) {\mathrm e}^{2 x}+\left (-\frac {1}{64}+\frac {i}{64}\right ) \left (-1+i+4 x \right ) {\mathrm e}^{\left (2+2 i\right ) x}+\left (-\frac {1}{4}-\frac {i}{4}\right ) \left (-1+i+2 x \right ) {\mathrm e}^{\left (1+i\right ) x}+\left (-\frac {1}{4}+\frac {i}{4}\right ) \left (-1-i+2 x \right ) {\mathrm e}^{\left (1-i\right ) x}+\left (-\frac {1}{64}-\frac {i}{64}\right ) \left (-1-i+4 x \right ) {\mathrm e}^{\left (2-2 i\right ) x}\) \(85\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(x*(1+exp(x)*sin(x))^2,x,method=_RETURNVERBOSE)

[Out]

1/2*x^2+2*(-1/2*x+1/2)*exp(x)*cos(x)+exp(x)*x*sin(x)+1/4*exp(x)^2*x-1/8*exp(x)^2-1/8*x*exp(2*x)*cos(2*x)+1/2*(
-1/4*x+1/8)*exp(2*x)*sin(2*x)

________________________________________________________________________________________

Maxima [A]
time = 0.28, size = 58, normalized size = 0.45 \begin {gather*} -\frac {1}{8} \, x \cos \left (2 \, x\right ) e^{\left (2 \, x\right )} - {\left (x - 1\right )} \cos \left (x\right ) e^{x} - \frac {1}{16} \, {\left (2 \, x - 1\right )} e^{\left (2 \, x\right )} \sin \left (2 \, x\right ) + x e^{x} \sin \left (x\right ) + \frac {1}{2} \, x^{2} + \frac {1}{8} \, {\left (2 \, x - 1\right )} e^{\left (2 \, x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x*(1+exp(x)*sin(x))^2,x, algorithm="maxima")

[Out]

-1/8*x*cos(2*x)*e^(2*x) - (x - 1)*cos(x)*e^x - 1/16*(2*x - 1)*e^(2*x)*sin(2*x) + x*e^x*sin(x) + 1/2*x^2 + 1/8*
(2*x - 1)*e^(2*x)

________________________________________________________________________________________

Fricas [A]
time = 0.31, size = 55, normalized size = 0.43 \begin {gather*} -{\left (x - 1\right )} \cos \left (x\right ) e^{x} + \frac {1}{2} \, x^{2} - \frac {1}{8} \, {\left (2 \, x \cos \left (x\right )^{2} - 3 \, x + 1\right )} e^{\left (2 \, x\right )} - \frac {1}{8} \, {\left ({\left (2 \, x - 1\right )} \cos \left (x\right ) e^{\left (2 \, x\right )} - 8 \, x e^{x}\right )} \sin \left (x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x*(1+exp(x)*sin(x))^2,x, algorithm="fricas")

[Out]

-(x - 1)*cos(x)*e^x + 1/2*x^2 - 1/8*(2*x*cos(x)^2 - 3*x + 1)*e^(2*x) - 1/8*((2*x - 1)*cos(x)*e^(2*x) - 8*x*e^x
)*sin(x)

________________________________________________________________________________________

Sympy [A]
time = 0.72, size = 109, normalized size = 0.85 \begin {gather*} \frac {x^{2}}{2} + \frac {3 x e^{2 x} \sin ^{2}{\left (x \right )}}{8} - \frac {x e^{2 x} \sin {\left (x \right )} \cos {\left (x \right )}}{4} + \frac {x e^{2 x} \cos ^{2}{\left (x \right )}}{8} + x e^{x} \sin {\left (x \right )} - x e^{x} \cos {\left (x \right )} - \frac {e^{2 x} \sin ^{2}{\left (x \right )}}{8} + \frac {e^{2 x} \sin {\left (x \right )} \cos {\left (x \right )}}{8} - \frac {e^{2 x} \cos ^{2}{\left (x \right )}}{8} + e^{x} \cos {\left (x \right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x*(1+exp(x)*sin(x))**2,x)

[Out]

x**2/2 + 3*x*exp(2*x)*sin(x)**2/8 - x*exp(2*x)*sin(x)*cos(x)/4 + x*exp(2*x)*cos(x)**2/8 + x*exp(x)*sin(x) - x*
exp(x)*cos(x) - exp(2*x)*sin(x)**2/8 + exp(2*x)*sin(x)*cos(x)/8 - exp(2*x)*cos(x)**2/8 + exp(x)*cos(x)

________________________________________________________________________________________

Giac [A]
time = 0.00, size = 71, normalized size = 0.55 \begin {gather*} \frac {1}{2} x^{2}+\mathrm {e}^{x} \left (-\frac {1}{2} \left (2 x-2\right ) \cos x+\frac {2}{2} x \sin x\right )+\frac {1}{8} \left (2 x-1\right ) \mathrm {e}^{2 x}+\mathrm {e}^{2 x} \left (-\frac {2}{16} x \cos \left (2 x\right )+\frac {1}{16} \left (-2 x+1\right ) \sin \left (2 x\right )\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x*(1+exp(x)*sin(x))^2,x)

[Out]

-1/16*(2*x*cos(2*x) + (2*x - 1)*sin(2*x))*e^(2*x) - ((x - 1)*cos(x) - x*sin(x))*e^x + 1/8*e^(2*x)*(2*x - 1) +
1/2*x^2

________________________________________________________________________________________

Mupad [B]
time = 0.28, size = 69, normalized size = 0.54 \begin {gather*} \frac {3\,x\,{\mathrm {e}}^{2\,x}}{8}-\frac {{\mathrm {e}}^{2\,x}}{8}+{\mathrm {e}}^x\,\cos \left (x\right )+\frac {x^2}{2}-\frac {x\,{\mathrm {e}}^{2\,x}\,{\cos \left (x\right )}^2}{4}+\frac {{\mathrm {e}}^{2\,x}\,\cos \left (x\right )\,\sin \left (x\right )}{8}-x\,{\mathrm {e}}^x\,\cos \left (x\right )+x\,{\mathrm {e}}^x\,\sin \left (x\right )-\frac {x\,{\mathrm {e}}^{2\,x}\,\cos \left (x\right )\,\sin \left (x\right )}{4} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(x*(exp(x)*sin(x) + 1)^2,x)

[Out]

(3*x*exp(2*x))/8 - exp(2*x)/8 + exp(x)*cos(x) + x^2/2 - (x*exp(2*x)*cos(x)^2)/4 + (exp(2*x)*cos(x)*sin(x))/8 -
 x*exp(x)*cos(x) + x*exp(x)*sin(x) - (x*exp(2*x)*cos(x)*sin(x))/4

________________________________________________________________________________________