# Why there is no $dxdy$ and $\Delta k_x \Delta k_y$ in MATLAB's $\tt fft2()$ & $\tt ifft2()$ functions?

In analytical 2D Fourier Transform, integrand is multiplied by $dxdy$. In algorithm of MATLAB function fft2(), this is not done.

In discrete case, $\Delta x = Lx/Nx$ and $\Delta y = Ly/Ny$ where $Lx,Ly$ are lengths in metres and $Nx,Ny$ are number of samples in $x,y$ directions.

Is it not correct to multiply by $\Delta x \Delta y$ after using fft2() for user function i.e. matrix ?

Similarly for ifft2() function in MATLAB, there is no $\Delta k_x \Delta k_y$ where $\Delta k_x = 1/Lx$ and $\Delta k_y = 1/Ly$

Any help will be appreciated.

• fft and fft2 are discrete Fourier transforms. They are not Reiman sum approximations
– user28715
Jul 26 '17 at 13:05
• Well, one could interpret the DFT as a Riemann sum web.stanford.edu/~ndwork/tutorials/approxDFT.pdf Jul 27 '17 at 11:58

## 2 Answers

The Matlab functions fft,fft2,fftn and their inverses ifft,ifft2,ifftN implement what is called as the Discrete Fourier Transform (DFT) in $1$,$2$ and $N$ dimensions. The mathematical expression for those transforms is:

$$X[k] = \sum_{n=0}^{N-1} x[n] e^{-j \frac{2\pi}{N} n k} ~~~ \text{, for} ~~~ k=0,1,2,...,N-1$$

$$x[n] = \frac{1}{N} \sum_{k=0}^{N-1} X[k] e^{j \frac{2\pi}{N} k n} ~~~ \text{, for} ~~~ n=0,1,2,...,N-1$$

Which is the 1D forward and inverse DFT in particular. Here x[n] is a discrete-time sequence of length $N$ samples and $X[k]$ is a complex valued discrete sequence of length $N$.

Note that the DFT can be considered as the samples of a continuous frequency function (the Discrete-Time Fourier Transform, DTFT) $X(e^{j\omega})$ which is given by: $$X(e^{j\omega}) = \sum_{n=-\infty}^{\infty} x[n] e^{-j \omega n }$$

for which the inverse is: $$x[n] = \frac{1}{2\pi} \int_{-\pi}^{\pi} X(e^{j\omega}) e^{j\omega n} d\omega$$

Note that DFT $X[k]$ is considered to be as the samples of DTFT $X(e^{j\omega })$ and both are operating on the same sequence $x[n]$ (assuming $x[n]$finite length) but produce two different outputs; one of them is a discrete sequence $X[k]$ while the other is a continuous function of $\omega$, $X(e^{j\omega})$.

Furthermore their inverses are the same; $x[n] = \mathcal{IDFT} \{X[k]\}$, $x[n] = \mathcal{IDTFT} \{X(e^{j\omega n})\}$. Hence this might have tempted you to think that the matlab function ifft2 was actually implementing the inverse DTFT by an approximation; which is not the case as it computes the inverse of the DFT which is a finite summation exactly computed in a computer.

A more mundane answer than the good one provided by @Fat32 is that a $dx$ can be thought as an infinitesimal quantity, requiring a continuous extension of the ordinal quantity $x$. For a uniformly sampled signal, the $\Delta x$ is fixed (so it cannot become infinitely small), and often one gets signal amplitudes without the exact sampling period, or the time basis. This is even truer with images, where the pixel dimensions are not given.

Anyway, we can still do DFTs. So you have two options:

• consider a unit inter-sample distance, hence $dx=1$ (somehow),
• consider a unit signal length, hence $dx=1/N$ (and accordingly in more dimensions).

Both $dx=1$ are somehow unitless (no meter, no second).

From these common conventions, one often finds the $dx$ factorized, and a $1/N$ either before the DFT, or before the inverse DFT. Such a factor does not strongly affect the interpretation, as one is often interested in the relative amplitudes at the discrete Fourier frequency bins. The factor will only be a global shift when looked at in a $\log$ domain.

Indeed, normalizations can (should) be more subtle. Being orthonormal, the DFT and its inverse are sometimes both normalized by $1/\sqrt{N}$. Even more, for a real signal, each complex amplitude is shared by a negative and of positive frequency bin, except the mean (DC component) and the Nyquist component, so a little adjustment is required to faithfully represent a precise energy.

As long as you compare signals with the same length and sampling, the normalization does not really matter, as long as it is consistent. Some more care is required otherwise.