How do the equations below follow? $$\int_0^1 x^2\sin(m\pi x)\,dx =\sum_{n=1}^\infty \left(B_n\int_0^1 \sin(n\pi x) \sin(m\pi x) \, dx\right) , m,n\in \mathbb N  $$
From here how do the equations below follow?
$$\int_0^1 x^2 \sin(n\pi x) \, dx ={1\over 2} B_n $$
$$ B_n=2 {-2+(-1)^n (2-n^2 \pi ^2) \over n^3 \pi ^3 }  $$
 A: The question as it is seems a bit oddly framed to me, so I will start from where I feel is the most natural point to motivate the question. If you want to skip this, then start from the bolded line.

We want to find the Fourier series for the function $x^2$; since we are only interested in the function on $(0,1)$, we can choose a series that will involve sine terms only (so that the series, when not restricted to $(0,1)$ will actually give the odd periodic extension of $x^2$). We may write*:
$$x^2 = \sum_{m=1}^{\infty} B_m \, sin(m \pi x)$$
*We assume that we are given that such a series representation exists.
We want to isolate the $n^{th}$ coefficient, $B_n$, and do so by first multiplying each side by $sin(n \pi x)$, and then integrating each side over $[0,1]$:
\begin{align}
\int_0^1 x^2\sin(n \pi x)\,dx &=\int_0^1 \left(\sum_{m=1}^\infty B_m\sin(m\pi x) \sin(n\pi x) \, dx\right)\\ \tag{1}
&=\sum_{m=1}^\infty \left(B_m\int_0^1 \sin(n\pi x) \sin(m\pi x) \, dx\right)
\end{align}
We assume here that the order of integration and summation can be interchanged (in fact it can since the Fourier series converges uniformly).
This brings us to the entry point of the question. We now observe the following identities, often referred to as the "orthogonality relations" when dealing with Fourier series:
$$ \int_{-1}^1 sin(m \pi x) \, sin(n \pi x) \, dx = \delta_{m n} $$
where $\delta_{m n}$ is the Kronecker delta.
Noting that the integrand in the above equality is even (since the two sine terms are odd, and the product of two odd functions is even), we get
\begin{align}
\int_0^1 sin(m \pi x) \, sin(n \pi x) \, dx &= \frac12 \int_{-1}^1 sin(m \pi x) sin(n \pi x)\, dx\\ \tag{2}
&= \frac{\delta_{m n}}{2}
\end{align}
Now, observe that, by substituting $(2)$ into $(1)$, we can massively simplify equation $(1)$, and isolate the $n^{th}$ coefficient:
\begin{align}
\int_0^1 x^2 \sin(n\pi x) \, dx &= \sum_{m=1}^{\infty} B_m \, \frac{\delta_{m n}}{2}\\
&= \frac12 B_n
\end{align}
But we know how to evaluate the LHS explicitly - for example, we could use integration by parts twice (like this). Indeed, this gives,
$$ \text{LHS}= {-2+(-1)^n (2-n^2 \pi ^2) \over n^3 \pi ^3 }  $$
as required.
