My starting point is cosine on $[0, 2\pi)$ represented by a projection onto the function space with basis
$$ \{ \cos(0), \sin(0), \cos(x), \sin(x), \cos(2x) \sin(2x), ...\} $$
given by
$$ \cos(x) = \sum_{k=0}^\infty \;\langle\cos(x), \cos(kx)\rangle\frac{\cos(kx)}{ \|\cos(kx)\|^2} + \langle\cos(x), \sin(kx)\rangle\frac{\sin(kx)}{\|\sin(kx)\|^2}, $$
where
$$ \begin{align} \langle\cos(x), \cos(kx)\rangle &= \int_0^{2 \pi} \cos(x) \cos(kx) dx \\ &= \left.\frac{\sin((k - 1)x)}{2(k - 1)} + \frac{\sin((k + 1)x)}{2(k + 1)}\right|_0^{2\pi} = 0, \text{if} \; k \neq 1, \end{align} $$
is the inner product, and
$$ \|\cos(kx)\|^2 = \langle\cos(kx), \cos(kx)\rangle = \pi $$
normalizes $\cos(kx)$ terms.
Now, if I use a Riemann approximation
$$ \langle\cos(x), \cos(kx)\rangle \approx \sum_{j=0}^{N-1} \cos(x) \cos(kx) \Delta x, $$
and introduce
$$ x = 2\pi j/N, \; \Delta x = 2\pi / N, $$
I am getting
$$ \sum_{j=0}^{N-1} \cos(x) \cos(kx) \Delta x = 2\pi/N \sum_{j=0}^{N-1} \cos(j2\pi/N) \cos(jk2\pi/N). $$
Due to the following identity
\begin{align} \cos(j2\pi/N) &= \cos(-j2\pi/N) \\ &= \cos(-j2\pi/N + j2\pi) \\ &= \cos(j2\pi(1 - 1/N)) = \cos(j2\pi(N-1)/N) \end{align}
we have that
$$ \sum_{j=0}^{N-1} \cos(x) \cos(x) \Delta x = \sum_{j=0}^{N-1} \cos(x) \cos((N-1)x) \Delta x, $$
which means that the approximated Fourier coefficients $a_1$ and $a_{N-1}$ are the same.
But the function $\cos(x) = 1 \cdot \cos(1 \cdot x)$ should have Fourier coefficients $a_1 = \pi$ and $a_k = 0, k \neq 1$.
The described phenomenon is a direct consequence of the finite approximation of the Fourier coefficients and commonly referred to as aliasing.