1
$\begingroup$

I'm having some trouble with understanding the DFT of a sawtooth single period signal and its relation with sawtooth Fourier coefficients.

Let's say I have a signal $$ s(t) = \frac{At}{T} - \frac{A}{2} \qquad t\in[0,T) $$

If I plot its DFT real and imaginary components I have something like this sawtooth dft

Where $A=10$, $T=1$, $N=50$ (number of samples) and the DFT is normalized by $\tau = T/N$ and $1/N/\tau$ for the inverse.

Now, the imaginary part as far as I can understand comes from the Fourier coefficients $$ c_n = \frac{iA}{2\pi N} $$ These coefficients (see e.g. Brigham, section 5.2) equal the fourier transform $S(t)$ scaled by $\frac{1}{T}$ and sampled at $n/T$. Given we have a discrete signal, we need to account for aliasing in the frequency space, which can be represented by repeating $c_n$ at $N$ intervals and summing with themselves, something like the following? probably missing a constant $$ Im(S_n) = \sum_{m=-\infty}^{\infty} c_n\delta(n-mN) \qquad n \in [0,N-1] $$

What about the non zero real part? As an afterthought I can rationalize it because the sawtooth is non zero at $t=0$, so it must have a non zero mean DFT. But if I take a sawtooth centered in $-T/2,T/2$ it's still there even if the signal crosses the origin.

I'd like to find a better relation that gets me from the Fourier series to the DFT, accounting both for the imaginary and the real part. Any pointer to good resources to help understand the whole thing would be more than welcome.

Just looking at the DFT, the real part, with my normalization should be: $$ -\frac{A}{2}\tau\sum_{n=-\infty}^{\infty}\delta\left(f-\frac{n}{T}\right) $$ How do I justify this result? especially the multiplication factor?

(sorry if the math is a bit flaky, I'm still trying to understand everything about DFT, Dirac combs and most of all normalization constants, every single source has them different...)

$\endgroup$
  • $\begingroup$ in case no one points it out is that sampling a continuous-time function always causes the spectrum to be repeated (at integer multiples of the sampling frequency), overlap, and add. the reason the coefficients come out slightly different is because of aliasing where the overlapped and aliased component lie right on top (not in between) the original components. $\endgroup$ – robert bristow-johnson Jan 10 '16 at 19:32
  • $\begingroup$ @robertbristow-johnson would you mind elaborating on this point? $\endgroup$ – filippo Jan 10 '16 at 20:48
  • $\begingroup$ i'll try with an answer. Matt is usually quite thorough and i am lazy enough to, more often than not, delay starting an answer if Matt had already, to the point that i don't bother answering. $\endgroup$ – robert bristow-johnson Jan 11 '16 at 1:05
  • $\begingroup$ thank you! what I'm having trouble to understand is how aliasing an imaginary function could explain the real part. $\endgroup$ – filippo Jan 11 '16 at 4:15
  • $\begingroup$ @filippo: I added some more explanation at the end of my answer. Note that the real part is not caused by aliasing but simply because the sampled function isn't odd (which would cause a purely imaginary DFT), whereas the original continuous function is. This explanation was already in my answer before the edit. $\endgroup$ – Matt L. Jan 11 '16 at 7:51
2
$\begingroup$

Let me use the definitions of the Fourier series and the DFT as they are commonly used in signal processing. The Fourier series of a $T$-periodic function $f(t)$ is given by

$$f(t)=\sum_{k=-\infty}^{\infty}c_ke^{j2\pi kt/T}\tag{1}$$

where $c_k$ are the complex Fourier coefficients:

$$c_k=\frac{1}{T}\int_0^Tf(t)e^{-j2\pi kt/T}dt\tag{2}$$

The length-$N$ DFT of a sequence $x[n]$ is defined by

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

and the inverse DFT is

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

If you sample $f(t)$ at $t=n\tau$ with $\tau=T/N$ you can approximate the integral $(2)$ by the following sum:

$$c_k\approx\frac{1}{T}\sum_{n=0}^{N-1}f(n\tau)e^{-j2\pi kn\tau /T}\tau\tag{5}$$

With $x[n]=f(n\tau)$ and $\tau=T/N$, Eq. $(5)$ can be rewritten as

$$c_k\approx\frac{1}{N}\sum_{n=0}^{N-1}x[n]e^{-j2\pi nk/N}=\frac{1}{N}X[k],\qquad |k|\le\left\lfloor \frac{N}{2}\right\rfloor\tag{6}$$

Equation $(6)$ says that the Fourier series coefficients $c_k$ of the $T$-periodic function $f(t)$ are approximated by the (scaled) DFT coefficients of the sequence $x[n]=f(n\tau)$, with $\tau=T/N$.

Of course this is also the case for your function. With

$$f(t)=A\left(\frac{t}{T}-\frac12\right),\qquad 0\le t< T\tag{7} $$

and $f(t)=f(t+T)$, we get

$$x[n]=f(nT/N)=A\left(\frac{n}{N}-\frac12\right),\qquad 0\le n< N \tag{8}$$

The Fourier coefficients of $f(t)$ are

$$c_k=\frac{jA}{2\pi k}\tag{9}$$

The DFT of $x[n]$ is given by

$$X[k]=\begin{cases}-\frac{A}{2},&\quad k=0\\ \frac{A}{e^{-j2\pi k/N}-1} = e^{j\pi k/N} \frac{jA/2}{\sin(\pi k/N)}=\frac{A}{2}(-1+j\cot(\pi k/N)),&\quad 0<k<N \end{cases}\tag{10}$$

The first thing to notice is that $f(t)$ is an odd function (with a discontinuity at $t=0$), and, consequently, its Fourier coefficients are purely imaginary. On the other other hand, the sampled version of $f(t)$ is not odd because $x[0]\neq 0$; that's why we get a (relatively small) non-zero real part in the DFT coefficients. However, as predicted by Eq. $(6)$, the scaled DFT coefficients $X[k]/N$ still approximate the Fourier coefficients quite well. The zero real part of $c_k$ is "approximated" by the value $-A/2N$, which is small for large $N$. The figure below shows the imaginary part of $X[k]/N$ (red) and the (imaginary part of the) Fourier coefficients $c_k$ (blue):

enter image description here

The increasing difference between $c_k$ and $X[k]/N$ with increasing $k$ is due to aliasing caused by sampling $f(t)$. Note that $f(t)$ is not band-limited, so you will always have some amount of aliasing, no matter how fast you sample. The difference in the real part ($-A/2N$ vs $0$) is caused by the fact that $f(t)$ is odd, but $x[n]$ isn't because $x[0]=f(0^+)=A/2\neq 0$.


EDIT: Here comes the derivation of the DFT of $x[n]$ defined by $(8)$. From $(3)$ we have

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

Let's first consider the case $k=0$:

$$\begin{align}X[0]&=\frac{A}{N}\sum_{n=0}^{N-1}n-\frac{A}{2}\sum_{n=0}^{N-1}1\\&= \frac{A}{N}\frac{(N-1)N}{2}-\frac{AN}{2}\\&=-\frac{A}{2}\end{align}\tag{b}$$

For $k\neq 0$, the second term in Eq. (a) equals zero. From the formula

$$\sum_{n=0}^{N-1}nq^n=\frac{(N-1)q^{N+1}-Nq^N+q}{(1-q)^2},\qquad q\neq 1\tag{c}$$

(which can be obtained by taking the derivative of the standard formula for a geometric series), and by noting that $e^{-j2\pi k}=1$, we get after some manipulations

$$\begin{align}X[k]&=\frac{A}{N}\sum_{n=0}^{N-1}ne^{-j2\pi nk/N}\\&=\ldots\\&=\frac{A}{e^{-j2\pi k/N}-1},\qquad k\neq 0\end{align}\tag{d}$$

from which all other representations shown in Eq. $(10)$ can be derived quite easily.

$\endgroup$
  • $\begingroup$ Matt, you can revert the edit, if you want. somehow this should be setup so that the two sawtooths line up at $x(0)$ and $x[0]$ so that the only difference between the two sets of coefficients is the denominator. and it should be made clear that as $N \to \infty$, the coefficients begin to appear the same. except for the scaling of $N$. $\endgroup$ – robert bristow-johnson Jan 10 '16 at 19:29
  • $\begingroup$ @robertbristow-johnson: That's OK; the point of my representation was to make it explicit that the real part of $X[k]$ is $-A/2$ for all $k$. $\endgroup$ – Matt L. Jan 10 '16 at 19:53
  • $\begingroup$ Would you mind editing back to show both representations of the closed form? I guess the former was better targeted to my question about the real part. Thanks, by the way, now I just have to get accustomed to the different notation and try to reconcile this approach with the multiplication/convolution/dirac combs based one which I'm more accustomed to. $\endgroup$ – filippo Jan 10 '16 at 20:19
  • $\begingroup$ @filippo: Now you have both representations. Also note that you shouldn't have any Dirac deltas because the DFT as well as the Fourier series are discrete representations. You only get Dirac deltas in the Fourier transform, and its discrete-time version, the DTFT (which is different from the DFT). $\endgroup$ – Matt L. Jan 10 '16 at 20:33
  • $\begingroup$ @MattL. I'll try to update in my question to make it more clear. What I mean is that you can get the sampled, aliased, imaginary part starting from fourier transform just using continous math and dirac distributions, so it should be possible to also account for the real part. $\endgroup$ – filippo Jan 11 '16 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.