How to evaluate $\frac{1}{2\pi }\int_{-\pi }^{\pi }\dfrac{\sin n\theta }{\sin\theta }d\theta $? How to evaluate the integral given below?

$$\dfrac{1}{2\pi }\int_{-\pi }^{\pi }\dfrac{\sin n\theta }{\sin\theta }d\theta $$

 A: Note that
$$
\begin{align}
\frac{\sin(n\theta)}{\sin(\theta)}
&=\frac{e^{in\theta}-e^{-in\theta}}{e^{i\theta}-e^{-i\theta}}\tag{1}\\
&=e^{i(n-1)\theta}+e^{i(n-3)\theta}+\cdots+e^{-i(n-3)\theta}+e^{-i(n-1)\theta}\tag{2}\\[4pt]
&=\left\{\begin{array}{}
\small2\cos((n-1)\theta)+2\cos((n-3)\theta)+\dots+2\cos(\theta)&\text{if $n$ is even}\\
\small2\cos((n-1)\theta)+2\cos((n-3)\theta)+\dots+2\cos(2\theta)+1&\text{if $n$ is odd}
\end{array}\right.\tag{3}
\end{align}
$$
where the middle of omitted part of $(2)$ looks like
$$
\dots e^{i3\theta}+e^{i\theta}+e^{-i\theta}+e^{-i3\theta}\dots\tag{4}
$$
when $n$ is even, and
$$
\dots e^{i2\theta}+1+e^{-i2\theta}\dots\tag{5}
$$
when $n$ is odd.
For non-zero $k\in\mathbb{Z}$,
$$
\int_{-\pi}^\pi\cos(k\theta)\,\mathrm{d}\theta=0\tag{6}
$$
Therefore,
$$
\frac1{2\pi}\int_{-\pi}^\pi\frac{\sin(n\theta)}{\sin(\theta)}\,\mathrm{d}\theta
=\left\{\begin{array}{}
0&\text{if $n$ is even}\\
1&\text{if $n$ is odd}
\end{array}\right.\tag{7}
$$
A: Since the integrand is $ 2 \pi$-periodic,
$$ \begin{align} \frac{1}{2\pi } \int_{-\pi }^{\pi } \frac{\sin n\theta }{\sin\theta } \ d\theta &= \frac{1}{2 \pi} \int_{-\pi/2}^{3 \pi/2} \frac{\sin n \theta}{\sin \theta} \ d \theta \\ &=\frac{1}{2 \pi} \int_{-\pi/2}^{3 \pi/2} \text{Im} \frac{e^{in \theta}}{\sin \theta} \ d \theta \\ &= \frac{1}{2\pi} \text{Im} \ \text{PV} \int_{-\pi/2}^{3 \pi /2} \frac{e^{in \theta}}{\sin \theta \ } \ d \theta \tag{1} \\ &= \frac{1}{\pi} \text{Im} \ i \ \text{PV} \int_{-\pi/2}^{3 \pi /2} \frac{e^{in \theta}}{e^{i \theta}-e^{-i \theta}} \ d \theta . \end{align} $$
Now let $z=e^{i \theta}$.
Then
$$ \begin{align} \frac{1}{2\pi } \int_{-\pi }^{\pi } \frac{\sin n\theta }{\sin\theta } \ d\theta &= \frac{1}{\pi} \text{Im}\ i \ \text{PV} \int_{|z|=1} \frac{z^{n}}{z-z^{-1}}\frac{dz}{iz} \\ &= \frac{1}{\pi} \text{Im} \ \text{PV} \int_{|z|=1} \frac{z^{n}}{z^{2}-1} \ dz  \end{align}$$
where the unit circle is indented around the simple poles at $z=1$ and $z=-1$.
Therefore,
$$ \frac{1}{2\pi } \int_{-\pi }^{\pi } \frac{\sin n\theta }{\sin\theta } \ d\theta=  \frac{1}{\pi } \text{Im} \left(i \pi \ \text{Res} \left[\frac{z^{n}}{z^{2}-1},1 \right] + i \pi \ \text{Res} \left[\frac{z^{n}}{z^{2}-1},-1 \right]\right) .$$
If $n=2k+1$ (that is, if $n$ is odd),
$$ \frac{1}{2\pi }\int_{-\pi }^{\pi }\frac{\sin (2k+1)\theta }{\sin\theta } \ d\theta = \frac{1}{\pi } \text{Im} \left[i \pi \left(\frac{1}{2} \right) +i \pi \left(\frac{1}{2} \right) \right] = 1.$$
And if $n=2k$,
$$ \frac{1}{2\pi }\int_{-\pi }^{\pi } \frac{\sin 2k \theta }{\sin\theta } \ d\theta = \frac{1}{\pi } \text{Im} \left[i \pi \left(\frac{1}{2} \right) +i \pi \left(-\frac{1}{2} \right) \right] = 0 .$$
$ $
$(1)$ On the interval $[- \frac{\pi}{2}, \frac{3 \pi}{2} ]$, $\frac{e^{in \theta}}{\sin \theta}$ has a simple pole at $0$ and a simple pole at $\pi$.
A: Let $I_n = \dfrac1{2\pi} \displaystyle\int_{-\pi}^{\pi} \dfrac{\sin(nx)}{\sin(x)}dx$. We then have
\begin{align}
I_{n+2} - I_n & = \dfrac1{2\pi} \int_{-\pi}^{\pi} \dfrac{\sin((n+2)x)-\sin(nx)}{\sin(x)}dx = \dfrac1{2\pi} \int_{-\pi}^{\pi} \dfrac{2\sin(x) \cos((n+1)x)}{\sin(x)}dx\\
& = \dfrac1{\pi}\int_{-\pi}^{\pi} \cos((n+1)x)dx
\end{align}
Assuming $n \neq -1$ and is an integer, we get $I_{n+2} - I_n = 0$. Hence, $I_{2k} = I_0$ and $I_{2k-1} = I_1$, where $k \in \mathbb{Z}^+$.
We have $I_0 = 0$ and $I_1 = 1$. Hence, $I_{2k} = 0$ and $I_{2k-1} = 1$, where $k \in \mathbb{Z^+}$. For negative $n$, note that $I_{-n} = -I_n$
A: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
$\ds{{1 \over 2\pi }\int_{-\pi}^{\pi}{\sin\pars{n\theta} \over \sin\pars{\theta}}
\,\dd\theta:\ {\large ?}}$

When $\ds{n = 0}$, the integral vanishes out. Then, let's consider the case $\ds{n \not= 0}$:
  \begin{align}
&\color{#c00000}{{1 \over 2\pi }\int_{-\pi}^{\pi}
{\sin\pars{n\theta} \over \sin\pars{\theta}}\,\dd\theta}
={\sgn\pars{n} \over 2\pi }\int_{-\pi}^{\pi}
{\sin\pars{\verts{n}\theta} \over \sin\pars{\theta}}\,\dd\theta
\\[3mm]&={\sgn\pars{n} \over 2\pi}\,
\oint_{\verts{z}\ =\ 1 \atop
      {\vphantom{\Huge A}0\ <\ \verts{{\rm Arg}\pars{z}\ <\ \pi}}}
{\pars{z^{\verts{n}} - z^{-\verts{n}}}/\pars{2\ic} \over \pars{z - z^{-1}}/\pars{2\ic}}
\,{\dd z \over \ic z}
\\[3mm]&=-\ic\,{\sgn\pars{n} \over 2\pi}\oint_{\verts{z}\ =\ 1 \atop
{\vphantom{\Huge A}0\ <\ \verts{{\rm Arg}\pars{z}\ <\ \pi}}}
{1 \over z^{\verts{n}}}\,{1 - z^{2\verts{n}} \over 1 - z^{2}}\,\dd z
\\[3mm]&=-\ic\,{\sgn\pars{n} \over 2\pi}\,2\pi\ic\,{1 \over \pars{\verts{n} - 1}!}
\lim_{z \to 0}\totald[\verts{n} - 1]{}{z}
\bracks{1 - z^{2\verts{n}} \over 1 - z^{2}}
\end{align}

$$\color{#c00000}{{1 \over 2\pi }\int_{-\pi}^{\pi}
{\sin\pars{n\theta} \over \sin\pars{\theta}}\,\dd\theta}
=\sgn\pars{n}\,{1 \over \pars{\verts{n} - 1}!}
\color{#00f}{\lim_{z \to 0}\totald[\verts{n} - 1]{}{z}
\bracks{1 - z^{2\verts{n}} \over 1 - z^{2}}}
$$
When $\ds{n}$ is even the integral vanishes out since
$\ds{1 - z^{2\verts{n}} \over 1 - z^{2}}$ is an even function of $\ds{z}$. When $\ds{n}$ is odd, the right hand side can be evaluated by means of a expansion in powers of $\ds{z}$:
\begin{align}
&\left.{1 - z^{2\verts{n}} \over 1 - z^{2}}\,\right\vert_{\,\verts{z}\ <\ 1}
=\sum_{k = 0}^{\infty}z^{2k} - \sum_{k = 0}^{\infty}z^{2\verts{n} + 2k}
=\sum_{k = 0}^{\infty}z^{2k} - \sum_{k = \verts{n}}^{\infty}z^{2k}
=\sum_{k = 0}^{\verts{n} - 1}z^{2k}
\\[3mm]&=\sum_{k = 0}^{\verts{n} - 2}z^{2k}
+\color{#00f}{\large\pars{\verts{n} - 1}!}\,
{z^{\verts{n} - 1} \over \pars{\verts{n} - 1}!}\,,\qquad n\ \mbox{odd}
\end{align}

$$
\color{#66f}{\large{1 \over 2\pi }\int_{-\pi}^{\pi}
{\sin\pars{n\theta} \over \sin\pars{\theta}}\,\dd\theta
=\left\lbrace\begin{array}{lcl}
\sgn\pars{n} & \mbox{if} & n\ \mbox{is odd}
\\
0 & \mbox{if} & n\ \mbox{is even}
\end{array}\right.}
$$

A: Assume $n=2k+1$ is odd, so the integral is, by taking $t\to t/2$ $$\int_0^{\pi}\frac{\sin((2k+1)t)}{\sin t}dt= \int_0^{\pi/2}\frac{\sin(k+\frac 1 2)t}{2\sin \frac t 2}dt$$
The integrand is half of the Dirichlet kernel, which equals thus $$\frac 1 2 +\sum_{j=1}^k \cos jt$$
and makes the evaluation easy. 
