# Rectify signal basic question

When rectifying a signal by squaring it, is it necessary to upsample by a factor of 2?

Why is this?

• As a complement to jithin's fine answer: When processing a signal, the sampling theorem needs to be satisfied at every step, including the final result, or aliasing will occur.
– MBaz
Mar 27 '20 at 16:19

The only reason I can think of may be to preserve the frequencies over which original signal had spectrum (before squaring). When you square a signal $$x[n]$$, whose spectrum $$X(e^{j\omega})$$ extends from $$-\omega_0 \le \omega \le \omega_0$$, you are multiplying by itself. So in frequency domain, the effect is to (periodically) convolve $$X(e^{j\omega})$$ by itself. $$S(e^{j\omega}) = \int_0^{2\pi} X(e^{j\theta})X(e^{j(\omega - \theta)})d\theta$$ The convolution will result in $$S(e^{j\omega})$$ non-zero over $$-2\omega_0 \le \omega \le 2\omega_0$$. If you had upsampled before squaring, the spectrum before squaring would have been non-zero only from $$-\omega_0/2 \le \omega \le \omega_0/2$$. So after squaring (convolution in frequency domain), its spectrum is still $$-\omega_0 \le \omega \le \omega_0$$.

I think the accepted answer is not quite strong enough to state the real problem: If you don't up-sample you run the risk of significant aliasing.

Let's look at a simple example: sample rate of 25.6 kHz and a strong signal component at 11.5kHz. If you just square it you end up with a component at DC (which is representative of the average energy) and another one at 2600 Hz. The one at 2600Hz has NOTHING to do with your original signal. It's simply an aliasing artifact that's a function of the sample rate. If you were to sample this at 25.0 kHz that component would move to 2 kHz.

Any analysis or conclusion drawn from the aliased component would simply be wrong.

So the options are to either up-sample or low-pass filter somewhere below $$F_S/4$$ before squaring the signal

• Conversely, if you have a signal that is known to have no significant energy above 1/4 the sampling rate, then you could square it safely, knowing that the result would have no significant energy above 1/2 the sampling rate. Mar 27 '20 at 19:08
• Hence my recommendation of a lowpass filter at Fs/4 I'm assuming that the sampling rate was chose based on the actual contents of the signal Mar 28 '20 at 11:31