While I was learning about Fourier Series I stumbled upon the following Let $f:[0, 2 \pi] \rightarrow \mathbb{C}$. One can calculate the coefficients $c_n$ of the Fourier series of $f$, as follows: (1) $c_k=\frac{1}{2 \pi} \int_0^{2\pi}f(x)e^{-ikx}dx$ (by an orthogonality argument).
In the book I am reading it is mentioned that the interval $[0,2\pi]$ can be easily extended to an interval $(a,b)$, where the coefficients can be calculated as follows: (2) $c_k=\frac{1}{b-a}\int_a^b f(x)e^{-2\pi ik \frac{x}{b-a}} dx$
I don't understand why the formula changed in that way (or how). Would be thankful if someone could show me how this transition works.
Here’s a general definition:
So, more generally, we see that the concept of “Fourier coefficients” relies on having an inner product space, and a specific choice of orthonormal basis. These $f_{\alpha}$ are simply “the components of the vector $f$ along the vector $u_{\alpha}$”, so it is a simple extension of an idea which we’re all familiar with in 3-dimensions, to arbitrary dimensions. Now, with this preliminary general definition out of the way, let’s talk about your example.
First way of describing things (your book)
This is the way your book seems to be doing things.
We shall take $H= L^2([a,b],\frac{1}{b-a}m_{\text{Lebesgue}})$ the space of complex-valued $L^2$ functions with respect to the normalized Lebesgue measure on the interval. The inner product on this space is \begin{align} \langle f,g\rangle&:=\frac{1}{b-a}\int_a^bf(x)\overline{g(x)}\,dx. \end{align} Then, consider the sequence of functions $(u_k)_{k\in\Bbb{Z}}$ given by \begin{align} u_k(x)&=e^{\frac{2\pi i k x}{b-a}}. \end{align} Now, here are some facts:
So, with this, we are perfectly in the situation of the definition above. We can thus calculate, for any $f\in H$, the Fourier coefficients of $f$, relative to this exponential basis, and we get \begin{align} f_k&=\langle f,u_k\rangle=\frac{1}{b-a}\int_a^bf(x)e^{-\frac{2\pi i kx}{b-a}}\,dx. \end{align}
Alternative approach:
In some other texts, you may find things done this way, so I’ll describe it as well. You see, the constant factors are always a pain, and it’s a question of where you want to place the normalization factors.
This time, let’s define $H_1=L^2([a,b])$, with its usual inner product (which one can show forms a Hilbert space, but I won’t do it) \begin{align} \langle f,g\rangle_1&=\int_a^bf(x)\overline{g(x)}\,dx. \end{align} So, we no longer normalize the measure. That has to be taken into account elsewhere, and indeed, now we consider the sequence $(v_k)_{k\in \Bbb{Z}}$, \begin{align} v_k(x)&=\frac{1}{\sqrt{b-a}}e^{\frac{2\pi i k x}{b-a}}. \end{align} Then, you can verify that $(v_k)_{k\in\Bbb{Z}}$ is an orthonormal basis in $H_1$ (i.e rather than having the normalization factor in absorbed in the measure, we put absorb it into the basis).
We once again have a Hilbert space and an orthonormal basis, so we can consider Fourier coefficients: \begin{align} \langle f,v_k\rangle_1&=\int_a^bf(x)\overline{\frac{1}{\sqrt{b-a}}e^{\frac{2\pi i kx}{b-a}}}\,dx=\frac{1}{\sqrt{b-a}}\int_a^bf(x)e^{-\frac{2\pi i kx}{b-a}}\,dx. \end{align}
This is also a perfectly valid way of doing things; it’s a matter of preference.
So, tldr: get yourself a Hilbert space, and an orthonormal basis, and simply look at the “components relative to that basis”, because that is exactly the purpose of Fourier coefficients.