# DTFT of sawtooth wave through DTFT of rect signal

In a course i'm currently taking, the lecturer computed DTFT for the following signal: $$r[n] = \begin{cases} 1& 0 \le n \le N\\ 0& \mbox{otherwise} \end{cases}$$ For $$N = 32$$ i pictured $$\frac{1}{N}\frac{\sin{\omega*N/2}}{\sin{\omega/2}}$$:

The lecturer told us that you can compute DTFT of any signal on finite support by using this formula:

\begin{align*} \bar{X}(e^{j\omega}) = \sum_{k=0}^{N-1}X[k]\bar{R}(e^{\omega - \frac{2\pi}{N} k})\\ \end{align*}

So, I tried to render DTFT of sawtooth (red) as the sum:

That's clearly wrong. What did I do wrong?

The discrete Fourier transform (DFT) coefficients of a sequence $$x[n]$$ of length $$N$$ is defined by

$$X[k]=\sum_{n=0}^{N-1}x[n]e^{-j2\pi nk/N}\tag{1}$$

and the inverse transform is

$$x[n]=\frac{1}{N}\sum_{k=0}^{N-1}X[k]e^{j2\pi nk/N}\tag{2}$$

The discrete-time Fourier transform (DTFT) of a sequence $$x[n]$$ of length $$N$$ is given by

$$X(e^{j\omega})=\sum_{n=0}^{N-1}x[n]e^{-jn\omega}\tag{3}$$

Plugging $$(2)$$ into $$(3)$$ gives

\begin{align}X(e^{j\omega})&=\sum_{n=0}^{N-1}\frac{1}{N}\sum_{k=0}^{N-1}X[k]e^{-jn(\omega-2\pi k/N)}\\&=\sum_{k=0}^{N-1}X[k]\frac{1}{N}\sum_{n=0}^{N-1}e^{-jn(\omega-2\pi k/N)}\tag{4}\end{align}

With the DTFT of a rectangular sequence $$r[n]=1/N$$ for $$n\in [0,N-1]$$ and zero otherwise

$$R(e^{j\omega})=\frac{1}{N}\sum_{n=0}^{N-1}e^{-jn\omega}=e^{-j(N-1)\omega/2}\frac{\sin(N\omega/2)}{N\sin(\omega/2)}\tag{5}$$

Eq. $$(4)$$ can be written as

$$\sum_{k=0}^{N-1}X[k]R\left(e^{j(\omega-2\pi k/N)}\right)\tag{6}$$

So $$(6)$$ is the correct version of the formula, and the DFT coefficients $$X[k]$$ are defined by $$(1)$$. If you use those formulas correctly it should work.

• Thanks for the answer. I believe I used exactly these formulas to create figures. You can see stems of sawtooth DFT in the second picture and for this $R$ thing in the first. But they don't give me proper DTFT of sawtooth. – Yola Jan 19 '19 at 15:12
• I wonder if I missed something while plotting $R$ and this is the reason that DTFT of sawtooth is wrong. – Yola Jan 19 '19 at 15:15
• @Yola: Note that there's a linear phase term in $R(e^{j\omega})$ (Eq. 5) that I don't see in your formula. – Matt L. Jan 19 '19 at 15:40
• I removed it because its absolute value is one anyway. Thus, my first picture is not $\mbox{abs}(R)$, but $\mbox{sign}(R)\mbox{abs}(R)$. Maybe that's wrong to do so, but otherwise, I get even worser picture for sawtooth's DTFT. – Yola Jan 19 '19 at 15:57