While performing the following (presumably) correct manipulations in Mathematica, I obtain a result that is missing a sign function. Is there a mistake in my code, or is there some bug in Mathematica?

Let’s say we want to reproduce the following Fourier transform in *Mathematica*:

$ $ \frac{1}{\sqrt{2\pi}}\int_{-\infty}^\infty dx \frac{e^{iwx}}{\sin(\pi x)}=\frac{i}{\sqrt{2\pi}}\text{sign}(w)\sum_{n=-\infty}^{\infty}e^{i n(\pi+w)}$ $

The `FourierTransform`

routine is hopeless here, since it never finishes evaluating. That’s not surprising, since the result is an infinite sum without a closed form representation. So we have to try something else.

One way to proceed seems to be to take an anti-derivative

`f = Exp[I x w]/(Sqrt[2 \[Pi]] Sin[\[Pi] x]); F = Assuming[Element[w, Reals], Integrate[f, x]] `

We can readily verify the anti-derivative to be correct:

`D[F, x] // FullSimplify `

`(E^(I w x) Csc[\[Pi] x])/Sqrt[2 \[Pi]]`

We know that anti-derivatives are only useful in analytic regions of functions. In the case of $ e^{i wx}/\sin(\pi x)$ the function is analytic for $ x\in\mathbb{R\backslash\mathbb{Z}}$ , so that we will have to compute

$ $ \begin{align}\tilde{f}(w)&=\lim_{\epsilon\to0^+}\sum_{n\in\mathbb{Z}}(F(n+1-\epsilon)-F(n+\epsilon))\ &=\lim_{\epsilon\to0^+}\sum_{n\in\mathbb{Z}}(F(n-\epsilon)-F(n+\epsilon))\end{align}$ $ (where we shifted the infinite sum by one step in the first term for convenience).

For just a single summand we therefore calculate:

`Assuming[Element[w, Reals] && Element[n, Integers] && 1/10 > \[Epsilon] > 0, Series[(F/.x->n-\[Epsilon]) - (F/.x->n+\[Epsilon]), {\[Epsilon], 0, 0}]//FullSimplify ] `

This summand is almost the correct one! Just an overall factor $ \text{sign}(w)$ is missing, which breaks the Fourier transform and makes our result wrong. I have been trying to find a mistake in my calculation, to see where the sign function was neglected. Unfortunately, it all looks correct to me. Therefore, I’d like to ask if I made a mistake somewhere, or if there is a bug in Mathematica? Thanks for any suggestion!