Solution (source code)

= Solution

Let $F(z)=p(z)/q(z)$. Its only possible finite <poles> are the distinct nonreal roots $\alpha_j$, and the <residue> of $F(z)e^{iz}$ there is $p(\alpha_j)e^{i\alpha_j}/q'(\alpha_j)$; this is zero if the numerator cancels that <pole>. Close the real segment by a positively oriented semicircle in the upper half-plane, where $|e^{iz}|=e^{-\operatorname{Im}z}$ decays.

For sufficiently large radius $R$, all roots lie strictly inside or outside the contour as appropriate, and the degree bound gives $|F(z)|\leq C/R$ uniformly on the arc. Parametrizing by $z=Re^{i\theta}$ bounds the arc integral by
$$
C\int_0^\pi e^{-R\sin\theta}\,d\theta
\leq2C\int_0^{\pi/2}e^{-2R\theta/\pi}\,d\theta\leq\frac{C\pi}{R}\longrightarrow0.
$$
Here $\sin\theta\geq2\theta/\pi$ on $[0,\pi/2]$, and symmetry handles the other half. The <residue theorem> therefore gives
$$
\boxed{\int_{-\infty}^{\infty}\frac{p(x)}{q(x)}e^{ix}\,dx
=2\pi i\sum_{\operatorname{Im}\alpha_j>0}\frac{p(\alpha_j)e^{i\alpha_j}}{q'(\alpha_j)}.}
$$
To justify that this is the ordinary improper integral rather than just its symmetric principal value, note $F(x)=O(|x|^{-1})$ and $F'(x)=O(|x|^{-2})$. On either tail, <integration by parts> writes the integral as a vanishing endpoint term $F(x)e^{ix}/i$ minus an absolutely convergent integral involving $F'$. Thus both one-sided limits exist. When the degree bound is stricter the original integral is already absolutely convergent. This proves the <Fourier integral of a rational function with simple nonreal poles> formula with all tail and arc limits accounted for.