Fourier Transform gives unexpected results: signal reversal and conjugation As far as I understand the math you can reverse a real valued signal by Fourier transformation, taking the complex conjugate of the result and inverse Fourier transformation, i.e.
\begin{equation}
\tag{1}
f(-x) = \mathcal{F}^{-1}(\overline{\mathcal{F}(f(x))})
\end{equation}
where $\mathcal{F}$ is the fourier transformation operation and the overline denotes complex conjugation. This all makes sense and from a mathematical perspective this isn't very useful. However, from a DSP perspective its very useful because the autocorrelation of a signal can be conveniently cast as the convolution of a signal with a time-reversed version of itself. If you're using an FFT convolution it means that you only have to calculate one FFT of the signal.

When I tried to confirm that equation (1) was working in python I found that the result is shifted by one sample. Here's the example code:

import numpy as np
from numpy.fft import rfft, irfft
x = np.arange(128)
y = np.sin(2 * np.pi * x / 128 * 4 + np.pi / 3)
y_rev = y[::-1]
y_rev_fft = irfft(conj(rfft(y)))
plt.plot(y, label="Original Signal")
plt.plot(y_rev, label="Straight Reverse")
plt.plot(y_rev_fft, label="FFT Reverse")




Is this the expected result? If so, can the conjugate still be used in the FFT correlation algorithm I described?

Also, is this question better suited to another stackexchange site?
Try plotting the signal and the straight reversed signal in points rather than lines and you will see that, unlike with reversal via FFT, none of the values stay the same throughout the reversal. The straight reversal flips the 128-long data around index 63.5 or equivalently around index -0.5 if you think of the data as periodic with a period of 128, rather than around index 0 (or 64) as in reversal via FFT.

According to user David Hoffman's tests both

roll(irfft(conj(rfft(y))*rfft(y)), -1)


and

irfft(rfft(y[::-1])*rfft(y))


work for autocorrelation, roll being numpy circular shift.