> [!NOTE]
> Let $\phi \in C^0([-\pi,\pi],\mathbb{C})$. Let $\hat{\phi}(k):=\frac{1}{2\pi}\int_{-\pi}^{\pi}\phi(x)e^{-ikx}\;dx$ be the [[Fourier Transform|Fourier coefficients]]. Then $c_{k}=\hat{\phi}(k)$ minimises $(c_{-n},\dots,c_{n})\mapsto \int_{-\pi}^\pi \left\lvert \phi(x) - \sum_{k=-n}^n c_{k}e^{ikx} \right\rvert^2 \; dx $among all possible choices of complex coefficients $c_{-n},\dots,c_{n}$ where $|\cdot|$ denotes complex modulus and $C^0$ denotes [[Continuous Differentiability|C-0 functions]]. Furthermore, the error is given by $\int_{-\pi}^\pi \left\lvert \phi(x)- \sum_{k=-n}^n \hat{\phi}(k)e^{ikx} \right\rvert^2 \, dx = \int_{-\pi}^\pi \lvert \phi(x) \rvert^2 \,dx - 2\pi \sum_{k=-n}^n \lvert \hat{\phi}(k) \rvert^2 \tag{1}$
###### Proof \[MA265\]:
Given any coefficients $c_{k}\in \mathbb{C}$, [[Complex exponentials form orthonormal basis of square-integrable functions on (-pi, pi)]] yields $\begin{aligned}
E_n & :=\int_{-\pi}^\pi\left|\phi(x)-\sum_{|k| \leq n} e^{i k x} c_k\right|^2 d x \\
& =\int_{-\pi}^\pi\left(\phi(x)-\sum_{|k| \leq n} e^{i k x} c_k\right)\left(\overline{\phi(x)}-\sum_{|k| \leq n} e^{-i k x} \overline{c_k}\right) d x \\
& =\int_{-\pi}^\pi|\phi(x)|^2 d x -\sum_{|k| \leq n} \overline{c_k} \int_{-\pi}^\pi \phi(x) e^{-i k x} d x -\sum_{|k| \leq n} c_k \int_{-\pi}^\pi \overline{\phi(x)} e^{i k x} d x +\sum_{|k|,| | \leq n} c_k \overline{c_l} \int_{-\pi}^\pi e^{i(k-l) x} d x \\
& =\int_{-\pi}^\pi|\phi(x)|^2 d x-\sum_{|k| \leq n} \overline{c_k} 2 \pi \hat{\phi}(k)-\sum_{|k| \leq n} c_k 2 \pi \overline{\hat{\phi}(k)}+\sum_{|k| \leq n} 2 \pi c_k \overline{c_k} .
\end{aligned}$Adding and subtracting $2 \pi \sum_{|k| \leq n}|\hat{\phi}(k)|^2$ yields$\begin{aligned}
E_n & =\int_{-\pi}^\pi|\phi(x)|^2 d x+2 \pi \sum_{|k| \leq n}\left(c_k \overline{c_k}-\overline{c_k} \hat{\phi}(k)-c_k \overline{\hat{\phi}(k)}+\hat{\phi}(k) \overline{\hat{\phi}(k)}\right)-2 \pi \sum_{|k| \leq n}|\hat{\phi}(k)|^2 \\
& =\int_{-\pi}^\pi|\phi(x)|^2 d x-2 \pi \sum_{|k| \leq n}|\hat{\phi}(k)|^2+2 \pi \sum_{|k| \leq n}\left|c_k-\hat{\phi}(k)\right|^2
\end{aligned}$
The last expression shows that $E_n$ is minimal if and only if $c_k=\hat{\phi}(k), k=-n, \ldots, n$. The identity $(1)$ then follows immediately.
A consequence of the identity $(1)$ is [[Bessel's Inequality|Bessel's inequality]]: $2 \pi \sum_{k \in Z}|\hat{\phi}(k)|^2 \leq \int_{-\pi}^\pi|\phi(x)|^2 d x$Furthermore, we see that **if** $\lim _{n \rightarrow \infty} \int_{-\pi}^\pi\left|\phi(x)-S_n(\phi)(x)\right|^2=0$**then** $\frac{1}{2\pi} \int_{-\pi}^\pi|\phi(x)|^2 d x= \sum_{k \in \mathcal{Z}}|\hat{\phi}(k)|^2$
which is known as [[Squared Norm of a Vector is equal to the sum of the Squares of its projections onto an orthonormal basis (Parseval's Equality)|Parseval's equality]].