\(\int (a+b x+c x^2) \sin (x) \, dx\) [920]

   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 = 13, antiderivative size = 35 \[ \int \left (a+b x+c x^2\right ) \sin (x) \, dx=-a \cos (x)+2 c \cos (x)-b x \cos (x)-c x^2 \cos (x)+b \sin (x)+2 c x \sin (x) \]

[Out]

-a*cos(x)+2*c*cos(x)-b*x*cos(x)-c*x^2*cos(x)+b*sin(x)+2*c*x*sin(x)

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 35, normalized size of antiderivative = 1.00, number of steps used = 8, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.308, Rules used = {6874, 2718, 3377, 2717} \[ \int \left (a+b x+c x^2\right ) \sin (x) \, dx=-a \cos (x)+b \sin (x)-b x \cos (x)-c x^2 \cos (x)+2 c x \sin (x)+2 c \cos (x) \]

[In]

Int[(a + b*x + c*x^2)*Sin[x],x]

[Out]

-(a*Cos[x]) + 2*c*Cos[x] - b*x*Cos[x] - c*x^2*Cos[x] + b*Sin[x] + 2*c*x*Sin[x]

Rule 2717

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

Rule 2718

Int[sin[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Cos[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 (a \sin (x)+b x \sin (x)+c x^2 \sin (x)\right ) \, dx \\ & = a \int \sin (x) \, dx+b \int x \sin (x) \, dx+c \int x^2 \sin (x) \, dx \\ & = -a \cos (x)-b x \cos (x)-c x^2 \cos (x)+b \int \cos (x) \, dx+(2 c) \int x \cos (x) \, dx \\ & = -a \cos (x)-b x \cos (x)-c x^2 \cos (x)+b \sin (x)+2 c x \sin (x)-(2 c) \int \sin (x) \, dx \\ & = -a \cos (x)+2 c \cos (x)-b x \cos (x)-c x^2 \cos (x)+b \sin (x)+2 c x \sin (x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.08 (sec) , antiderivative size = 32, normalized size of antiderivative = 0.91 \[ \int \left (a+b x+c x^2\right ) \sin (x) \, dx=-a \cos (x)-b x \cos (x)-c \left (-2+x^2\right ) \cos (x)+b \sin (x)+2 c x \sin (x) \]

[In]

Integrate[(a + b*x + c*x^2)*Sin[x],x]

[Out]

-(a*Cos[x]) - b*x*Cos[x] - c*(-2 + x^2)*Cos[x] + b*Sin[x] + 2*c*x*Sin[x]

Maple [A] (verified)

Time = 0.26 (sec) , antiderivative size = 31, normalized size of antiderivative = 0.89

method result size
risch \(\left (-c \,x^{2}-x b -a +2 c \right ) \cos \left (x \right )+\left (2 c x +b \right ) \sin \left (x \right )\) \(31\)
parts \(-c \,x^{2} \cos \left (x \right )-b x \cos \left (x \right )-a \cos \left (x \right )+2 c \left (\cos \left (x \right )+x \sin \left (x \right )\right )+b \sin \left (x \right )\) \(35\)
default \(c \left (-x^{2} \cos \left (x \right )+2 \cos \left (x \right )+2 x \sin \left (x \right )\right )+b \left (\sin \left (x \right )-x \cos \left (x \right )\right )-a \cos \left (x \right )\) \(36\)
parallelrisch \(\left (-c \,x^{2}-x b -a +2 c \right ) \cos \left (x \right )+\left (2 c x +b \right ) \sin \left (x \right )-a +2 c\) \(37\)
norman \(\frac {c \,x^{2} \tan \left (\frac {x}{2}\right )^{2}+x b \tan \left (\frac {x}{2}\right )^{2}+2 b \tan \left (\frac {x}{2}\right )-c \,x^{2}-x b +4 c x \tan \left (\frac {x}{2}\right )-2 a +4 c}{1+\tan \left (\frac {x}{2}\right )^{2}}\) \(64\)
meijerg \(4 c \sqrt {\pi }\, \left (-\frac {1}{2 \sqrt {\pi }}+\frac {\left (-\frac {x^{2}}{2}+1\right ) \cos \left (x \right )}{2 \sqrt {\pi }}+\frac {x \sin \left (x \right )}{2 \sqrt {\pi }}\right )+2 b \sqrt {\pi }\, \left (-\frac {x \cos \left (x \right )}{2 \sqrt {\pi }}+\frac {\sin \left (x \right )}{2 \sqrt {\pi }}\right )+a \sqrt {\pi }\, \left (\frac {1}{\sqrt {\pi }}-\frac {\cos \left (x \right )}{\sqrt {\pi }}\right )\) \(74\)

[In]

int((c*x^2+b*x+a)*sin(x),x,method=_RETURNVERBOSE)

[Out]

(-c*x^2-b*x-a+2*c)*cos(x)+(2*c*x+b)*sin(x)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 27, normalized size of antiderivative = 0.77 \[ \int \left (a+b x+c x^2\right ) \sin (x) \, dx=-{\left (c x^{2} + b x + a - 2 \, c\right )} \cos \left (x\right ) + {\left (2 \, c x + b\right )} \sin \left (x\right ) \]

[In]

integrate((c*x^2+b*x+a)*sin(x),x, algorithm="fricas")

[Out]

-(c*x^2 + b*x + a - 2*c)*cos(x) + (2*c*x + b)*sin(x)

Sympy [A] (verification not implemented)

Time = 0.09 (sec) , antiderivative size = 39, normalized size of antiderivative = 1.11 \[ \int \left (a+b x+c x^2\right ) \sin (x) \, dx=- a \cos {\left (x \right )} - b x \cos {\left (x \right )} + b \sin {\left (x \right )} - c x^{2} \cos {\left (x \right )} + 2 c x \sin {\left (x \right )} + 2 c \cos {\left (x \right )} \]

[In]

integrate((c*x**2+b*x+a)*sin(x),x)

[Out]

-a*cos(x) - b*x*cos(x) + b*sin(x) - c*x**2*cos(x) + 2*c*x*sin(x) + 2*c*cos(x)

Maxima [A] (verification not implemented)

none

Time = 0.19 (sec) , antiderivative size = 35, normalized size of antiderivative = 1.00 \[ \int \left (a+b x+c x^2\right ) \sin (x) \, dx=-{\left (x \cos \left (x\right ) - \sin \left (x\right )\right )} b - {\left ({\left (x^{2} - 2\right )} \cos \left (x\right ) - 2 \, x \sin \left (x\right )\right )} c - a \cos \left (x\right ) \]

[In]

integrate((c*x^2+b*x+a)*sin(x),x, algorithm="maxima")

[Out]

-(x*cos(x) - sin(x))*b - ((x^2 - 2)*cos(x) - 2*x*sin(x))*c - a*cos(x)

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 27, normalized size of antiderivative = 0.77 \[ \int \left (a+b x+c x^2\right ) \sin (x) \, dx=-{\left (c x^{2} + b x + a - 2 \, c\right )} \cos \left (x\right ) + {\left (2 \, c x + b\right )} \sin \left (x\right ) \]

[In]

integrate((c*x^2+b*x+a)*sin(x),x, algorithm="giac")

[Out]

-(c*x^2 + b*x + a - 2*c)*cos(x) + (2*c*x + b)*sin(x)

Mupad [B] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 34, normalized size of antiderivative = 0.97 \[ \int \left (a+b x+c x^2\right ) \sin (x) \, dx=b\,\sin \left (x\right )-\cos \left (x\right )\,\left (a-2\,c\right )-b\,x\,\cos \left (x\right )+2\,c\,x\,\sin \left (x\right )-c\,x^2\,\cos \left (x\right ) \]

[In]

int(sin(x)*(a + b*x + c*x^2),x)

[Out]

b*sin(x) - cos(x)*(a - 2*c) - b*x*cos(x) + 2*c*x*sin(x) - c*x^2*cos(x)