I want to start by saying I understand the process of how to obtain equations for $a_n$ and $b_n$ are derived, but there is something about the notation in the derivation that I don't understand.
Lets say $$f(x) = \frac{a_0}{2}+\sum _{n=1}^{\infty }\left(a_n\:cos\left(nx\right)+b_n\:sin\left(nx\right)\right)$$
In the derivation, perhaps of $a_n$, the function is multiplied by $cos(mx)$ and then after simplification we get: $$\sum _{n=1}^{\infty }\left(a_n\:\delta _{mn}\right)$$
Which gives a formula for $a_m$... But what I don't get is how we can just replace 'm' with 'n'... If I retry doing the derivation, multiplying $f(x)$ by $cos(nx)$ instead, won't the $a_n$ obtained correspond to the $n$ in the newly multiplied $cos(nx)$, and not the $n$ in the $a_n$ subscript? It is easier to see what I mean if I use $n_1$ for the coefficient of cos($n_1$x) (in $f(x)$) and $n_2$ inside the argument in the multiplied $cos(nx)$, which gives me $$\sum _{n_1=1}^{\infty }\left(a_{n_1}\:\delta _{n_1n_2}\right) = a_{n_2}$$ and not a formula for $a_{n_1}$ as I would have expected from the actual derived equation.