If you have the equation:
$$f(t) = \sum_{k=0}^N \left( A_k \cos \omega_k t + B \sin \omega_k t\right)$$
To compute the $A_k$ Fourier coefficient you have two cases:
$$A_k = \color{\red}{{2 \over T}} \int_{-T/2}^{T/2} f(t) \cos \omega_k t dt$$
for $k \neq 0$ and
$$A_0 = \color{\red}{{1 \over T}} \int_{-T/2}^{T/2} f(t) dt.$$
I am interested in the normalization coefficients in red. I know where they come from:
$$\scriptsize\int_0^T \cos \left({2 \pi m t \over T}\right)\cos \left({2 \pi n t \over T}\right) dt = \begin{cases}0 & \mbox{ for } n \ne m,\\ T/2 & \mbox{ for } n = m \ne 0,\\T & \mbox{ for } n = m = 0.\end{cases}$$
But my question actually concerns the case where you deal with real signal (no imaginary part). You can write the equation for computing the coefficients as:
$$a[k] = \sum_{x=0}^{N-1} s[x] \cos(\omega_k x)$$
for $k = \{1,...,{N \over 2}\}$, where $N$ is the number of samples making up the discrete signal.
However in this case you need to normalize the coefficients by $1 \over N$ for $A_0$ and $A_{N/2}$ and $2 \over N$ otherwise. So I can imagine the reason why $A_0$ is normalized by $1 \over N$ but I am not sure to understand clearly why it is also the case for the last coefficient in the series $A_{N/2}$. Could someone please explain? Thank you very much.