Closed form of the function i've a function $h_j(x) =1/N\sum _{k=-N/2}^{N/2}1/c_k e^{ik(x-x_j)}$ where N is even and $c_k = 1$ when $k = -N/2 +1, ..., N/2 -1$and $c_k = 2$ when $k = -N/2, N/2$ i'm unable to calculate the closed form of $h_j(x)$ i.e
$h_j(x)= 1/N Sin [N/2 (x-x_j)]Cot[1/2 (x-x_j)]$ kindly help me in calculating thos closed form.
 A: Just to simplify, let's put $N = 2\,n$ and $x - x_{\,j}  = t$.
Then
$$
\eqalign{
  & h_{\,j} (t) = {1 \over {2n}}\sum\limits_{ - n\, \le \,k\, \le \,n} {{1 \over {c_{\,k} }}e^{\,i\,k\,t} }  =   \cr 
  &  = {1 \over {2n}}\left( {\sum\limits_{ - n + 1\, \le \,k\, \le \,n - 1} {e^{\,i\,k\,t} }  + \left( {{{e^{\, - \,i\,n\,t}  + e^{\,i\,n\,t} } \over 2}} \right)} \right) =   \cr 
  &  = {1 \over {2n}}\left( {e^{\, - \,i\,\left( {n - 1} \right)\,t} \sum\limits_{0\, \le \,k\, \le \,2n - 2} {e^{\,i\,k\,t} }  + \left( {{{e^{\, - \,i\,n\,t}  + e^{\,i\,n\,t} } \over 2}} \right)} \right) =   \cr 
  &  = {1 \over {2n}}\left( {e^{\, - \,i\,\left( {n - 1} \right)\,t} {{1 - e^{\,i\,\left( {2n - 1} \right)\,t} } \over {1 - e^{\,i\,t} }} + {{e^{\, - \,i\,n\,t}  + e^{\,i\,n\,t} } \over 2}} \right) =   \cr 
  &  = {1 \over {2n}}\left( {{{e^{\, - \,i\,\left( {n - 1} \right)\,t}  - e^{\,i\,n\,t} } \over {1 - e^{\,i\,t} }} + {{e^{\, - \,i\,n\,t}  + e^{\,i\,n\,t} } \over 2}} \right) =   \cr 
  &  = {1 \over {2n}}\left( {{{2\,e^{\, - \,i\,\left( {n - 1} \right)\,t}  - 2\,e^{\,i\,n\,t}  + e^{\, - \,i\,n\,t}  + e^{\,i\,n\,t}  - e^{\, - \,i\,\left( {n - 1} \right)\,t}  - e^{\,i\,\left( {n + 1} \right)\,t} } \over {2\left( {1 - e^{\,i\,t} } \right)}}} \right) =   \cr 
  &  = {1 \over {2n}}\left( {{{\, - e^{\,\,i\,\,t} \left( {e^{\,i\,n\,t}  - e^{\, - \,i\,n\,t} } \right) - \left( {e^{\,i\,n\,t}  - e^{\, - \,i\,n\,t} } \right)\,} \over {2\left( {1 - e^{\,i\,t} } \right)}}} \right) =   \cr 
  &  = {1 \over {2n}}\left( {{{e^{\,i\,n\,t}  - e^{\, - \,i\,n\,t} } \over 2}{{\,e^{\,\,i\,t}  + 1\,} \over {e^{\,i\,t}  - 1}}} \right) \cr} 
$$
