Periodic signals - Fourier series Valentina Hubeika, Honza Černocký DCGM FIT BUT Brno, {ihubeika,cernocky}@fit.vutbr.cz • • • • • • • Why do we like exponentials. Fourier series. Basis. FS of square signals. Example from real world. Hints. Mean power and Parseval theorem. 1 By means of FS, we can decompose a periodic signal into a series of complex exponentials. ⇒ Any cosine function with an arbitrary phase can be expressed as sum of ejx + e−jx : exponentials cos(x) = 2 C1 cos(ω1 t + φ1 ) = = C1 j(ω1 t+φ1 ) 2 e + C1 −j(ω1 t+φ1 ) 2 e C1 jφ1 jω1 t e 2 e + C1 −jφ1 −jω1 t e , 2 e = where c1 = C1 jφ1 , 2 e c−1 = C1 −jφ1 2 e 2 = are complex constants. ⇒ Transfer of an exponential through an LTI system results in the original exponential scaled (multiplied) by a constant: the input signal is defined as x(t) = est , where s is a complex number. Mainly, we will be interested in the case when s is purely imaginary, s = jω. However, we will demonstrate the computation on a general complex s. 3 LTI system output is given by convolution of the input signal and the impulse response: Z +∞ Z +∞ y(t) = h(t) ⋆ x(t) = h(τ )x(t − τ )dτ = h(τ )es(t−τ ) dτ −∞ −∞ The expression es(t−τ ) can be decomposed (using equation ea+b = ea eb ) and the component independent of τ is moved in front of the integral Z +∞ Z +∞ y(t) = h(τ )est e−sτ dτ = est h(τ )e−sτ dτ. −∞ −∞ The integral becomes now a function of the complex number s and the system’s impulse response, but NOT a function of the input! Let us denote the integral as a complex function H(s). Factor est is the input, thus we can write: y(t) = est H(s), Here we see that the output is the same exponential multiplied by the constant defined as: Z +∞ H(s) = h(τ )e−sτ dτ. −∞ 4 ... what happens when we multiply complex exp. c1 ejω1 t by complex H(s)? Short recap: • Every complex number can be decomposed into a module and an agument (phase): H(s) = |H(s)|ej arg H(s) . • Multiplication rule: z1 z2 = r1 r2 ej(φ1 +φ2 ) . How will it be? We start off with: H(s)c1 ejω1 t = . . . We do nothing with ejω1 t and define a new complex constant where c′1 = H(s)c1 . As both H(s) and c1 are complex, during multiplication we multiply the modules and add up the arguments. The output of LTI system is thus a complex exponential that is scaled (wider or thinner) and has a different phase. The ”speed“ of the exponential does not change relative the original input signal. 5 jω1 t Example: complex exponential c1 e −j π 4 j100πt e = 2.5e π π jπ 4 is multiplied by H(s) = 2e π π c′1 = c1 H(s) = 2.5e−j 4 2ej 4 = 2.5 × 2e−j 4 +j 4 = 5 6 . FOURIER SERIES A periodic signal x(t) = x(t + T1 ), with fundamental period T1 , is decomposed into a series of exponentials: x(t) = +∞ X ck ejkω1 t k=−∞ ω1 is the fundamental period of the signal, ω1 = is called harmonic complex exponential. 7 2π T1 . Function ejkω1 t for k = 0, ±1, ±2 . . . Im 1 0 −1 2 1 Re 0 0 0.01 0.02 t 1 Im Im 1 0 −1 1 0 Re −1 0 0.01 −1 1 0.02 t 0 0 Re −1 0 0.01 0.02 t 0 0.02 t 0 Re −1 0 0.01 0.02 t 1 Im Im −1 0.01 0 −1 1 1 0 −1 1 0 Re 1 Im Im 1 −1 1 0 0 Re −1 0 0.01 t 0.02 0 −1 1 8 0 Re −1 0 0.01 t 0.02 Basic properties of the coefficients: • For real signals x(t): ck and c−k are always complex conjugate: ck = c⋆−k • c0 is complex conjugate with itself, thus is real: c0 ∈ ℜ. As ejkω1 t equals to 1 for k = 0, c0 must be direct component. • We can rewrite the series into the form: s(t) = c0 + ∞ X [ck ejkω1 t + c−k e−jkω1 t ] | {z } k=1 Ck cos(kω1 t + φk ) • for k > 0 – magnitude of the k-th harmonic component is Ck = 2|ck |. – initial phase of the k-th harmonic is φk = arg ck . 9 Recapitulation - basis and projection into basis Basis • we express one ’thing’ by means of some other ’thing’. • how similar is some input (vector, signal, function) to some reference. 2 x= x2 3 0 1 b2 = b1 = 1 0 2 2 =3 = 2 x2 = [0 1] x1 = [1 0] 3 3 x b2 b1 . . . scalar product 10 x1 Rotated axes b1 = y1 = y2 = 3 √1 2 √1 2 [ √12 [− √12 x √1 ] 2 b2 = 2 3 √1 ] 2 − √12 √1 2 y1 2 = 3.53 2 3 = 0.707 11 b1 x= y2 b2 How can we plot a higher dimensional space ? q x = [3 2 1 0 1 2 3 4], b1 = y1 = 5.65, similarity y2 = 2.41 4 0.4 3 0.3 1 8 [1 1 1 1 1 1 1 1], b2n = similarity. 1.5 1 2 0.2 1 0.1 0.5 0 0 5 10 0 0 5 10 0.5 0 0 5 10 0 5 10 1.5 1 0.5 0 0 −0.5 −0.5 0 5 10 −1 12 1 2 cos(2π/8n) General expression in an arbitrary dimensional space... vector representation yn = bTn x, matrix representation y = Bx 13 Properties of basis • One coefficient should not be dependent on the others - ortogonality: bTi bj = 0 • All basis are of the same ’importance’ - basis magnitude equal to 1 |bi | = 1 • Ortogonality and unit magnitude of basis gives us an orthonormal system 14 Signal and basis can be functions! • one function can be represented by means of some other function • how two functions are similar. Analogiously to the scalar product: • multiplication with the basis R P • adding up - integral for continuous signals or sum for descrete Example - what is cosine similar to ? 15 To a direct signal ? b(t) = 1 R1 0 x(t) s(t)b(t)dt = 0 ... is not similar b(t) x(t)b(t) 1 2 1 0.8 1.8 0.8 0.6 1.6 0.6 0.4 1.4 0.4 0.2 1.2 0.2 0 1 0 −0.2 0.8 −0.2 −0.4 0.6 −0.4 −0.6 0.4 −0.6 −0.8 0.2 −0.8 −1 0 0.5 1 0 0 0.5 1 −1 0 0.5 16 1 Maybe to a cosine function ? b(t) = 2 cos(2πt) x(t) 1 R1 0 s(t)b(t)dt = 1 ... is similar b(t) x(t)b(t) 2 0.8 2 1.8 1.5 0.6 1.6 1 0.4 1.4 0.5 0.2 0 1.2 0 −0.2 1 0.8 −0.5 −0.4 0.6 −1 −0.6 0.4 −1.5 −0.8 −1 0 0.5 1 −2 0.2 0 0.5 1 0 0 0.5 17 1 2x faster cosine ? b(t) = 2 cos(4πt) x(t) 1 0.8 R1 0 s(t)b(t)dt = 0 ... is not similar b(t) x(t)b(t) 2 2 1.5 1.5 1 1 0.5 0.5 0 0 −0.5 −0.5 −1 −1 −1.5 −1.5 0.6 0.4 0.2 0 −0.2 −0.4 −0.6 −0.8 −1 0 0.5 1 −2 0 0.5 1 −2 0 0.5 18 1 Now lets play with sine function s(t) = sin(2πt), ... no x(t) b(t) 1 x(t)b(t) 2 0.8 b(t) = 2 cos(2πt) 1 0.8 1.5 0.6 0.6 1 0.4 0.4 0.5 0.2 0 0.2 0 −0.2 0 −0.2 −0.5 −0.4 −0.4 −1 −0.6 −0.6 −1.5 −0.8 −1 0 0.5 1 −2 −0.8 0 0.5 1 −1 0 0.5 ⇒ we will need cosine and sine !!! 19 1 R1 0 s(t)b(t)dt = 0 Shifted sine ... s(t) = sin(2πt − π/5) R1 s(t)b1 (t)dt = −0.59 b1 (t) = 2 cos(2πt) 0 R1 s(t)b1 (t)dt = 0.81 b2 (t) = 2 sin(2πt) 0 x(t) b(t) 1 2 0.5 1 0 0 x(t)b(t) 0.5 0 −0.5 −1 −0.5 −1 −1 0 0.5 1 −2 −1.5 0 0.5 1 −2 0 b(t) 0.5 1 x(t)b(t) 2 2 1.5 1 1 0 0.5 −1 −2 0 0 0.5 1 −0.5 0 0.5 1 20 We will be working with complex exponentials ! that conjugate cosine and sine in themselves ! b1 (t) = ejωt = cos ωt + j sin ωt R coefficient calculation: c1 = x(t)b⋆1 (t)dt product of such coefficient and the base is complex... so we need to add a complex cojugate base: b−1 (t) = e−jωt = cos ωt − j sin ωt R coefficient computation: c−1 = x(t)b⋆−1 (t)dt 21 Derivation of coefficients of FS We said that a periodic function can be decomposed to the series: x(t) = +∞ X ck ejkω1 t k=−∞ The coefficients ck are computed using the formula: Z 1 x(t)e−jkω1 t dt, ck = T1 T1 R where T1 denotes integral over one period (typically, from 0 to T1 or from − T21 to also can be from 25T1 to 26T1 ) 22 T1 2 , but Plotting FS coefficients The coefficients are indexed from k = −∞ to ∞. Remember, they are tied with angular frequencies: c1 is associated with ω1 , c2 with 2ω1 Coefficients with negative indeces are associated with corresponding negative frequencies: c−1 is associated with −ω1 , c−2 with −2ω1 Negative frequency means that the exponential c−k e−jkω1 t is rotating the opposite direction that ck ejkω1 t . Their composition will give us a normal cosine Ck cos(kω1 t + φk ). 23 As the coefficients are complex numbers, we will plot their modules and aguments in separate graphs along frequency axes. Thus we are expressing a signal in frequency domain. Coefficients’ position and value will form a SPECTRUM of a signal. For a periodic signal the spectrum is descrete (composed of vertical lines). Example 1. Derive FS coefficients for signal: x(t) = 5 cos(100πt) . The basic angular frequency is ω1 = 100π. In this example we don’t integrate because we can rewrite cosine function as: x(t) = 5 j100πt 5 −j100πt e + e , 2 2 thus, the coefficients’ values are : 5 c1 = , 2 c−1 The coefficients are real. 24 5 = 2 25 Example 2. Derive FS coefficients of the signal: x(t) = 5 cos(100πt − π4 ) Again, we will manage with no integration. Either we can rewrite cosine into the form: π π 2.5e−j 4 ej100πt + 2.5e+j 4 e−j100πt , thus, for c1 and c−1 we get: −j π 4 c1 = 2.5e +j π 4 , c−1 = 2.5e OR we look at how the coefficients ck are related to the magnitude and initial phase of the harmonics (here, only one): C1 = 5 and φ1 = − π4 . C1 = 2.5, |c1 | = 2 π arg c1 = φ1 = − , 4 so −j π 4 c1 = 2.5e . Coefficient c−1 is a complex conjugate to c1 (same module, reverse angle): |c−1 | = C1 = 2.5, 2 arg c−1 = −φ1 = 26 π , 4 so π c−1 = 2.5ej 4 . 27 Example 3. . . . let’s integrate!! We have a periodic signal of square impulses: D for − ϑ ≤ t ≤ ϑ 2 2 x(t) = 0 for − T1 ≤ t < − ϑ a ϑ < t ≤ T1 2 2 2 2 with period T1 s(t) D −υ/2 υ/2 −υ/2+Τ1 Τ 1 28 t Preparation 1. — Function sinc(·) 1 0.8 sinc(x) = sin(x) x 1 for x 6= 0 sinc(x) 0.6 0.4 0.2 for x = 0 0 −2π −π 0 π 2π −0.2 −0.4 −10 ... Matlab! sinc is defined as sin(πx) πx −5 !!! 29 0 x 5 10 Preparation 2. — Computation of integral ejxy I(x) = Z b e±jxy dy −b a) for x = 0 : I(0) = 2b b) for x 6= 0 : I(x) · e±jxy = ±jx ¸b −b ejxb − e−jxb = = jx 2 ejxb − e−jxb sin bx = = 2b . x 2j bx Z b e±jxy dy = 2b sinc(bx). −b 30 Spectrum of a periodic signal of square impulses The signal is defined by ϑ, D, T1 . ck T1 2 1 T1 Z + 1 = T1 Z +ϑ 2 = − T1 2 −ϑ 2 x(t)e−jkω1 t dt D −jkω1 t De dt = T1 Z +ϑ 2 e−jkω1 t dt. −ϑ 2 When we define: t = y, b = ϑ/2 and x = kω1 , we obtain: ¶ µ ¶ µ D ϑ ϑ ϑ ϑ ck = 2 sinc kω1 = D sinc kω1 . T1 2 2 T1 2 Plotting results is not trivial :-( • Prepare graphs ω-|ck | and ω-arg(ck ). • Realize that the resulting coefficients are real numbers- either positive or negative depending on the sign of the funtion sinc. 31 • Prepare an auxiliary function (dotted) for aµgeneral ¯ ¶¯ ω (we will be placing the ¯ ¯ ϑ ϑ ¯ ω ¯¯. Note, that the principal (central) coefficients under the aux func): ¯D sinc T1 2 fold of the function is twise as wide as the side folds. Very important point is ωa , where the function touchs the axis for the first time. To estimate ωa , set the argument of the sinc equal to π: 2π ϑ ωa = π → ω a = . 2 ϑ • indicate the coefficients on the aux function at every fold of ω1 . • argument of a positive coefficients (sinc(·) > 0) is 0. Argument of a negative coefficient (sinc(·) < 0) must be ±π. Convention: for positive ω it will be +π and for negative ω it will be −π. (It will not be incorrect when its the opposite thought). 32 ω |c | =2π/T 1 k 1 Dϑ/T 1 ωa=2π/ϑ |Dϑ/T1 sinc (ϑω/2)| −5ω −4ω 1 1 −ω a −2ω −1ω 1 1 0 1ω 1 2ω 1 ω a 4ω 1 5ω 1 6ω 1 7ω 1 8ω 1 −−−> ω arg ck π −5ω −4ω −3ω −2ω −1ω 1 1 1 1 1 0 1ω1 2ω1 3ω1 4ω1 5ω1 6ω1 7ω1 8ω1 −−−> ω −π 33 c0 and mean of a signal ¯ µ ¶¯ ¯ ¯ ϑ ϑ ¯ The coefficient c0 lies in the maximum of the auxiliary function ¯D sinc ω ¯¯ for T1 2 ω = 0. Its value is thus: ϑ c0 = D . T1 We also know that the value of c0 must be equal to the direct component of the signal, which is its mean Z + T21 Z + ϑ2 1 1 1 Dϑ +ϑ x̄ = x(t)dt = Ddt = [Dt]− ϑ2 = . T 2 T1 − 21 T1 − ϑ2 T1 T1 Proved! 34 6 Example 1. D = 6, T = 1 µs, ϑ = 0.5 µs. Solution: f = 1 MHz, ω = 2 × 10 π rad/s, 1 1 1 ¯ ¯ ¡ ϑ ¢¯ ¯ ϑ auxiliary function: ¯D T1 sinc 2 ω ¯ = |3sinc(0.25 × 10−6 ω)|. It touches zero when 0.25 × 10−6 ω = kπ, so ω = k4 × 106 π. 35 6 Example 2. D = 6, T = 1 µs, ϑ = 0.25 µs. Solution: f = 1 MHz, ω = 2 × 10 π rad/s, 1 1 1 ¯ ¯ ¡ ϑ ¢¯ ¯ ϑ auxiliary function: ¯D T1 sinc 2 ω ¯ = |1.5sinc(0.125 × 10−6 ω)|. It touches zeros for 0.125 × 10−6 ω = kπ, so for ω = k8 × 106 π. 36 Example 3. ... same as example 1 but the signal is normalized (mean is 0) Same result with the only difference: c0 is equal to 0. 37 Again example 1. – how it is composed: k = 0, ±1, ±3, ±5 4 4 3 3 2 −1 0 2 −1 10 1 −6 x 10 5 0 1 −6 x 10 2 5 0 −2 2 0 0 0 −2 −1 0 1 −6 −5 x 10 −1 5 0 1 −6 x 10 −5 −1 10 0 1 −6 x 10 2 5 0 −2 2 0 0 0 −2 −1 0 1 −6 −5 x 10 −1 5 0 1 −6 x 10 −5 −1 10 0 1 −6 x 10 2 5 0 −2 2 0 0 0 −2 −1 0 1 −6 −5 x 10 −1 0 1 −6 x 10 38 −5 −1 0 1 −6 x 10 k = ±7, ±9, ±11, ±13 5 10 2 5 0 −2 2 0 0 0 −2 −1 0 1 −6 −5 x 10 −1 5 0 1 −6 x 10 −5 −1 10 0 1 −6 x 10 2 5 0 −2 2 0 0 0 −2 −1 0 1 −6 −5 x 10 −1 5 0 1 −6 x 10 −5 −1 10 0 1 −6 x 10 2 5 0 −2 2 0 0 0 −2 −1 0 1 −6 −5 x 10 −1 5 0 1 −6 x 10 −5 −1 10 0 1 −6 x 10 2 5 0 −2 2 0 0 0 −2 −1 0 1 −6 −5 x 10 −1 0 1 −6 x 10 39 −5 −1 0 1 −6 x 10 What else can we decompose ? Wovel ’a’, Fs = 16 kHz, selected 1 period, repeted 50× ⇒ xx.wav. Coefficients of FS: yytill14.wav – k = 0, ±1, ±2, ±3, ±4. yytill19.wav – k = 0, ±1, ±2, ±3, ±4, ±5, ±6, ±7, ±8, ±9. etc. . . 1 0.5 0 −0.5 0 50 100 150 0.08 0.06 0.04 0.02 0 0 5 10 15 20 0 5 10 15 20 25 30 35 40 45 50 25 30 35 40 45 50 4 2 0 −2 −4 40 0.05 0.2 0 0 −0.05 0.10 50 100 −0.2 10 150 0 100 150 50 100 150 50 100 150 50 100 150 50 100 150 50 100 150 50 100 150 50 100 150 0 −0.1 0.10 50 100 −1 10 150 0 0 −0.1 0.10 50 100 −1 10 150 0 0 −0.1 0.10 50 100 −1 10 150 0 0 −0.1 0.10 50 100 −1 10 150 0 0 −0.1 0.10 50 100 −1 10 150 0 0 −0.1 0.10 50 100 −1 10 150 0 −0.1 50 0 0 50 100 −1 150 41 0 Properties of spectra of periodic signals x(t) ck linearity a xa (t) + b xb (t) a ca,k + b cb,k time shift x(t − τ ) ck e−jkω1 τ scale of time axis x(mt) ck 42 A little bit more on time shif Z 1 x(t)e−jkω1 t dt. FS coefficients of a shifted FS coefficients are computed as ck = T1 T1 signal x(t − τ ) are then: ¯ ¯ ¯ r =t−τ ¯ ¯ ¯ Z Z ¯ ¯ 1 1 x(t − τ )e−jkω1 t dt = ¯¯ t = r + τ ¯¯ = x(r)e−jkω1 (r+τ ) dr = ck,τ = T1 T1 ¯ ¯ T1 T1 ¯ dr = dt ¯ = 1 T1 Z x(r)e−jkω1 r e−jkω1 τ dr = e−jkω1 τ ck T1 How have the coefficients changed? (Recall, complex numbers multiplication) • magnitude - NO, as |e−jkω1 τ | = 1: |ck,τ | = ck . • phase - YES - shift by factor −kω1 τ : arg ck,τ = arg ck − kω1 τ . 43 Time shift – example signal x(t) from example 1.: D = 6, T1 = 1 µs, ϑ = 0.5 µs. Shifted signal x(t − 0.25 × 10−6 ): coefficients are multiplied by |e−jkω1 τ | = 1 2π π −6 τ = −k (0.25 × 10 ) = −k :−kω1 τ = −k 2π −6 T1 1×10 2. 44 45 Mean power of periodic signals – Parseval theorem 1 Ps = T1 Z |x(t)|2 dt = T1 +∞ X |ck |2 . k=−∞ The signal power thus can be calculated not only through integration of | · |2 in time, but also by summing up squares of all FS coefficients. Summation is usually easier realized than integration. Why? What is the power of k-th complex exponential: Z Z 1 1 |ck ejkω1 t |2 dt = |ck |2 dt = |ck |2 T1 T1 T1 T1 The power is then |ck |2 , when powers of all exponentials are summed, we get overall mean power Ps of the signal. 46 Convergency of FS 3 Dirichlet properties: 1. x(t) must be absolutelly integrable: Z |x(t)| < ∞ T1 not fullfilled for example for: x(t) = 1/t for 0 < t ≤ 1, periodic with T1 = 1. 2. x(t) must have finitly variable: a finit interval must contain a finit number of minima and maxima. not fullfilled for example for: x(t) = sin 2π t for 0 < t ≤ 1, periodic with T1 = 1. 3. on finite interval the signal must have finite number of discontinuities. We are going to work with signals that fully satisfy these restrictions. 47 Conclusions • Spectrum of periodic signal is discrete. • When signal is narrowed — spectrum is spread. • When signal is delayed phase is dropped downward, when signal is advanced phase is tipped upward 48