Autocorrelation and Spectrum Density Wiener–Khinchin theorem states that autocorrelation function and power spectral density are a Fourier-transform pair - see Wikipidia (and lots of other resources).
That means autocorrelation should be able to be obtained by inverse Fourier transform the spectrum. The following code (run within Octave, with &quot;pkg load signal&quot;) shows the Fourier transform of the autocorrelation DOES look like the spectrum, but the inverse Fourier transform of the spectrum does not look like the autocrrelation. What did I do wrong?
### A signal's autocorrelation and its Engergy Spectral Density are Fourier transform pairs.

###   signal
Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = cos(2*pi*100*t)+randn(size(t));
#plot(x);

###    autocorrelation
Rxx = xcorr(x);
#figure();
plot(Rxx); title(&quot;Rxx&quot;);

###    autocorrelation FT
RxxDftAbs = abs(fftshift(fft(Rxx)));
freq = -Fs/2:Fs/length(Rxx):Fs/2-(Fs/length(Rxx));
figure(); 
plot(freq,RxxDftAbs); title(&quot;RxxDftAbs&quot;);

###    Energy Spectral Density
xdft = abs(fftshift(fft(x)));
x_esd = xdft.^2;   # ESD is the same as autocorrelation FT. Here for visualization purpose, using absolute values.
freq = -Fs/2:Fs/length(x_esd):Fs/2-(Fs/length(x_esd));
figure();
plot(freq,x_esd); title(&quot;x esd&quot;);

### ?????????????
### is it possible to get autocorrelation from the ESD by inverse Fourier transform?
### ?????????????

###    IFT of ESD
x_esd_idft_abs = abs(ifft(fftshift(x_esd)));
figure();
plot(x_esd_idft_abs); title(&quot;x esd ift&quot;);

Thanks in advance.
Fat32's answer is correct and shows a common pitfall.
The reason that you must do this is because recall that the output of the autocorrelation of a signal of length $N$ is $2N - 1$.
You were performing the FFT with the original sample size of $N = 1000$, effectively destroying necessary information to retrieve the autocorrelation of size $2N - 1 = 1999$.