How can one expand the function $f_1(x) = x$ on $(−π, π)$in terms of the functions $\cos nx, n = 0, 1, 2, ...$ and $\sin nx, n = 1, 2, ...,$ I read the below function - $$f_2(x) = a_0 + \sum_{n=1}^{\infty}(a_n \cos nx + b_n \sin nx)$$
is the expansion of the $f_1$, how is that?
Main Question:
Is $f_1$ equivalent to $f_2$ in some way? If so, plz provide a detail proof which is easily comprehensible.
I have attached the excerpt below -

As already mentioned in the comments, this is known as a Fourier series. The set of square-integrable functions forms an infinite dimensional vector space called $L^2$-space:
$$L^2[-\pi, +\pi] =\bigg\{f\colon[-\pi, +\pi]\to\mathbb R \biggm\vert \int\limits_{-\pi}^{+\pi} \!\! |f(x)|^2 dx < \infty \bigg\}$$
In fact, it is even a Hilbert space with the inner product
$$ \langle f, g\rangle_{L^2[-\pi, +\pi]} = \int\limits_{-\pi}^{+\pi} \!\!f(x)g(x) d x$$
which induces the norm $\|f\|_{L^2[-\pi, +\pi]}^2 = \langle f, f\rangle_{L^2[-\pi, +\pi]}$. The above is not 100% correct, there is a technicality involved that needs to be accounted for: one needs to "mod out" functions that are equal w.r.t. the $L^2$-norm. For example, consider the functions $f(x) = 0$ and $g(x) = \begin{cases}1:x=0\\0:x\neq 0\end{cases}$. Here $\|f-g\|=0$, since the functions only differ on a set of measure zero. However, for $L^2$ to be a proper normed vector-space, we need $\|h\|=0 \iff h=0$. Therefore, we need to identify functions with each other whenever their $L^2$ distance is zero. (Alternatively, one can use the completion of the space of square integrable continuous functions)
With this in mind, we can do Linear Algebra in $L^2$, in particular we can construct orthogonal basis (which are sometimes called Schauder basis in the case of infinite dimensional vector spaces) and express functions in terms of these bases. And this is exactly what the Fourier Series does! The functions $f_1$ and $f_2$ are then equivalent in the $L^2$ sense:
$$ \lim_{N\to\infty}\bigg\|f_1(x) - \sum_{n=1}^N \big(a_n \cos(nx) + b_n\sin(nx)\big)\bigg\| = 0$$