# Understanding the multiply by 2 factor in scaling the DFT magnitude

I have seen a number of answers on various forums for why we need to scale the magnitude of DFT output by 2 (e.g. 1) to account for discarding negative frequencies, or 2) due to the 2 in the denominator of the exponential form of sine and cosine). However, as far as I can tell these are not the root reason for this, and rather it seems to be due to the orthogornality of sine and cosine.

1) We need to account for discarding negative frequencies, and so double out magnitude spectrum.

I don't think this can be correct, because the DFT formula is for a single frequency - it has no 'knowledge' if we keep the negative frequencies or not.

$$X(m) = \sum_{n=0}^{N-1}x(n)e^{-i2\pi n/N}$$ This would imply half of the signal magnitude is lost to the negative frequency component in the calculation. However, this cannot be the case as frequencies are calculated in isolation i.e. calculating $$X(1)$$ has no influence on $$X(-1)$$. The replicate frequencies are just exact replications of the orignal frequency content, due to ambiguity caused by discrete sampling. If the magnitude of the original signal did not need to be scaled by 2, this would also be the case for the replications.

2) It is due to the denominator of the exponential form of sine and cosine.

$$\sin(x) = \frac{e^{ix} - e^{-ix}}{2i}$$

$$\cos(x) = \frac{e^{ix} + e^{-ix}}{2}$$ Here, the denominator scaling is used to correct the magnitude of sine and cosine phasor components of the DFT complex exponential after addition (cos) or subtraction (sin). Without this denominator scaling, the magnitude of the DFT complex exponential $$e^{-i 2\pi m n/N}$$ could exceed 1 (e.g. when $$x=0$$). This doesn't seem to influence the magnitude of the output, in fact, it ensures it is not distorted. 3) The scaling factor is due to splitting our signal across sine and cosine, two orthogornal functions, and summing the output.

Taking the FFT of a sine wave at frequency $$m$$, the short proof of the correct magnitude scaling below relies on sine and cosine orthogonality. Because one of the components goes to zero, we always loose half our signal.

$$\begin{gather*} X(m) = \sum_{n=0}^{N-1} x(n) e^{-i2\pi m n/N} \\ \theta = 2 \pi m n / N \\ x(n) = M\sin{\theta} \\ \\ X(m) = \sum_{n=0}^{N-1} M\cos{\theta} \sin{\theta} - i M\sin^2{\theta} \end{gather*}$$ The first term goes to zero due to orthogonality property of sine and cosine $$\begin{gather*} X(m) = - i \sum_{n=0}^{N-1} M\sin^2{\theta} \\ X(m) = - i \sum_{n=0}^{N-1} M\frac{(1 - \cos(2\theta))}{2} \\ X(m) = - i \frac{1}{2} \sum_{n=0}^{N-1} M - i \frac{1}{2} \sum_{n=0}^{N-1} M\cos(2\theta) \\ \end{gather*}$$ The second term goes to zero as we are integrating over $$2\pi m n/N$$. $$M$$ is the magnitude of the original sine wave we are trying to recover.

$$\begin{gather*} X(m) = - i \frac{1}{2} \sum_{n=0}^{N-1} M \\ X(m) = 0 - i\frac{1}{2} MN \\ |X(m)| = \sqrt{(-\frac{1}{2} MN)^2} = \frac{1}{2} MN \\ \frac{2|X(m)|}{N} = M \\ \end{gather*}$$

To me, this seems to indicate the need to double $$|X(m)|$$ falls out of the orthogornality property, rather than the above reasons (1) or (2).

• I think your initial premise is wrong. We certainly DON'T have to double the magnitude of the DFT and I almost never do. Occasionally it's useful if you do power spectral analysis but in most other cases, you really don't. Can you provide a reference or a specific application where you think doubling is required ? Feb 9 at 22:21

Scaling is indeed done for the first two reasons, and the scaling chosen is based on what units we want the output of the DFT to represent. The analysis for the OP's item (3) is incomplete, leading to an inaccurate conclusion.

When (and only when) the time domain signal is real, the spectral is Hermitian symmetric in which case we can discard the negative frequencies and double the magnitude of the positive frequencies for the representation of a single sided spectrum. This is considered for example in representing $$A\cos(\omega_c t+\phi)$$ with a double sided spectrum versus a single sided spectrum.

For the case of being double sided: each component is coefficient of an $$e^{j\omega t}$$ and the waveform is given as: $$\frac{A}{2} e^{j(\omega_c + \phi)} + \frac{A}{2}e^{-j(\omega_c - \phi)}$$

With that in the magnitude spectrum we would see an impulse at $$-\omega_c$$ with magnitude $$A/2$$ and another at $$\omega_c$$ with magnitude $$A/2$$. If we wanted the DFT to match this, we could scale the DFT by multiplying by $$1/N$$.

For the case of being single sided: each component is coefficient of an $$\cos(\omega t)$$ and the waveform is given as $$A\cos(\omega_c t+\phi)$$. If we wanted the DFT to match this, we could drop the negative frequencies and scale the DFT by multiplying by $$2/N$$.

If we want the DFT to represent other units, we can scale differently as long as we're clear as to what we are doing and why.

The analysis for the OP's item (3) is incomplete, leading to an inaccurate conclusion. If further detailed, it is another example of the previous two points already given: The OP has considered only one particular bin in the DFT for a real sinusoid, and confirmed similar to the expression of a sine as a weighted sum of the exponential function that each of those weights would be half:

$$sin(x) = \frac{-j}{2}e^{jx}+\frac{j}{2}e^{-jx}$$

Consistent with this, for a real sinusoid there will be two bins where the signal also exists as a non-zero value (when we use an integer number of samples in one cycle of the sinusoid), so it is not at all "lost". The DFT simply reports the values for the coefficients of $$e^{jx}$$, not coefficients of sinusoids: Through the correlation process, the DFT determines for each $$k$$ the amount of each $$e^{jk\omega_o n}$$ in our time domain waveform $$x[n]$$. We can of course choose to describe $$e^{jx}$$ in terms of sines and cosines, as I will show below, in which case the DFT determines for each $$k$$ the amount of $$\cos(k\omega_o n) + j\sin(k\omega_o n)$$ in our time domain waveform $$x[n]$$ (same thing, but more cumbersome).

Consider the DFT given as:

$$X(k) = \sum_{n=0}^{N-1} x[n]e^{-jk\omega_o n} \label{1} \tag{1}$$

Where $$\omega_o$$ is the frequency associated with the first bin as $$\omega_o = 2\pi/N$$

$$x[n]$$ is NOT necessarily a real signal, but can be a complex waveform with real and imaginary components expressed as $$I[n]+jQ[n]$$

$$e^{j\omega_o n}$$ can be expressed with its real and imaginary components as sines and cosines using Euler's formula as:

$$e^{j\omega_o n} = \cos(\omega_o n)+j\sin(\omega_o n)$$

Thus the full complex product that is summed in the DFT would be:

$$x[n]e^{-jk\omega_o n} = (I[n]+jQ[n])(\cos(k\omega_o n)-j\sin(k\omega_o n))$$

$$=\bigg(I[n]\cos(k\omega_o n) + Q[n]\sin(k\omega_o n))\bigg) + j\bigg(I[n]\sin(k\omega_o n) - Q[n]\cos(k\omega_o n)\bigg) \tag{2} \label{2}$$

For the case when $$x[n]$$ is real, such that $$x[n]=I[n]$$ the result would properly reduce to:

$$I[n]\cos(k\omega_o n)+jI[n]\sin(k\omega_o n) \tag{3} \label{3}$$

Further and more significantly, no signal is "lost". When $$x[n]$$ is a sine wave as the OP gave in the example, the result would produce non-zero values at two different values of $$k$$ for $$k\omega_0$$, each scaled by half (assuming sampling by an integer multiple frequency such that the sine is on bin center). These values would be associated with the equivalent positive and negative frequency components when the sine wave is expressed in exponential form. The DFT itself is telling us as a correlation all the components of the form $$e^{jk\omega_o n}$$ that are in our waveform $$x[n]$$. When $$x[n]$$ is alternatively a single exponential frequency such as $$x[n]=e^{jk\omega_0}$$, the DFT will produce a single non-zero value at one bin given by $$k$$.

A specific example will help to illustrate this. Consider $$x[n] = \sin(2\omega_o n)$$. We could multiply out the complex product in the DFT given in \ref{1} with sines and cosines as demonstrated in \ref{3} for the case of a real waveform, or directly in exponential form as follows:

$$X(k) = \sum_{n=0}^{N-1}x[n]e^{-jk\omega_o n} = \sum_{n=0}^{N-1}\sin(2\omega_o n)e^{-jk\omega_o n}$$

$$=\sum_{n=0}^{N-1}(-0.5je^{j2\omega_o n}+0.5je^{-j2\omega_o n})e^{-jk\omega_o n}$$

Note specifically when we compute the DFT for $$k=2$$ we get the result and conclusion the OP reached more directly:

$$X(2) = \sum_{n=0}^{N-1}=(-0.5je^{j2\omega_o n}+0.5je^{-j2\omega_o n})e^{-j2\omega_o n}$$

$$= \sum_{n=0}^{N-1}(-0.5j+0.5je^{-j4\omega_o n})$$

The second term in the summation goes to $$0$$ since $$\omega_o = 2\pi/N$$, so the result is simply $$X(2) = -0.5Nj$$

If we stopped here, it may appear that we have lost half of the signal because one of the components went to 0. No, that is not the case; we've simply confirmed again that half of the sine wave has a component at $$e^{j2\omega_o n}$$ and if we continued we would also confirm that it has the other half at $$e^{-j2\omega_o n}$$!

All other bins will result in zero values except for $$k=N-2$$. Due to periodicity in $$e^{-jk\omega_o n}$$ we have the relationship:

$$e^{-j(N-k)\omega_o n} = e^{jk\omega_o n}$$

So when $$k=N-2$$ in this case we get the rest of the signal the OP thought was "lost".

$$X(N-2) = \sum_{n=0}^{N-1}=(-0.5je^{j2\omega_o n}+0.5je^{-j2\omega_o n})e^{-j(N-2)\omega_o n}$$

$$= \sum_{n=0}^{N-1}=(-0.5je^{j2\omega_o n}+0.5je^{-j2\omega_o n})e^{j2\omega_o n}$$

$$= \sum_{n=0}^{N-1}(-0.5je^{j4\omega_o n} + 0.5 ) = 0.5Nj$$

The OP was basically using the first property given for the case of real signal in which we could drop that other term (which is the negative frequency component) and if we do, we need to double our result to maintain the same scaling.

If we divide the results above by $$N$$ we see that the DFT simply returned the coefficients of the sine wave when written out using Euler's formula:

$$\sin(2\omega_o n) = \frac{1}{2j}e^{2j\omega_o n} - \frac{1}{2j}e^{-2j\omega_o n}$$

This point is not at all surprising when you consider individual frequency "tones" not as sinusoids, but the basic component in the form of $$e^{j\omega_o n}$$; a spinning phasor in the time domain. The DFT is simply a correlation to all the possible $$e^{kj\omega_o n}$$ components as I detail further in this post.

• Thanks Dan for the comprehensive answer, that is very clear and illuminating. Feb 12 at 18:39
• Thanks for the good question Joseph! Feb 12 at 18:53