# Interpolation and harmonics

A real valued causal sequence $$x1[n]$$ exists with length of the sequence being $$N$$. Valid indices of x conform to $$0 \le n \le N-1$$

The DFT of x[n] is: $$X1[k] = \sum_{n=0}^{N-1} x1[n].e^{-j.2.\pi.k.n/N}$$

The normalized frequency spectrum exists from 0 to $$2\pi$$. This frequency spectrum contains discrete frequencies which are integer factors of $$\frac{2 \pi}{N}$$.

A properly sampled signal fulfilling Nyquist criteria will have the valid range of normalized frequencies from $$0$$ through $$(\frac{N}{2} - 1)$$ $$\frac{2\pi}{N}$$.

As an example, for N=8, the valid frequencies are $$0$$, $$2\pi.n/N$$, $$4\pi.n/N$$ and $$6\pi.n/N$$.

When $$x1[n]$$ is upsampled with a factor of 2, we essentially insert a $$0$$ after each sample. This creates a new sequence $$x2[n]$$ with a length of $$2N$$.

The DFT of this new sequence will now be: $$X2[k] = \sum_{n=0}^{2N-1} x2[n].e^{-j.\pi.k.n/N}$$

The discrete frequencies of this new sequence are $$0$$, $$\pi.n/N$$, $$2\pi.n/N$$, $$3\pi.n/N$$, $$4\pi.n/N$$, $$5\pi.n/N$$, $$6\pi.n/N$$, $$7\pi.n/N$$ and so on.

So it is clear that each new sample that was added to $$x1[n]$$ has introduced a new frequency component.

I have two questions now:

1. As the harmonics (as the math seems to suggest) lies amongst the desired frequencies (e.g., $$\pi.n/N$$ is less than $$2\pi.n/N$$, and $$3\pi.n/N$$ is less than $$4\pi.n/N$$), shouldn't the interpolation filter be a comb filter?

2. When I take a FFT of $$x2[n]$$, I expect to see the harmonics in the original pass-band. But instead, the frequency spectrum of x1[n] has been replicated.

What have I misunderstood?

• Are you trying to express $x2$ as a function of $x1$? Because if you do, you are missing the interpolation filter and the $N$ on $X2$'s kernel would have to be $2 N$ too (?). If $x2$ is the upsampled sequence it has lost any reference to $x$ and its $N$. It is now a new stand alone sequence. – A_A May 3 '19 at 8:27
• The $X2(k)$ does factor in $2N$. You can find the $2$ missing in the sinusoid component. – Raj May 3 '19 at 8:48
• Got it, are you doing the full upsampling including the interpolation? Also, is it possible to include some plots of the signals you work with for clarity? – A_A May 3 '19 at 10:40
• @A_A, No interpolation yet, just up-sampling. – Raj May 3 '19 at 14:19
• then what you see is perfectly normal because your $x1$ spectrum is multiplied with a train of pulses and what you see is the convolution of the frequency spectra as per the DFT conv property. – A_A May 3 '19 at 15:21

Upsampling requires two steps:

1. Inserting zeros. This does indeed replicate the spetcrum in the frequency domain. For N zeros inserted you get N copies of the original spectrum
2. Lowpass filtering to remove the mirror spectra. That's often also called an "interpolation filter".

The choice of interpolation filter depends a lot on the requirements of your specific application (signal to noise ratio, spectral suppression, shape of original spectrum, transient behavior, phase distortion, latency, MIPS, etc.). There is no "one size fits all" solution

• Thank you, Hilmar. I am looking for intuition [Mathematical/Pictorial] behind the spectrum replication phenomenon. – Raj May 3 '19 at 14:17
• @Raj, Have you seen Marcus Muller's answer in this recent question: dsp.stackexchange.com/questions/58032/… ? – Cedron Dawg May 4 '19 at 11:55
• Upvoted. Thank you very much. Exactly the answer I was looking for. He nailed it. – Raj May 4 '19 at 12:49

Proof by induction.

Let $$N=2$$. $$x1[n]$$ is the original sequence whilst $$x2[n]$$ and $$x3[n]$$ are upsampled sequences..

$$x1[2] = { x1[0], x1[1] }$$

$$x2[4] = { x1[0], 0, x1[1], 0 }$$

$$x3[6] = x1[0],0,0,x1[1],0,0$$

$$X1(0) = x1[0].e^{-j.2\pi.0.0 / 2} + x1[1].e^{-j.2\pi.0.1 / 2} = x1[0]+ x1[1]$$ $$X1(1) = x1[0].e^{-j.2\pi.1.0 / 2} + x1[1].e^{-j.2\pi.1.1 / 2} = x1[0]- x1[1]$$

$$X2(0) = x2[0].e^{-j.2\pi.0.0 / 4} + 0.e^{...} + x2[2].e^{-j.2\pi.0.2 / 4} + 0.e^{...}= x2[0]+ x2[2] = x1[0]+ x1[1]$$ $$X2(1) = x2[0].e^{-j.2\pi.1.0 / 4} + 0.e^{...} + x2[2].e^{-j.2\pi.1.2 / 4} + 0.e^{...}= x2[0]- x2[2] = x1[0]- x1[1]$$ $$X2(2) = x2[0].e^{-j.2\pi.2.0 / 4} + 0.e^{...} + x2[2].e^{-j.2\pi.2.2 / 4} + 0.e^{...}= x2[0]+ x2[2] = x1[0]+ x1[1]$$ $$X2(3) = x2[0].e^{-j.2\pi.3.0 / 4} + 0.e^{...} + x2[2].e^{-j.2\pi.3.2 / 4} + 0.e^{...}= x2[0]- x2[2] = x1[0]- x1[1]$$

$$X1$$ has replicated twice in $$X2$$.

Similarly: $$X3(0) = x3[0].e^{-j.2\pi.0.0 / 6} + 0.e^{...} + 0.e^{...}+ x3[3].e^{-j.2\pi.0.3 / 6} + 0.e^{...} + 0.e^{...}= x3[0]+ x3[3] = x1[0]+ x1[1]$$ $$X3(1) = x3[0].e^{-j.2\pi.1.0 / 6} + 0.e^{...} + 0.e^{...}+ x3[3].e^{-j.2\pi.1.3 / 6} + 0.e^{...} + 0.e^{...}= x3[0]- x3[3] = x1[0]- x1[1]$$ $$X3(2) = x3[0].e^{-j.2\pi.2.0 / 6} + 0.e^{...} + 0.e^{...}+ x3[3].e^{-j.2\pi.2.3 / 6} + 0.e^{...} + 0.e^{...}= x3[0]+ x3[3] = x1[0]+ x1[1]$$ $$X3(3) = x3[0].e^{-j.2\pi.3.0 / 6} + 0.e^{...} + 0.e^{...}+ x3[3].e^{-j.2\pi.3.3 / 6} + 0.e^{...} + 0.e^{...}= x3[0]- x3[3] = x1[0]- x1[1]$$ $$X3(4) = x3[0].e^{-j.2\pi.4.0 / 6} + 0.e^{...} + 0.e^{...}+ x3[3].e^{-j.2\pi.4.3 / 6} + 0.e^{...} + 0.e^{...}= x3[0]+ x3[3] = x1[0]+ x1[1]$$ $$X3(5) = x3[0].e^{-j.2\pi.5.0 / 6} + 0.e^{...} + 0.e^{...}+ x3[3].e^{-j.2\pi.5.3 / 6} + 0.e^{...} + 0.e^{...}= x3[0]- x3[3] = x1[0]- x1[1]$$

$$X1$$ has replicated thrice in $$X3$$.

So, every $$0$$ added to up-sample contributes to a copy of the original spectrum. Also, no new frequencies as claimed by my original question are created. The zero samples cancel them out. So, its just copies of the original spectrum. No comb filter, just a LPF will do fine.