You actually do recover the convolution, but as it is discussed in the comments, there is a normalization issue due to discretization.
According to the documentation, fft
is implemented like this:
$$ A_k = \sum_{m=0}^{n-1} a_m \exp \{ - 2\pi i \frac{mk}{n} \} $$
with $A_k$ being the Fourier-coefficients, $a_m$ the $m$-th element of your signal vector and $n$ the length of the signal.
Squaring this gives you
$$ A_k^2 = \sum_{m=0}^{n-1} \sum_{m'=0}^{n-1} a_m a_{m'} \exp\{ - 2\pi i \frac{(m+m')k}{n} \} \} $$
Now, applying ifft
to the squared Fourier-transform gives you, using the ifft
-definition from the documentation:
$$ \text{ifft}(A_k^2)_{m''} = \frac{1}{n} \sum_{k=0}^{n-1} \sum_{m=0}^{n-1} \sum_{m'=0}^{n-1}a_m \exp\{ - 2\pi i \frac{(m+m'-m'')k}{n} \} \}$$
With the observation, that
$$ \frac{1}{n} \sum_{k=0}^{n-1} \exp\{ - 2\pi i \frac{(m+m'-m'')k}{n} \} = \delta_{m+m', m''} $$
you end up with
$$ \text{ifft}(A_k^2)_{m''} = \sum_{m=0}^{n-1} \sum_{m'=0}^{n-1} a_m a_{m'} \delta_{m+m', m''} = \sum_{m=0}^{n-1} a_m a_{m'' - m}
$$
This is actually how np.convolve
is defined (except for some padding). If you use np.convolve
on your data
, you end up with the same result (except for some padding), so within the numpy
-world, you did exactly what you set out to do, i.e. verify, the convolution property of the Fourier transform. As noted in the comments however, neither fft
nor convolve
"know" anything about your descretization, so you have to take care of that manually by multiplying the results with dt
.
np.fft
computations are correct; what is incorrect is that you expect these computations to give different results. It appears that you trying to verify Fourier transform properties of continuous-time signals by discretizing the latter and applying discrete Fourier transform (FFT). I would not recommend this approach due to subtle but critical differences between the continuous and discrete time domains. $\endgroup$1
, no such notion exists for the discrete-time version. The only "similar" quantity in the discrete-time version is the sum of the sample values, which is equal to50
. However this value will be different if you choose a different sampling period (dt
). $\endgroup$1
. $\endgroup$