3.4.52 \(\int x^2 \cos (3 x) \, dx\) [352]

Optimal. Leaf size=29 \[ \frac {2}{9} x \cos (3 x)-\frac {2}{27} \sin (3 x)+\frac {1}{3} x^2 \sin (3 x) \]

[Out]

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

________________________________________________________________________________________

Rubi [A]
time = 0.02, antiderivative size = 29, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, integrand size = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3377, 2717} \begin {gather*} \frac {1}{3} x^2 \sin (3 x)-\frac {2}{27} \sin (3 x)+\frac {2}{9} x \cos (3 x) \end {gather*}

Antiderivative was successfully verified.

[In]

Int[x^2*Cos[3*x],x]

[Out]

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

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]

Rubi steps

\begin {align*} \int x^2 \cos (3 x) \, dx &=\frac {1}{3} x^2 \sin (3 x)-\frac {2}{3} \int x \sin (3 x) \, dx\\ &=\frac {2}{9} x \cos (3 x)+\frac {1}{3} x^2 \sin (3 x)-\frac {2}{9} \int \cos (3 x) \, dx\\ &=\frac {2}{9} x \cos (3 x)-\frac {2}{27} \sin (3 x)+\frac {1}{3} x^2 \sin (3 x)\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.01, size = 25, normalized size = 0.86 \begin {gather*} \frac {2}{9} x \cos (3 x)+\frac {1}{27} \left (-2+9 x^2\right ) \sin (3 x) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[x^2*Cos[3*x],x]

[Out]

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

________________________________________________________________________________________

Maple [A]
time = 0.02, size = 24, normalized size = 0.83

method result size
risch \(\frac {2 x \cos \left (3 x \right )}{9}+\frac {\left (9 x^{2}-2\right ) \sin \left (3 x \right )}{27}\) \(22\)
derivativedivides \(\frac {2 x \cos \left (3 x \right )}{9}-\frac {2 \sin \left (3 x \right )}{27}+\frac {x^{2} \sin \left (3 x \right )}{3}\) \(24\)
default \(\frac {2 x \cos \left (3 x \right )}{9}-\frac {2 \sin \left (3 x \right )}{27}+\frac {x^{2} \sin \left (3 x \right )}{3}\) \(24\)
meijerg \(\frac {4 \sqrt {\pi }\, \left (\frac {3 x \cos \left (3 x \right )}{2 \sqrt {\pi }}-\frac {\left (-\frac {27 x^{2}}{2}+3\right ) \sin \left (3 x \right )}{6 \sqrt {\pi }}\right )}{27}\) \(33\)
norman \(\frac {\frac {2 x}{9}-\frac {2 x \left (\tan ^{2}\left (\frac {3 x}{2}\right )\right )}{9}+\frac {2 x^{2} \tan \left (\frac {3 x}{2}\right )}{3}-\frac {4 \tan \left (\frac {3 x}{2}\right )}{27}}{1+\tan ^{2}\left (\frac {3 x}{2}\right )}\) \(40\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(x^2*cos(3*x),x,method=_RETURNVERBOSE)

[Out]

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

________________________________________________________________________________________

Maxima [A]
time = 2.98, size = 21, normalized size = 0.72 \begin {gather*} \frac {2}{9} \, x \cos \left (3 \, x\right ) + \frac {1}{27} \, {\left (9 \, x^{2} - 2\right )} \sin \left (3 \, x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x^2*cos(3*x),x, algorithm="maxima")

[Out]

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

________________________________________________________________________________________

Fricas [A]
time = 0.86, size = 21, normalized size = 0.72 \begin {gather*} \frac {2}{9} \, x \cos \left (3 \, x\right ) + \frac {1}{27} \, {\left (9 \, x^{2} - 2\right )} \sin \left (3 \, x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x^2*cos(3*x),x, algorithm="fricas")

[Out]

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

________________________________________________________________________________________

Sympy [A]
time = 0.08, size = 27, normalized size = 0.93 \begin {gather*} \frac {x^{2} \sin {\left (3 x \right )}}{3} + \frac {2 x \cos {\left (3 x \right )}}{9} - \frac {2 \sin {\left (3 x \right )}}{27} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x**2*cos(3*x),x)

[Out]

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

________________________________________________________________________________________

Giac [A]
time = 0.87, size = 21, normalized size = 0.72 \begin {gather*} \frac {2}{9} \, x \cos \left (3 \, x\right ) + \frac {1}{27} \, {\left (9 \, x^{2} - 2\right )} \sin \left (3 \, x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x^2*cos(3*x),x, algorithm="giac")

[Out]

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

________________________________________________________________________________________

Mupad [B]
time = 0.19, size = 23, normalized size = 0.79 \begin {gather*} \frac {2\,x\,\cos \left (3\,x\right )}{9}-\frac {2\,\sin \left (3\,x\right )}{27}+\frac {x^2\,\sin \left (3\,x\right )}{3} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(x^2*cos(3*x),x)

[Out]

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

________________________________________________________________________________________