How to calculate the coefficients in an IBVP which is solved using separation of variables? So, I'm new to IBVP and I was looking at a basic heat problem, but I have a small question about the solution for the problem. I am attaching the problem and the solution.

In this problem $f(x) = sin (2πx) - 3 sin(6πx)$.
Based on the conditions we're given we know that $K = 1$ and $L = 1$
So our solution is

When I substitute in the solution I have $bn = \int_0^1 sin(2πx)sin(nπx) - 3sin(6πx) sin(nπx)dx$
We also know that 
$\sum_1^\infty bn*sin(nπx) = sin (2πx) - 3 sin(6πx)$
From that, we conclude that $b2 = 1$ and $b3 = -3$. Can someone please explain how we got these coefficients from the above?
 A: The separated solutions of the your PDE have the form
$$
             f_n(x,t) = X_n(x)T_n(t),\\
          X_n(x) = \sin\left(\frac{n\pi x}{L}\right),\;\;\; T_n(t)=\exp\left(-k\left(\frac{n\pi}{L}\right)^2t\right)
$$
The eigenfunction solutions $X_n$ for the $x$ equation satisfy common endpoint conditions, and this forces
$$
             \int_{0}^{L}X_n(x)X_m(x)dx = 0,\;\;\; n \ne m.
$$
This is a general pattern for separation of variables problems. The general solution $u$ has the form
$$
            u(x,t) = \sum_{n=1}^{\infty}A_n X_n(x)T_n(t)
$$
The coefficients $A_n$ are determined by the initial condition
$$
            f(x) = u(x,0) = \sum_{n=1}^{\infty}A_n X_n(x)
$$
because $T_n(0)=1$. Using orthogonality,
$$
             \int_{0}^{L}f(x)X_m(x)dx = A_m\int_{0}^{L}X_m(x)^2dx \\
            A_m = \frac{\int_{0}^{L}f(x)X_m(x)dx}{\int_{0}^{L}X_m(x)^2dx}.
$$
Apparently $L=1$ in your problem. And the initial function $f$ was convenient chosen to be of the form
$$
         f(x) = \sin(2\pi x) - 3\sin(6\pi x) \\
              = X_2(x)-3X_6(x).
$$
So that was crafted to make it easy to find the coefficients $A_n$ because
$$
        \int_{0}^{L}f(x)X_m(x)dx = 0,\;\;\; m \ne 2,6.
$$
You can spot that the solution has to be
$$
                  u(x,t) = X_2(x)T_2(t)-6X_6(x)T_6(t).
$$
