I'm going through a chapter on Fourier series, and I've encountered some confusion.
The textbook states the following:
In the context of linear spaces, we can immediately write $f(x) = (a_0, a_1, b_1, \dots, a_n, b_n, \dots)$ is a vector expressed in terms of the orthonormal basis $e = (e_0, e_{\alpha_1}, e_{\beta_1}, \dots, e_{\alpha_n}, e_{\beta_n}, \dots)$, where
$$e_0 = \dfrac{1}{\sqrt{2}},$$ $$e_{\alpha_n} = \cos(nx),$$ $$e_{\beta_n} = \sin(nx)$$
The series $f = \sum_{k = 0}^\infty \langle f,e_k\rangle e_k$, where $e_k, k = 0, \dots$ is a renumbering of the basis vectors. This is the standard expansion of $f$ in terms of the orthonormal basis and is the Fourier series for $f$. Invoking the linear space theory therefore helps us understand how it is possible to express any function piecewise continuous in $[-\pi, \pi]$ as the series expansion
$$f(x) \sim \dfrac{a_0}{\sqrt{2}} + \sum_{n = 1}^\infty (a_n \cos(nx) + b_n \sin(nx)), \ -\pi < x < \pi,$$ where $$a_n = \dfrac{1}{\pi} \int_{-\pi}^\pi f(x)\cos(nx) \ dx,$$ and $$b_n = \dfrac{1}{\pi} \int_{-\pi}^\pi f(x)\sin(nx) \ dx, \ n = 0, 1, 2, \dots$$
The orthonormal basis is $\{ 1/\sqrt{2}, \sin(x), \cos(x), \sin(2x), \cos(2x), \dots \}$.
I am also told the following:
The sequence of functions $\{ 1/\sqrt{2}, \sin(x), \cos(x), \sin(2x), \cos(2x), \dots \}$ form an infinite orthonormal sequence in the space of all piecewise continuous functions on the interval $[-\pi, \pi]$, where the inner product $\langle f, g\rangle$ is defined by $\langle f, g\rangle = \dfrac{1}{\pi} \int^\pi_{-\pi} f \ \bar{g} \ dx$, where the overbar denotes the complex conjugate.
However, I am struggling to expand $f = \sum_{k = 0}^\infty \langle f,e_k\rangle e_k$ to get $f(x) \sim \dfrac{a_0}{\sqrt{2}} + \sum_{n = 1}^\infty (a_n \cos(nx) + b_n \sin(nx)), -\pi < x < \pi$. I would greatly appreciate it if people could please take the time to demonstrate this step-by-step.