Verifying the Indictor Function:$X_{[a,b]}$ can be expressed as a Fourier Series? In the text "Fourier Analysis: An Introduction" by Elias M. Stein and Rami Shakarchi. I'm having trouble attempting to verify the that $f(x)$ can be written as a Fourier Series in $\text{Proposition (1.2)}$ Note my initial approach to verify $\text{Proposition  (1.2)}$ can be seen within, $\text{Lemma (1.3)}$
$\text{Proposition  (1.2)}$:
Let $f(x) \, = X_{[a,b]}(x)$ be the Characteristic Function of the interval $[a,b] \subset [-\pi,\pi]$ this can be fully expressed as the following.
$$
   X_{[a,b]}(x) = \left\{
     \begin{array}{lr}
       1 &  if\, \, \, \, \,  \, x \in [a,b]\\
       0 &  if \, \, otherwise
     \end{array}
   \right.
$$
The Fourier series of $f$ is given in $(1.)$
$(1)$
$$  \, \, \, \, \, \, f(x)=X_{[a,b]} \sim \frac{b-a}{2 \pi} \, + \, \sum_{n \neq 0}^{\infty} \frac{e^{-ina}-e^{-inb}}{2 \pi in}e^{inx}.$$
$\text{Lemma (1.3)}$
$\text{Definition (2.1)}$
If the function $f$ is an integrable function on the interval $[-\pi,\pi]$, then the $n^{th}$ Fourier coefficient of $f$ can be written as:
$$f(n)=a_n = \frac{1}{2 \pi}\int_{-\pi}^{\pi}f(\theta)e^{in\theta}d \theta.$$
$\text{Definition (2.2)}$
The Fourier series of function $f$ given in the case our integrable function lies on the interval $[-\pi,\pi]$ is:
$$f(\theta)\sim \sum_{n=-\infty}^{\infty}a_ne^{in\theta}.$$
For integrating a product of two functions defined as the following for the case of definite integrals:
$$\int_{a}^{b}u(x) \cdot v'(x)dx = (u(b) \cdot v(b) -u(a) \cdot v(a))-\int_{a}^{b}v(x) \cdot u'(x)dx.$$
By $\text{Definition (2.1)}$, our function $f(x)=X_{[a,b]}(x)$ can be written as the following Fourier coefficient:
$$X_{[a,b]}(x)=\frac{1}{2 \pi}\int_{-\pi}^{\pi}f(\theta)e^{in\theta}d \theta.$$
Since our function $f$ now has a Fourier coefficient it can be written as the following Fourier Series:
$$f(\theta) \sim \sum_{n=-\infty}^{\infty}((\frac{1}{2 \pi}\int_{-\pi}^{\pi}f(\theta)e^{in\theta}d \theta((e^{2 \pi inx/-\pi -pi)})).$$
Direct calculations on the integral by utilization of $IBP$ yield if $n \neq 0$:
$$\frac{1}{2 \pi}\int_{-\pi}^{\pi}f(\theta)e^{in\theta}d \theta = \frac{1}{2 \pi}\Bigg[ \frac{\theta}{in}e^{in\theta}\Bigg]_{-\pi}^{\pi}+\frac{1}{2 \pi in} \int_{-\pi}^{\pi}e^{in\theta}d\theta=\frac{(-1)^{n+1}}{in}.$$
and since $n \neq 0$ our Fourier Coefficient becomes:
$$f(0)=\frac{1}{2 \pi}\int_{-\pi}^{pi}\theta d\theta = 0.$$
Now our initial Fourier Series for our function $f$ is now:
$$f(\theta) \sim \sum_{n=0}^{\infty}\frac{(-1)^{n+1}}{in}e^{in\theta}e^{2\pi inx/b-a}).$$
My initial question specifically is how to show that the series in $(3.1)$ can be written as the series in $(3.2)$
$(3.2)$
$$ \, \, \, f(x)=X_{[a,b]} \sim \frac{b-a}{2 \pi} \, + \, \sum_{n \neq 0}^{\infty} \frac{e^{-ina}-e^{-inb}}{2 \pi in}e^{inx}.$$

As I recall, Stein and Shakarchi use the notation
$f$ ~ $\sum_n a_n e^{inx}$ to denote that the series on the right is the Fourier series of the function on the left?  This notation doesn't imply anything about equality or convergence of that series; it's a formal expression.  So what you really want to do is calculate the Fourier coefficients for $\chi_{[a,b]}$.
$a_0 = \frac{1}{2\pi} \int \chi_{[a,b]} = \frac{1}{2\pi} \int_a^b 1 = \frac{b-a}{2\pi}$
For $n \neq 0$,
$a_n = \frac{1}{2\pi} \int_a^b e^{-inx} dx = \frac{i}{2n\pi}(e^{-inb}-e^{-ina})$, which is what you wanted to show.
