1

Evaluate $$\int_{-\pi}^{\pi} x^2 \cos{3x}dx$$

I applied integration-by-parts twice and finally got a result of $-\frac{4\pi}{9}$ but the back of the book says $+\frac{4\pi}{9}$ .

Which answer is correct?

Also I drew a sketch of the curve with points: $(-\pi,-\pi^2),(-\frac{\pi}{2},0),(0,\pi^2),(\frac{\pi}{2},0),(\pi,-\pi^2)$

Surely this function has an equal area above the x-axis as below it. Should the integral not be zero?

What am I missing here?

Kantura
  • 2,721

4 Answers4

4

Here is an approach in which we use differentiation under the integral.

Let $I(a)$ be the integral given by

$$\begin{align} I(a)&=\int_{-\pi}^\pi \cos(ax)\,dx\\\\ &=\frac{2\sin(a\pi)}{a} \tag 1 \end{align}$$

Then, note that the integral of interest can be written in terms of the second derivative of $I(a)$ as

$$\int_{-\pi}^\pi x^2\cos(3x)\,dx=-I''(3) \tag 2$$

From $(1)$, we have

$$-I''(3)=-\frac{4\pi }{9}$$

Hence, we have

$$\bbox[5px,border:2px solid #C0A000]{\int_{-\pi}^\pi x^2\cos(3x)\,dx=-\frac{4\pi}{9}}$$

as was to be shown!

Mark Viola
  • 179,405
2

The Fourier cosine series of $x^2$ over $(-\pi,\pi)$ is given by: $$ x^2 = \frac{\pi^2}{3}-\sum_{n\geq 1}\frac{4(-1)^{n+1}}{n^2}\cos(nx) \tag{1}$$ hence we have:

$$ \int_{-\pi}^{\pi}x^2\cos(3x)\,dx = -\frac{4}{9}\int_{-\pi}^{\pi}\cos^2(3x)\,dx = \color{red}{-\frac{4\pi}{9}}.\tag{2}$$

Jack D'Aurizio
  • 353,855
2

The function is not symmetric about the $x$-axis. It is symmetric about the $y$-axis; that is to say, $f(x) = x^2 \cos 3x$ satisfies $f(-x) = f(x)$ for all $x \in \mathbb R$.

With the choice $u = x^2$, $du = 2x \, dx$, $dv = \cos 3x \, dx$, $v = \frac{1}{3} \sin 3x$, we get $$\int x^2 \cos 3x \, dx = \frac{x^2}{3} \sin 3x - \frac{2}{3} \int x \sin 3x \, dx.$$ Repeating the process with the choice $u = x$, $du = dx$, $dv = \sin 3x \, dx$, $v = -\frac{1}{3}\cos 3x$, we get $$\int x^2 \cos 3x \, dx = \frac{x^2}{3} \sin 3x - \frac{2}{3} \left( -\frac{x}{3} \cos 3x + \frac{1}{3} \int \cos 3x \, dx \right).$$ From this we conclude the indefinite integral equals $$\frac{x^2}{3} \sin 3x + \frac{2x}{9} \cos 3x - \frac{2}{27} \sin 3x + C.$$ Evaluating this at the endpoint $x = \pi$ gives $-2\pi/9$, whereas evaluating at $x = 0$ gives $0$, hence half the definite integral (due to the aforementioned symmetry) is $-2\pi/9$, and the full value is $-4\pi/9$, as you claimed.

heropup
  • 135,869
0

You can also use the Taylor series of cosine $$\int_{-\pi}^{\pi}x^{2}\cos\left(3x\right)dx=\sum_{k\geq0}\frac{\left(-1\right)^{k}3^{2k}}{\left(2k\right)!}\int_{-\pi}^{\pi}x^{2k+2}dx $$ $$=2\sum_{k\geq0}\frac{\left(-1\right)^{k}3^{2k}\pi^{2k+3}}{\left(2k\right)!\left(2k+3\right)}=2\sum_{k\geq0}\frac{\left(-1\right)^{k}3^{2k}\pi^{2k+3}}{\left(2k+3\right)!}\left(2k+1\right)\left(2k+2\right) $$ $$2\sum_{k\geq1}\frac{\left(-1\right)^{k-1}3^{2k-2}\pi^{2k+1}}{\left(2k+1\right)!}\left(2k-1\right)\left(2k\right)=2\sum_{k\geq0}\frac{\left(-1\right)^{k-1}3^{2k-2}\pi^{2k+1}}{\left(2k+1\right)!}\left(2k-1\right)\left(2k\right)$$ $$ =2\pi^{3}\frac{d^{2}}{dx^{2}}\left(\frac{\sin\left(x\right)}{x}\right)_{x=3\pi}=-\frac{4}{9}\pi.$$

Marco Cantarini
  • 33,062
  • 2
  • 47
  • 93