# Integral with sine(x) and x multiplied

1. Feb 28, 2015

### Maylis

1. The problem statement, all variables and given/known data
I'm doing a physics problem, but I'm stuck on the math part. My integral is

$$\frac {2 \sqrt {15}}{a^{3}} \int_{0}^{a} \hspace{0.01 in} sin(\frac {n \pi}{a} x)x(a-x) dx$$
Where $a$ is a constant, and $n = 1,2,3,...$

2. Relevant equations

3. The attempt at a solution
I will separate these into two integrals

$$\frac {2 \sqrt {15}}{a^{3}} \Big [ \int_{0}^{a} ax \hspace{0.01 in} sin(\frac {n \pi}{a}x) dx - \int_{0}^{a} x^{2} \hspace {0.01 in} sin( \frac {n \pi}{a} x) \Big ] dx$$

But from here, I know I could look up on the internet some sort of integral table, but the one I found

Is this integral reasonable to solve by hand, or is it just better to use the table?

2. Feb 28, 2015

### Dick

It's just integration by parts. Try doing x*sin(x) using the method. It would be good practice.

3. Feb 28, 2015

### Maylis

Okay, that was a fun little exercise to do the integration by parts (it's been a couple years)

So for the first term
$$\frac {2 \sqrt {15}}{a^{3}} \int_{0}^{a} ax \hspace{0.01 in} sin(\frac {n \pi}{a}x) \hspace {0.01 in} dx$$
I will set $u = x$, $du = dx$, $dv = sin(\frac {n \pi}{a} x) dx$, $v = - \frac {a}{n \pi} \hspace {0.01 in} cos (\frac {n \pi}{a} x)$
So using integration by parts (and cancelling the $a$ term in the integral with the one outside)
$$\int u \hspace {0.01 in} dv = uv - \int v \hspace {0.01 in} du$$

$$\frac {2 \sqrt {15}}{a^{2}} \Big [ x \frac {-a}{n \pi} \hspace {0.01 in} cos (\frac {n \pi}{a} x) - \int - \frac {a}{n \pi} \hspace {0.01 in} cos (\frac {n \pi}{a} x) \hspace {0.01 in} dx \Big ]$$
$$\frac {2 \sqrt {15}}{a^{2}} \Big [ x \frac {-a}{n \pi} \hspace {0.01 in} cos (\frac {n \pi}{a} x) + \frac {a^{2}}{n^{2} \pi^{2}} \hspace {0.01 in} sin(\frac {n \pi}{a} x) \Big ] \bigg |_{0:a}$$
$$\frac {2 \sqrt {15}}{a^{2}} \Big [ \frac {-a^{2}}{n \pi} \hspace {0.01 in} cos (n \pi) + \frac {a^{2}}{n^{2} \pi^{2}} \hspace {0.01 in} sin(n \pi) \Big ]$$
The first term reduces to
$$\frac {-2 \sqrt {15}}{n \pi} \hspace {0.01 in} cos (n \pi) + \frac {2 \sqrt {15}}{n^{2} \pi^{2}} \hspace {0.01 in} sin(n \pi)$$

Now for the second term
$u = x^{2}$, $du = 2x \hspace {0.01 in} dx$, $dv = sin(\frac {n \pi}{a} x) dx$, $v = - \frac {a}{n \pi} \hspace {0.01 in} cos (\frac {n \pi}{a} x)$
$$\frac {2 \sqrt {15}}{a^{3}} \Big [ x^{2} \frac {-a}{n \pi} \hspace {0.01 in} cos (\frac {n \pi}{a} x) + \frac {1}{2} \int \frac {a}{n \pi} \hspace {0.01 in} cos (\frac {n \pi}{a} x) \hspace {0.01 in} dx \Big ]$$
$$\frac {2 \sqrt {15}}{a^{3}} \Big [ x^{2} \frac {-a}{n \pi} \hspace {0.01 in} cos (\frac {n \pi}{a} x) + \frac {a^{2}}{2n^{2} \pi^{2}} \hspace {0.01 in} sin (\frac {n \pi}{a} x) \Big ] \bigg |_{0:a}$$
$$\frac {2 \sqrt {15}}{a^{3}} \Big [ \frac {-a^{3}}{n \pi} \hspace {0.01 in} cos (n \pi) + \frac {a^{2}}{2n^{2} \pi^{2}} \hspace {0.01 in} sin (n \pi) \Big ]$$
The second term reduces to
$$\frac {-2 \sqrt{15}}{n \pi} \hspace {0.01 in} cos (n \pi) + \frac {\sqrt {15}}{an^{2} \pi^{2}} \hspace {0.01 in} sin (n \pi)$$

Now going all the way back, I have to subtract these terms,
$$\Big [ \frac {-2 \sqrt {15}}{n \pi} \hspace {0.01 in} cos (n \pi) + \frac {2 \sqrt {15}}{n^{2} \pi^{2}} \hspace {0.01 in} sin(n \pi) \Big ] - \Big [\frac {-2 \sqrt{15}}{n \pi} \hspace {0.01 in} cos (n \pi) + \frac {\sqrt {15}}{an^{2} \pi^{2}} \hspace {0.01 in} sin (n \pi) \Big ]$$

Simplifying to
$$c_{n} = \frac {\sqrt {15}}{n^{2} \pi^{2}} \hspace {0.01 in} sin(n \pi) \big (2 - \frac {1}{a} \big )$$

Last edited: Feb 28, 2015
4. Feb 28, 2015

### Maylis

I think the author just used a table, not sure if his solution is equivalent to mine

5. Feb 28, 2015

### LCKurtz

Are you aware that $\sin(n\pi)=0$ so you got $0$?

6. Feb 28, 2015

### Ray Vickson

A useful alternative method is to use "differentiation under the integral sign". Here is how it works.

We have $\sin(\theta) = \text{Im}\: e^{i \theta}$, where $\text{Im}$ denotes the imaginary part. Also: the integral of the imaginary part equals the imaginary part of the integral (for integration over real numbers). So, if we write
$$F(k) = \int_0^a e^{i x k/a} \, dx$$
we can use the facts that
$$\frac{d}{dk} e^{i k x /a} = \frac{i x}{a} e^{i k x/a}$$
and
$$\frac{d^2}{dk^2} e^{i k x/a} = -\frac{x^2}{a^2} e^{i k x/a}$$
to get
$$\int_0^a x(a-x) e^{i k x/a} \, dx = \left( 1 + \frac{a^2}{i} \frac{d}{dk} + a^2 \frac{d^2}{dk^2} \right) F(k)$$
You can easily find $F(k)$, take the derivatives above, and simplify. Then you can take the imaginary part, to get the integral with $\sin(k x /a)$ in the integrand. Finally, you can set $k = n \pi$ and simplify further.

Last edited: Feb 28, 2015
7. Feb 28, 2015

### Maylis

Where did I go wrong in my integration? Everything seems to check out...I overlooked that I got zero, but at least it is connect if $n$ is even...but my solution is for all $n$