\(\int (x+\sin (x))^2 \, dx\) [29]

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

Optimal result

Integrand size = 6, antiderivative size = 30 \[ \int (x+\sin (x))^2 \, dx=\frac {x}{2}+\frac {x^3}{3}-2 x \cos (x)+2 \sin (x)-\frac {1}{2} \cos (x) \sin (x) \]

[Out]

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

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 30, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.833, Rules used = {6874, 3377, 2717, 2715, 8} \[ \int (x+\sin (x))^2 \, dx=\frac {x^3}{3}+\frac {x}{2}+2 \sin (x)-2 x \cos (x)-\frac {1}{2} \sin (x) \cos (x) \]

[In]

Int[(x + Sin[x])^2,x]

[Out]

x/2 + x^3/3 - 2*x*Cos[x] + 2*Sin[x] - (Cos[x]*Sin[x])/2

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 2715

Int[((b_.)*sin[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[(-b)*Cos[c + d*x]*((b*Sin[c + d*x])^(n - 1)/(d*n))
, x] + Dist[b^2*((n - 1)/n), Int[(b*Sin[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1] && Integ
erQ[2*n]

Rule 2717

Int[sin[Pi/2 + (c_.) + (d_.)*(x_)], x_Symbol] :> Simp[Sin[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rule 3377

Int[((c_.) + (d_.)*(x_))^(m_.)*sin[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[(-(c + d*x)^m)*(Cos[e + f*x]/f), x]
+ Dist[d*(m/f), Int[(c + d*x)^(m - 1)*Cos[e + f*x], x], x] /; FreeQ[{c, d, e, f}, x] && GtQ[m, 0]

Rule 6874

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

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

Mathematica [A] (verified)

Time = 0.05 (sec) , antiderivative size = 30, normalized size of antiderivative = 1.00 \[ \int (x+\sin (x))^2 \, dx=\frac {1}{6} x \left (3+2 x^2\right )-2 x \cos (x)+2 \sin (x)-\frac {1}{4} \sin (2 x) \]

[In]

Integrate[(x + Sin[x])^2,x]

[Out]

(x*(3 + 2*x^2))/6 - 2*x*Cos[x] + 2*Sin[x] - Sin[2*x]/4

Maple [A] (verified)

Time = 0.46 (sec) , antiderivative size = 25, normalized size of antiderivative = 0.83

method result size
default \(\frac {x}{2}+\frac {x^{3}}{3}-2 x \cos \left (x \right )+2 \sin \left (x \right )-\frac {\cos \left (x \right ) \sin \left (x \right )}{2}\) \(25\)
risch \(\frac {x^{3}}{3}+\frac {x}{2}-2 x \cos \left (x \right )+2 \sin \left (x \right )-\frac {\sin \left (2 x \right )}{4}\) \(25\)
parallelrisch \(\frac {x^{3}}{3}+\frac {x}{2}-2 x \cos \left (x \right )+2 \sin \left (x \right )-\frac {\sin \left (2 x \right )}{4}\) \(25\)
parts \(\frac {x}{2}+\frac {x^{3}}{3}-2 x \cos \left (x \right )+2 \sin \left (x \right )-\frac {\cos \left (x \right ) \sin \left (x \right )}{2}\) \(25\)
norman \(\frac {x \tan \left (\frac {x}{2}\right )^{2}-\frac {3 x}{2}+\frac {x^{3}}{3}+5 \tan \left (\frac {x}{2}\right )^{3}+\frac {5 x \tan \left (\frac {x}{2}\right )^{4}}{2}+\frac {2 x^{3} \tan \left (\frac {x}{2}\right )^{2}}{3}+\frac {x^{3} \tan \left (\frac {x}{2}\right )^{4}}{3}+3 \tan \left (\frac {x}{2}\right )}{\left (1+\tan \left (\frac {x}{2}\right )^{2}\right )^{2}}\) \(74\)

[In]

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

[Out]

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

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 22, normalized size of antiderivative = 0.73 \[ \int (x+\sin (x))^2 \, dx=\frac {1}{3} \, x^{3} - 2 \, x \cos \left (x\right ) - \frac {1}{2} \, {\left (\cos \left (x\right ) - 4\right )} \sin \left (x\right ) + \frac {1}{2} \, x \]

[In]

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

[Out]

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

Sympy [A] (verification not implemented)

Time = 0.07 (sec) , antiderivative size = 41, normalized size of antiderivative = 1.37 \[ \int (x+\sin (x))^2 \, dx=\frac {x^{3}}{3} + \frac {x \sin ^{2}{\left (x \right )}}{2} + \frac {x \cos ^{2}{\left (x \right )}}{2} - 2 x \cos {\left (x \right )} - \frac {\sin {\left (x \right )} \cos {\left (x \right )}}{2} + 2 \sin {\left (x \right )} \]

[In]

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

[Out]

x**3/3 + x*sin(x)**2/2 + x*cos(x)**2/2 - 2*x*cos(x) - sin(x)*cos(x)/2 + 2*sin(x)

Maxima [A] (verification not implemented)

none

Time = 0.21 (sec) , antiderivative size = 24, normalized size of antiderivative = 0.80 \[ \int (x+\sin (x))^2 \, dx=\frac {1}{3} \, x^{3} - 2 \, x \cos \left (x\right ) + \frac {1}{2} \, x - \frac {1}{4} \, \sin \left (2 \, x\right ) + 2 \, \sin \left (x\right ) \]

[In]

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

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 24, normalized size of antiderivative = 0.80 \[ \int (x+\sin (x))^2 \, dx=\frac {1}{3} \, x^{3} - 2 \, x \cos \left (x\right ) + \frac {1}{2} \, x - \frac {1}{4} \, \sin \left (2 \, x\right ) + 2 \, \sin \left (x\right ) \]

[In]

integrate((x+sin(x))^2,x, algorithm="giac")

[Out]

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

Mupad [B] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 24, normalized size of antiderivative = 0.80 \[ \int (x+\sin (x))^2 \, dx=\frac {x}{2}+2\,\sin \left (x\right )-\frac {\cos \left (x\right )\,\sin \left (x\right )}{2}-2\,x\,\cos \left (x\right )+\frac {x^3}{3} \]

[In]

int((x + sin(x))^2,x)

[Out]

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