# FFTW small difference for r2c ?

Started by January 20, 2009
```Hello,

I am using FFTW v3.2 in C++ to compute the 3d DFT of a real image. I
use the FFT as part of an iterative algorithm in which high accuracy is a
must, so I checked the outputs of the FFTW and found some very small
difference depending on whether I used the r2c or not. By small difference
I mean about a 17% increase in numerical error versus by the traditional
error.  In pseudo-code, if I compute:

b = fft(a);
c = fft_r2c(a);

a2 = ifft(b);
a3 = ifft_c2r(c);

e1 = sum( abs( a - a2));
e2 = sum( abs( a - a3));
e3 = sum( abs( a2 - a3));

Then e2 is greater than e1 by about 17%, and e3 is not equal to zero.
E.g., e1 is around 10^(-5) when divided by the number of elements.

I would expect the output of the FFTW code to be numerically
identical. And indeed I find that it is if I do not use r2c. That is, again
in pseudo-code, if I compute:

b = fft(a);
c = fft(a);

a2 = ifft(b);
a3 = ifft(c);

e1 = sum( abs( a - a2));
e2 = sum( abs( a - a3));
e3 = sum( abs(a2 - a3));

Then of course e1 = e2 and e3 = 0.

So my question is: has anyone heard of this before? Is the output of
FFTW slightly different for r2c?