Q:

Fourier series for $[x]-x+\frac{1}{2}$

$[x]-x+\frac{1}{2}$ has the Fourier series $$\sum_{n=1}^{\infty} \frac{\sin{2n\pi x}}{n\pi}.$$
By evaluating the series directly, which requires some work, it can be shown that the series is convergent to $[x]-x+\frac{1}{2}$ if $x$ is not an integer.
My question is, do we have any criteria by which we can easily see that 
$$[x]-x+\frac{1}{2}=\sum_{n=1}^{\infty} \frac{\sin{2n\pi x}}{n\pi}$$
when $x$ is not an integer?

A:

The  sum $$g(x)  =  \sum_{n\ge  1} \frac{\sin  2n\pi  x}{n\pi x}$$  is
harmonic and may be evaluated  by Mellin transforms. The base function
is  $$f(x) =  \frac{\sin 2\pi  x}{\pi x}.$$  We may  then recover  the
expansion of $$h(x) = x g(x)$$ by Mellin inversion.
The Mellin transform of the base function $f(x)$ is
$$\mathfrak{M}(f(x); s) =
\int_0^\infty  \frac{\sin 2\pi x}{\pi x} x^{s-1} dx =
\frac{1}{2i} \int_0^\infty  \frac{e^{2\pi i x}-e^{-2\pi i x}}{\pi x} x^{s-1} dx \\
= \frac{1}{2i} \int_0^\infty  \frac{e^{2\pi i x}}{\pi x} x^{s-1} dx 
- \frac{1}{2i} \int_0^\infty  \frac{e^{-2\pi i x}}{\pi x} x^{s-1} dx.$$
Now evaluate the first integral along the square with a vertex at the origin and $(N,N)$ as the opposite vertex. Call the four sides $\Gamma_{1,2,3,4}.$
We get
$$ \left( \int_{\Gamma_1} +  \int_{\Gamma_2} + \int_{\Gamma_3} + \int_{\Gamma_4} \right)
 \frac{e^{2\pi i x}}{\pi x} x^{s-1} dx = 0.$$
Taking limits as $N$ goes to infinity, the integral along $\Gamma_1$ becomes 
$$ \int_0^\infty  \frac{e^{2\pi i x}}{\pi x} x^{s-1} dx,$$
which is the value we are looking to compute. 
Along $\Gamma_2$ we have $x= N+it$
and $$\left| \int_{\Gamma_2} \frac{e^{2\pi i x}}{\pi x} x^{s-1} dx\right| =
\left| \int_0^N \frac{e^{2\pi i (N+it)}}{\pi (N+it)} (N+it)^{s-1} dt\right|
\le \int_0^N \frac{e^{- 2\pi t}}{\pi N} (\sqrt{2} N)^{s-1} dt \\
= \frac{(\sqrt{2} N)^{s-1}}{\pi N} \left[-\frac{e^{-2\pi t}}{2\pi}\right]_0^N =
\frac{(\sqrt{2} N)^{s-1}}{2\pi^2 N} (1- e^{-2\pi N}).$$
The contribution along $\Gamma_2$ vanishes when $\Re(s)<2.$
Along $\Gamma_3$ we have $x= t+iN$
and $$\left| \int_{\Gamma_3} \frac{e^{2\pi i x}}{\pi x} x^{s-1} dx\right| =
\left|- \int_0^N \frac{e^{2\pi i (t+iN)}}{\pi (t+iN)} (t+iN)^{s-1} dt\right|
\le \int_0^N \frac{e^{- 2\pi N}}{\pi N} (\sqrt{2} N)^{s-1} dt \\
= \frac{e^{- 2\pi N}}{\pi} (\sqrt{2} N)^{s-1} .$$
The contribution along $\Gamma_3$ also vanishes, this time with no condition on $\Re(s).$
Along $\Gamma_4$ we have $x= it$
and $$  \int_{\Gamma_4} \frac{e^{2\pi i x}}{\pi x} x^{s-1} dx =
- i \int_0^N  \frac{e^{-2\pi t}}{\pi it} (it)^{s-1} dt =
- \frac{i^{s-1}}{\pi} \int_0^N  \frac{e^{-2\pi t}}{t} t^{s-1} dt.$$
Set $u = 2\pi t$ in this last integral to get
$$ - \frac{i^{s-1}}{\pi} \int_0^{2\pi N} e^{-u} (u/2/\pi)^{s-2}  \frac{1}{2\pi}du =
- \frac{i^{s-1}}{\pi} \frac{1}{(2\pi)^{s-2}} 
\int_0^{2\pi N} e^{-u} u^{s-2} \frac{1}{2\pi}du \\=
- \frac{i^{s-1}}{\pi} \frac{1}{(2\pi)^{s-1}} \Gamma(s-1)$$
in the limit.
This shows that
$$ \int_0^\infty  \frac{e^{2\pi i x}}{\pi x} x^{s-1} dx =
\frac{i^{s-1}}{\pi} \frac{1}{(2\pi)^{s-1}} \Gamma(s-1).$$
Now the second integral in the transform of $f(x)$ is
$$ \int_0^\infty  \frac{e^{-2\pi i x}}{\pi x} x^{s-1} dx$$
and this time we use a square spanned by $(0,0)$ and $(N,-N)$ traversed clockwise.
The two outer segments are treated as in the previous computation. The segment on the imaginary axis has $x=-it$ and yields
$$  \int_{\Gamma_4} \frac{e^{-2\pi i x}}{\pi x} x^{s-1} dx =
- (-i) \int_0^N  \frac{e^{-2\pi t}}{\pi (-it)} (-it)^{s-1} dt =
- \frac{(-i)^{s-1}}{\pi} \int_0^N  \frac{e^{-2\pi t}}{t} t^{s-1} dt.$$
Set $u = 2\pi t$ in this last integral as before to get
$$ - \frac{(-i)^{s-1}}{\pi} \int_0^{2\pi N} e^{-u} (u/2/\pi)^{s-2}  \frac{1}{2\pi}du =
- \frac{(-i)^{s-1}}{\pi} \frac{1}{(2\pi)^{s-2}} 
\int_0^{2\pi N} e^{-u} u^{s-2} \frac{1}{2\pi}du \\=
- \frac{(-i)^{s-1}}{\pi} \frac{1}{(2\pi)^{s-1}} \Gamma(s-1)$$
in the limit.
This shows that
$$ \int_0^\infty  \frac{e^{-2\pi i x}}{\pi x} x^{s-1} dx =
\frac{(-i)^{s-1}}{\pi} \frac{1}{(2\pi)^{s-1}} \Gamma(s-1).$$
Finishing the computation of the Mellin transform we obtain that
$$\mathfrak{M}(f(x); s) =
\frac{1}{\pi} \frac{i^{s-1}-(-i)^{s-1}}{2i} 
\frac{1}{(2\pi)^{s-1}} \Gamma(s-1).$$
But we have
$$ \frac{i^{s-1}-(-i)^{s-1}}{2i} =
\frac{e^{i\pi/2(s-1)}-e^{-i\pi/2(s-1)}}{2i} =
\sin(\pi/2(s-1))$$
so that finally
$$ \mathfrak{M}(f(x); s) = \frac{1}{\pi} \sin(\pi/2(s-1))
\frac{1}{(2\pi)^{s-1}} \Gamma(s-1).$$
Therefore the Mellin transform of $g(x)$ is
$$g^*(s) = \mathfrak{M}(g(x); s) = \frac{1}{\pi} \sin(\pi/2(s-1))
\frac{1}{(2\pi)^{s-1}} \Gamma(s-1) \zeta(s).$$
We may now apply Mellin inversion to obtain the asymptotic expansion.
The Mellin inversion integral is
$$\frac{1}{2\pi i}
\int_{3/2-i\infty}^{3/2+i\infty} g^*(s) \frac{ds}{x^s}.$$
There  are only  two  poles  because the  trivial  zeros  of the  zeta
function  cancel the  poles of  the  gamma function  at negative  even
integers and the sine term cancels the poles at negative odd integers.
Start with the pole at $s=1,$ getting
$$\operatorname{Res}(g^*(s)/x^s; s=1) = \frac{1}{2x}.$$
We also have
$$\operatorname{Res}(g^*(s)/x^s; s=0) = -1.$$
This shows that for $x\in(0,1],$ we have
$$ h(x) = x g(x) = \frac{1}{2} - x.$$
Since $h(x)$ is periodic with period $1$ we certainly have 
$$ h(x) = \frac{1}{2} - (x-[x]) = [x] - x + \frac{1}{2},$$
which was to be shown.
The reader is  invited to check the estimates  along $\Gamma_{2,3}$ of
the Mellin  transform computation, possibly  in an auxiliary  post. As
written the estimates go through for $s$ real.

