Fourier series of periodic discretetime signals ALGORITHM FOR SOLUTION: Fast Fourier Transform...
Embed Size (px)
Transcript of Fourier series of periodic discretetime signals ALGORITHM FOR SOLUTION: Fast Fourier Transform...

Fourier series of periodic discretetime signals
1

Discretetime signal x(n):
Defined for integer time instants n:
{x(n)} = {. . . , x(2), x(1), x(0), x(1), x(2), . . .}
2

In analogy with continuoustime signals, discrete
time signals can be expanded in terms of sinusoidal
components of form Ak cos(kn+ k)
2 0 2 4 6 8 10 12
1
0
1
cos(2fn+ ), f = 0.1(Hz), = 2f 2(rad)
3

Consider a periodic discretetime signal with period
N :
x(n) = x(n+N), all n
4

In analogy with continuoustime case the discrete
sinusoidal signals
cos(2k
Nn), sin(
2k
Nn), k = 0, 1, 2, . . .
have period N .
It follows that an N periodic signal {x(n)} can beexpanded in terms of sinusoidal signals
cos(2k
Nn), sin(
2k
Nn), k = 0, 1, 2, . . .
5

Important difference compared to continuoustime case:
We have
cos(n) = cos(n + 2nl)
= cos (n( + 2l)), all integers l
=Frequencies and + 2l give the same discrete
time sequence
NOTE: works only because time n is an integer!
6

Hence we need only include frequency components
cos(21
Nn), cos(2
2
Nn), . . . , cos(2
N 1N
n)
sin(21
Nn), sin(2
2
Nn), . . . , sin(2
N 1N
n)
and we obtain the Fourier series
x(n) = a0 +
N1k=1
ak cos(k2
Nn) +
N1k=1
bk sin(k2
Nn)
7

As before, we can express each frequency component
in terms of complex exponentials:
x(n) =N1
k=N+1
ckej2kn/N
As time n is an integer we can eliminate the negative
exponentials:
ej2(m)n/N = ej2(m)n/N+j2n = ej2(Nm)n/N
=
Terms with k = m < 0 can be replaced by a termwith k = N m > 0
8

NOTE:
As ck = ck, we have
ckej2(k)n/N = cke
j2(Nk)n/N
Fourier series of discretetime periodic signal
An N periodic discretetime signal can be expanded
as
x(n) =
N1k=0
dkej2kn/N
where dNk = dk
9

Here the complexvalued frequency components are
given by
dk =1
N
N1n=0
x(n)ej2kn/N
Proof:
Multiply expression for x(n) with ej2mn/N and sum
over time n over one period:
1
N
N1n=0
[ej2mn/N
(x(n) =
N1k=0
dkej2kn/N
)]10

Here the righthand side becomes
1
N
N1k=0
dk
N1n=0
ej2(km)n/N
which vanishes if m = k, because
N1n=0
ej2(km)n/N =
{N, if k m = 0,N,2N, . . .0, otherwise
Hence
1
N
N1k=0
dk
N1n=0
ej2(km)n/N = dm
11

and1
N
N1n=0
x(n)ej2mn/N = dm
giving the result
12

EXAMPLE: Periodic discretetime square wave with periodN = 4:
x(0) = 1
x(1) = 1
x(2) = 0
x(3) = 15 4 3 2 1 0 1 2 3 4 5
x(n)
n
and x(n) = x(n 4), all nFrequency components: 0, 24 ,
224 ,
234
(Next frequency 244 = 2 is equivalent to frequency
component 0)
13

Fourier series:
dk =1
4
3n=0
x(n)ej2kn/4
=1
4
[1 ej2k0/4 + 1 ej2k1/4 + 0 + 1 ej2k3/4
]=
1
4
[1 + ejk/2 + ejk3/2
]=
1
4[1 + 2 cos (k/2)]
=d0 =
3
4, d1 =
1
4, d2 =
1
4, d3 =
1
4
0 2/2
3/2
dk
14

Hence
x(n) =3
k=0
dkej2kn/4
=3
4+
1
4ej21n/4 1
4ej22n/4 +
1
4ej23n/4
=3
4+
1
4[cos (n/2) + j sin (n/2)]
14[cos (n) + j sin (n)] +
1
4[cos (3n/2) + j sin (3n/2)]
Note that as x(n) is real the imaginary components should
vanish
15

Here we have:
 sin(n) = 0
 cos(n) = (1)n
In addition, frequency components 3/2 and /2 are related,
because
 sin(3n/2)=sin(3n/22n)=sin(n/2)= sin(n/2),and
 cos(3n/2)=cos(3n/2 2n)=cos(n/2)=cos(n/2)
=
x(n) =3
4+
1
2cos
(2
4n
) 1
4(1)n
16

NOTE:
In above example the Fourier series coefficients dk were real.
Reason: Recall that
ak cos(2kn/N)+bk sin(2kn/N) = ckej2kn/N+cke
j2kn/N
where
ck =1
2(ak jbk) , ck =
1
2(ak + jbk)
As x(n) is even, x(n) = x(n), the sineterms vanish so thatbk = 0 and hence ck and dk are real.
17

Next example illustrates a signal which is not even.
Consider the periodic signal
x(0) = 1
x(1) = 1
x(2) = 1
x(3) = 0
and x(n) = x(n 4), all n
We see that x(n) = x(n 1), all n.
18

Hence
x(n) = x(n 1)
=3
k=0
dkej2k(n1)/4
=3
k=0
dkej2k/4ej2kn/4
=
3k=0
dkej2kn/4
where
dk = dkej2k/4
19

or
d0 = d0ej0 =
3
4
d1 = d1ej/2 =
1
4 (j)
d2 = d2ej = 1
4 (1)
d3 = d3ej3/2 =
1
4 j
20

Fourier series of nonperiodic discretetimesignals
In analogy with the continuoustime case a nonperiodic
discretetime signal consists of a continuum of frequencies
(rather than a discrete set of frequencies)
But recall that
cos(n) = cos(n + 2nl)
= cos (n( + 2l)), all integers l
=Only frequencies up to 2 make sense
21

Hence a discretetime signal {x(n)} can be expanded as
x(n) =1
2
20
X()ejnd
where it can be shown that the Fourier transform X() is given
by
X() =
n=
x(n)ejn
22

THE DISCRETE FOURIER TRANSFORM (DFT)
Next lets introduce the standard definition of the discrete
Fourier transform of a sequence
{x(0), x(1), . . . , x(N 1)}
of finite length N .
We do not make any assumptions about the signal (periodicity
etc) outside the range 0 n N 1.
23

Facts:
 from N signal values x(0), x(1), . . . , x(N 1) at most Nindependent frequency components can be computed
 frequency components 2 are redundant (identical withfrequencies < 2
 lower bound on frequency resolution is 2/N (= frequency
corresponding to period length equal to sequence length N)
Hence it makes sense to determine the frequency components
at the N equidistant frequencies
0,1
N2,
2
N2, . . . ,
N 1N
2
i.e., the same frequencies contained in an N periodic signal
24

DISCRETE FOURIER TRANSFORM (DFT):
The DFT {X(k)}N1k=0 of a sequence {x(k)}N1k=0 is
defined as
X(k) =
N1n=0
x(n)ej2kNn, k = 0, 1, . . . , N1 (DFT)
and the inverse DFT (IDFT) is given by
x(n) =1
N
N1k=0
X(k)ej2kNn, n = 0, 1, . . . , N 1
Observe similarity with Fourier transform of periodic
signal
25

EXAMPLE
Show that the Discrete Fourier Transform of the
sequence
{x(n)} = {1, 0, 0, 1}
is given by
{X(k)} = {2, 1 + j, 0, 1 j}
26

PROPERTIES OF DFT
Symmetry property.For a real sequence {x(n)}, the DFT satisfies
X(N k) = X(k) (complex conjugate)
i.e.,
Re[X(N k)] =Re[X(k)]Im[X(N k)] =Im[X(k)], k = 1, . . . , N 1
27

Follows from the fact that in the definition of X(N k),
x(n)ej2NkN n = x(n)ej2
kNnj2
= x(n)ej2kNn
=(x(n)ej2
kNn)
DC component.For k = 0 we have
X(0)=
N1n=0
x(n)ej20Nn
=x(0) + x(1) + + x(N 1)
Hence X(0) is real if x(n) are real and the
28

contribution of X(0) to x(n) is
1
NX(0)e0 =
1
NX(0)
i.e., a constant component (usually called the DC
component).
Oscillating component.For even values of N , we have for k = N/2
X(N/2) =
N1n=0
x(n)ej2N/2N n =
N1n=0
x(n)ejn
= x(0) x(1) + x(N 1)
Hence X(N/2) is real if x(n) are real and the
29

contribution of X(N/2) to x(n) is
1
NX(N/2)ej2
N/2N n =
1
NX(N/2) (1)n
i.e., an oscillating component.
Parsevals relation.The energy of the signal {x(n)} defined as
Px =
N1n=0
x(n)2
can be computed in the frequency domain using
30

Parsevals relation,
Px =N1n=0
x(n)2 =1
N
N1k=0
X(k)2
It follows that 1N X(k)2 can be interpreted as the
contribution to the total energy of the signal from
frequency component 2k/N .
Note: important in signal compression!
DFT of a function.The function,
(n) =
{1, n = 0
0, n = 031

has DFT X(k) = 1, k = 0, 1, . . . , N 1.Hence it consists of equal amounts of all
frequencies!
32

DIRECT COMPUTATION OF DFT SUM ISNOT ADVISABLE IN PRACTICE:
 HIGH COMPUTATIONAL BURDEN:
Computation of sequence X(k) requires N 2
complex additions and multiplications (a lot for
long sequences)
 Numerical roundoff errors add up when evaluation
long sum
33

EFFICIENT ALGORITHM FOR SOLUTION:Fast Fourier Transform (FFT)
 FFT: N log2N complex additions and
(N/2) log2N complex multiplications (compare
N 2 using direct evaluation)
 Each element X(k) is obtained by only log2N
complex additions (compare with N using direct
evaluation) significantly smaller roundoff errors
MATLAB routines:
 X=fft(x) (Fourier transform)
 x=ifft(X) (inverse Fourier transform)
34

FFT uses the fact that the discrete Fourier transformX(k) of a sequence {x(0), x(1), . . . , x(N 1)} withN even can be determined as
X(k) = X11(k) +WkNX12(k), k = 0, 1, . . . , N/2 1
X(k +N/2) = X11(k)W kNX12(k), k = 0, 1, . . . , N/2 1
where WN = ej2/N ,
{X11(k)} is the Fourier transform of the evensubsequence {x(0), x(2), . . . , x(N 2)}, andX12(k)} is the Fourier transform of the oddsubsequence {x(1), x(3), . . . , x(N 1)}.
35

Example (N = 8):
X(k) =7
n=0
x(n)ej2kn/8
= x(0) + x(2)ej2k2/8
+ x(4)ej2k4/8
+ x(6)ej2k6/8
+x(1)ej2k/8
+ x(3)ej2k3/8
+ x(5)ej2k5/8
+ x(7)ej2k7/8
= x(0) + x(2)ej2k/4
+ x(4)ej2k2/4
+ x(6)ej2k3/4
+ej2k/8
(x(1) + x(3)e
j2k/4+ x(5)e
j2k2/4+ x(7)e
j2k3/4)
=
3n=0
x(2n)ej2kn/4
+ ej2k/8
3n=0
x(2n + 1)ej2kn/4
= X11(k) + Wk8 X12(k), k = 0, 1, 2, 3
where W8 = ej2/8, and
{X11(k)} = DFT ({x(0), x(2), x(4), x(6)})
{X12(k)} = DFT ({x(1), x(3), x(5), x(7)})
36

X11(k), X12(k) are defined for k = 0, 1, 2, 3. The latter half of X(k) is obtained from
X(k + 4) =
7n=0
x(n)ej2(k+4)n/8
= x(0) + x(2)ej2(k+4)2/8
+ x(4)ej2(k+4)4/8
+ x(6)ej2(k+4)6/8
+x(1)ej2(k+4)/8
+ x(3)ej2(k+4)3/8
+ x(5)ej2(k+4)5/8
+ x(7)ej2(k+4)7/8
= x(0) + x(2)ej2(k/4+1)
+ x(4)ej2(2k/4+2)
+ x(6)ej2(3k/4+3)
+ej2(k/8+1/2)
(x(1) + x(3)e
j2(k/4+1)+ x(5)e
j2(2k/4+2)+ x(7)e
j2(3k/4+3))
= x(0) + x(2)ej2k/4
+ x(4)ej22k/4
+ x(6)ej23k/4
+ej2k/8
ej
(x(1) + x(3)e
j2k/4+ x(5)e
j22k/4+ x(7)e
j23k/4)
=
3n=0
x(2n)ej2kn/4 ej2k/8
3n=0
x(2n + 1)ej2kn/4
= X11(k) W k8 X12(k), k = 0, 1, 2, 3
where we have used ej = cos() + j sin() = 1.
37

The operation
X(k) = X11(k) + WkNX12(k), k = 0, 1, . . . , N/2 1
X(k + N/2) = X11(k) W kNX12(k), k = 0, 1, . . . , N/2 1
is known as the Butterly operation:
&%'$
3
QQQQ
QQQs
3
QQQQ
QQQs
X11(k)
X12(k)
X(k)
X(k + N/2)
+
WkN
The Discrete Fourier Transform is thus constructed by combining the transform two shorter
sequences of lengths N/2, N/4, . . . , 2, 1, starting with sequences of length 1.
38

Total number of operations:
 sequence of length N = 2B can be decomposed B = log2 N times.
 each stage requires N/2 Butterfly operations.
 Butterfly operations takes 2 complex additions and 1 complex multiplication.
=Total number of complex additions = N log2 N
Total number of complex multiplications = (N/2) log2 N
39

INTERPRETATION OF FOURIER TRANSFORMCOMPONENTS
0
X(0)
X(1)
1
X(k)
k
X(N/2)
N/2
X(Nk)=X(k)
Nk
X(N1)=X(1)
N1 N
Normalized frequency 0 1NkN
12
NkN
N1N 1
(Hz)
Actual frequency
Sampling frequency fs = 1/Ts0 1N
fskN
fs12fs
NkN
fsN1N
fs fs (Hz)
Matlab indexing X(1) X(2) X(k+1) X(N/2+1) X(Nk+1) X(N)
40

To observe:
The frequency component X(k) corresponds to the frequency 2k/N (radians/s)or k/N (Hz) when the sampling frequency is normalized to 1 sample/s. If the
actual sampling frequency is fs (samples/s or Hz), X(k) corresponds to the frequency
(k/N)fs Hz.
Highest frequency of which information can be obtained = half of sampling frequency= fs/2
Frequency resolution = fs/N , i.e., increasing sequence length N gives increasedresolution
Magnitude and phase information from:N/2 + 1 frequency components 0, 1/N, . . . , 1/2 (for even N),
(N + 1)/2 frequency components 0, 1/N, . . . , 12(N 1)/N (for odd N)
X(0) is realvalued; describes DC component (zero frequency)
1
NX(0) cos(2 0 n) =
1
NX(0)
41

X(N/2) is realvalued; describes oscillating component (normalized frequency 1/2)
1
NX(N/2) cos(2 (1/2) n) = (1)n
1
NX(N/2)
Frequency components X(1), . . . , X(N/2 1) usually complexvalued. X(1) describes sinusoidal component with period N samples
 X(2) describes sinusoidal component with period N/2 samples, etc.
42