16
Fourier Series, Fourier Transforms, and Periodic Response to Periodic Forcing CEE 541. Structural Dynamics Department of Civil and Environmental Engineering Duke University Henri P. Gavin Fall, 2020 This document describes methods to analyze the steady-state forced-response of a simple oscillator to general periodic loading. The analysis is carried out using Fourier series approx- imations to the periodic external forcing and the resulting periodic steady-state response. 1 Fourier Series for Real-Valued Functions Any real-valued function, f (t), that is: • periodic, with period T , ··· = f (t - 2T )= f (t - T )= f (t)= f (t + T )= f (t +2T )= ··· • square-integrable T 0 f 2 (t)dt < . may be represented as a series expansion of sines and cosines, in a Fourier series, ˆ f (t; a, b)= 1 2 a 0 + q=1 a q cos 2πqt T + q=1 b q sin 2πqt T , (1) where the Fourier coefficients, a q and b q are given by the Fourier integrals, a q = 2 T T 0 f (t) cos 2πqt T dt , q =1, 2,... (2) b q = 2 T T 0 f (t) sin 2πqt T dt , q =1, 2,... (3) The Fourier series ˆ f (t; a, b) is a least-squares fit to the function f (t). This may be shown by first defining the error function, e(t)= f (t) - ˆ f (t; a, b), the quadratic error criterion, J (a, b)= T 0 e 2 (t)dt, and finding the Fourier coefficients by solving the linear equations resulting from minimizing J (a, b) with respect to the coefficients a and b. (by setting ∂J (a, b)/∂ a and ∂J (a, b)/∂ b equal to zero). So doing, J (a, b) = T 0 f (t) - ˆ f (t; a, b) 2 dt = T 0 f 2 (t) - 2f (t) ˆ f (t; a, b)+ ˆ f 2 (t; a, b) dt. (4)

Fourier Series, Fourier Transforms, and Periodic Response

  • Upload
    others

  • View
    18

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Fourier Series, Fourier Transforms, and Periodic Response

Fourier Series, Fourier Transforms, andPeriodic Response to Periodic Forcing

CEE 541. Structural DynamicsDepartment of Civil and Environmental Engineering

Duke University

Henri P. GavinFall, 2020

This document describes methods to analyze the steady-state forced-response of a simpleoscillator to general periodic loading. The analysis is carried out using Fourier series approx-imations to the periodic external forcing and the resulting periodic steady-state response.

1 Fourier Series for Real-Valued Functions

Any real-valued function, f(t), that is:

• periodic, with period T ,

· · · = f(t− 2T ) = f(t− T ) = f(t) = f(t+ T ) = f(t+ 2T ) = · · ·

• square-integrable ∫ T

0f 2(t)dt <∞.

may be represented as a series expansion of sines and cosines, in a Fourier series,

f(t; a,b) = 12a0 +

∞∑q=1

aq cos 2πqtT

+∞∑q=1

bq sin 2πqtT

, (1)

where the Fourier coefficients, aq and bq are given by the Fourier integrals,

aq = 2T

∫ T

0f(t) cos 2πqt

Tdt , q = 1, 2, . . . (2)

bq = 2T

∫ T

0f(t) sin 2πqt

Tdt , q = 1, 2, . . . (3)

The Fourier series f(t; a,b) is a least-squares fit to the function f(t). This may be shownby first defining the error function, e(t) = f(t) − f(t; a,b), the quadratic error criterion,J(a,b) =

∫ T0 e2(t)dt, and finding the Fourier coefficients by solving the linear equations

resulting from minimizing J(a,b) with respect to the coefficients a and b. (by setting∂J(a,b)/∂a and ∂J(a,b)/∂b equal to zero). So doing,

J(a,b) =∫ T

0

(f(t)− f(t; a,b)

)2dt

=∫ T

0

(f 2(t)− 2f(t)f(t; a,b) + f 2(t; a,b)

)dt. (4)

Page 2: Fourier Series, Fourier Transforms, and Periodic Response

2 CEE 541. Structural Dynamics – Duke University – Fall 2020 – H.P. Gavin

Setting ∂J/∂a0 equal to zero results in

0 =∫ T

0

∂a0

[f 2(t)− 2f(t)f(t; a,b) + f 2(t; a,b)

]dt

= −2∫ T

0f(t) ∂

∂a0f(t; a,b)dt+ 2

∫ T

0f(t; a,b) ∂

∂a0f(t; a,b)dt

= −2∫ T

0f(t) · 1

2dt+ 2∫ T

0

12a0 +

∞∑q=1

aq cos 2πqtT

+∞∑q=1

bq sin 2πqtT

· 12dt

= −∫ T

0f(t)dt+

∫ T

0

12a0dt+

∞∑q=1

aq

∫ T

0cos 2πqt

Tdt+

∞∑q=1

bq

∫ T

0sin 2πqt

Tdt

= −∫ T

0f(t)dt+ 1

2a0T +∞∑q=1

aq · 0 +∞∑q=1

bq · 0

From which,

a0 = 2T

∫ T

0f(t) dt. (5)

Note here that (a0/2) is the average value of f(t).Proceeding with the rest of the a coefficients, setting ∂J(a,b)/∂ak equal to zero results in

0 =∫ T

0

∂ak

[f 2(t)− 2f(t)f(t; a,b) + f 2(t; a,b)

]dt

= −2∫ T

0f(t) ∂

∂akf(t; a,b)dt+ 2

∫ T

0f(t; a,b) ∂

∂akf(t; a,b)dt

= −∫ T

0f(t) cos 2πkt

Tdt+

∫ T

0

a0

2 +∞∑q=1

aq cos 2πqtT

+∞∑q=1

bq sin 2πqtT

cos 2πktT

dt

= −∫ T

0f(t) cos 2πkt

Tdt+

a0

2

∫ T

0cos 2πqt

Tdt+

∞∑q=1

aq

∫ T

0cos 2πqt

Tcos 2πkt

Tdt+

∞∑q=1

bq

∫ T

0sin 2πqt

Tcos 2πkt

Tdt

= −∫ T

0f(t) cos 2πkt

Tdt+ a0

2 · 0 + ak

∫ T

0cos2 2πkt

Tdt+

∞∑q=1

bq · 0

= −∫ T

0f(t) cos 2πkt

Tdt+ 0 + ak ·

T

2 + 0

From which,

ak = 2T

∫ T

0f(t) cos 2πkt

Tdt. (6)

In a completely similar fashion, ∂J(a,b)/∂bk = 0 results in

bk = 2T

∫ T

0f(t) sin 2πkt

Tdt. (7)

cbnd H.P. Gavin February 14, 2022

Page 3: Fourier Series, Fourier Transforms, and Periodic Response

Fourier Series and Periodic Response to Periodic Forcing 3

The derivation of the Fourier integrals (equations (5), (6), and (7)) makes use of orthogonalityproperties of sine and cosine functions.

∫ T

0sin2

(nπt

T

)dt = T

2 , n = 1, 2, · · ·∫ T

0cos2

(nπt

T

)dt = T

2 , n = 1, 2, · · ·∫ T

0sin

(nπt

T

)sin

(mπt

T

)dt = 0 , n 6= m , n,m = 1, 2, · · ·∫ T

0cos

(nπt

T

)cos

(mπt

T

)dt = 0 , n 6= m , n,m = 1, 2, · · ·∫ T

0sin

(nπt

T

)cos

(mπt

T

)dt = 0 , n 6= m , n,m = 1, 2, · · ·

1.1 The complex exponential form of Fourier series

Recall the trigonometric identities for complex exponentials, eiθ = cos θ+i sin θ. Definingthe complex scalar F as F = 1

2(a− ib), and its complex conjugate, F ∗ as F ∗ = 12(a+ ib), it

is not hard to show that

Feiθ + F ∗e−iθ = a cos θ + b sin θ. (8)

Note that the left hand side of equation (8) is the sum of two complex conjugate values, andthat the right hand side is the sum of two real values. So the imaginary parts on the leftcancel out and we can see that the sum of complex conjugates can be used to express thereal Fourier series given in equation (1). Substituting equation (8) into equation (1),

f(t; a,b) = 12a0 +

∞∑q=1

[aq cos 2πqt

T+ bq sin 2πqt

T

]

= 12a0 +

∞∑q=1

[12(aq − ibq) exp

[i2πqTt]

+ 12(aq + ibq) exp

[−i2πq

Tt]]

= 12a0 +

∞∑q=1

Fq exp[i2πqTt]

+∞∑q=1

F ∗q exp[−i2πq

Tt]

= 12a0 +

∞∑q=1

Fq exp[i2πqTt]

+−1∑

q=−∞F ∗−q exp

[i2πqTt]

=∞∑

q=−∞Fq exp

[i2πqTt]

=∞∑

q=−∞Fq e

iωqt (9)

where the Fourier frequency ωq is 2πq/T , F0 = 12a0, Fq = 1

2(aq − ibq), and F ∗−q = Fq. Thecondition F ∗−q = Fq holds for the Fourier series of any real-valued function that is periodic

cbnd H.P. Gavin February 14, 2022

Page 4: Fourier Series, Fourier Transforms, and Periodic Response

4 CEE 541. Structural Dynamics – Duke University – Fall 2020 – H.P. Gavin

and integrable. Going the other way,

f(t; F) =q=+∞∑q=−∞

Fq eiωqt

= F0 +q=−1∑q=−∞

Fq eiωqt +

q=+∞∑q=1

Fq eiωqt

= F0 +q=+∞∑q=1

F−qe−iωqt +

q=+∞∑q=1

Fqeiωqt

= F0 +∞∑q=1

[Fq e

iωqt + F−q e−iωqt

]

= F0 +∞∑q=1

[(F ′q + iF ′′q ) (cosωqt+ i sinωqt) + (F ′q − iF ′′q ) (cosωqt− i sinωqt)

]

= F0 +∞∑q=1

[2F ′q cosωqt− 2F ′′q sinωqt

]So, the real part of Fq, F ′q, is half of aq, the imaginary part of Fq, F ′′q , is half of −bq, andFq = F ∗−q. The real Fourier coefficients, aq, are even about q = 0 and the imaginary Fouriercoefficients, bq, are odd about q = 0. In other words, the complex Fourier coefficients of areal valued function are Hermetian symmetric.

Just as the Fourier expansion may be expressed in terms of complex exponentials, thecoefficients Fq may also be written in this form.

Fq = 12 (aq − ibq) = 1

T

∫ T

0f(t)

[cos 2πq

Tt− i sin 2πq

Tt]

= 1T

∫ T

0f(t) exp

[−i2πq

Tt]dt (10)

Since the integrand, f(t)e−iωqt, of the Fourier integral is periodic in T , the limits of integrationcan be shifted arbitrarily without affecting the resulting Fourier coefficients.∫ T

0f(t)e−iωqt dt =

∫ τ

0f(t)e−iωqt dt+

∫ T+τ

τf(t)e−iωqt dt−

∫ T+τ

Tf(t)e−iωqt dt.

But, since the integrand is periodic in T ,∫ τ

0f(t)e−iωqt dt =

∫ T+τ

Tf(t)e−iωqt dt .

So, the interval of integration can be shifted arbitrarily.∫ T

0f(t)e−iωqt dt =

∫ T+τ

0+τf(t)e−iωqt dt. (11)

On the other hand, shifting the function in time, affects the relative values of aq and bq(i.e., the phase the the complex coefficient Fq), but does not affect the magnitude, |Fq| =12

√a2q + b2

q. If f(t) = ∑Fqe

−iωqt, then f(t + τ) = ∑Fqe

−iωq(t+τ) = ∑ (Fqe−iωqτ ) e−iωqt, and|Fq| = |Fqe−iωqτ |.

cbnd H.P. Gavin February 14, 2022

Page 5: Fourier Series, Fourier Transforms, and Periodic Response

Fourier Series and Periodic Response to Periodic Forcing 5

2 Fourier Integrals in Maple

The Fourier integrals for real valued functions (equations (6) and (7)) can be evaluatedusing symbolic math software, such as Maple or Mathematica.

2.1 a periodic square wave function: f(t) = sgn(t−π) on 0 < t < 2π and f(t) = f(t+n(2π))

> assume (k::integer);> f := signum(t-Pi);

f := signum(t - Pi)> ak := (2/(2*Pi)) * int(f*cos(2*Pi*k*t/(2*Pi)),t=0..2*Pi);

ak := 0> bk := (2/(2*Pi)) * int(f*sin(2*Pi*k*t/(2*Pi)),t=0..2*Pi);

k˜2 ( (-1) - 1 )

bk := ----------------Pi k˜

2.2 a periodic sawtooth function: f(t) = t− π on 0 < t < 2π and f(t) = f(t+ n(2π))

> assume (k::integer);> f := t-Pi;

f := t - Pi> ak := (2/(2*Pi)) * int(f*cos(2*Pi*k*t/(2*Pi)),t=0..2*Pi);

ak := 0> bk := (2/(2*Pi)) * int(f*sin(2*Pi*k*t/(2*Pi)),t=0..2*Pi);

2bk := - ----

2.3 a periodic triangle function: f(t) = π/2 − (t − π) sgn(t − π) on 0 < t < 2π andf(t) = f(t+ n(2π))

> assume (k::integer);> f := Pi/2 - (t-Pi) * signum(t-Pi);

f := (Pi/2) - (t - Pi) signum(t - Pi)> ak := (2/(2*Pi)) * int(f*cos(2*Pi*k*t/(2*Pi)),t=0..2*Pi);

k˜2 ( (-1) - 1 )

ak := ----------------2

Pi k˜> bk := (2/(2*Pi)) * int(f*sin(2*Pi*k*t/(2*Pi)),t=0..2*Pi);

bk := 0

cbnd H.P. Gavin February 14, 2022

Page 6: Fourier Series, Fourier Transforms, and Periodic Response

6 CEE 541. Structural Dynamics – Duke University – Fall 2020 – H.P. Gavin

3 Fourier Transforms

Recall for periodic functions of period, T , the Fourier series expansion may be written

f(t) =q=∞∑q=−∞

Fq eiωqt , (12)

where the Fourier coefficients, Fq, have the same units as f(t), and are given by the Fourierintegral,

Fq = 1T

∫ T/2

−T/2f(t) e−iωqt dt , (13)

in which the limits of integration have been shifted by τ = −T/2.

Now, consider a change of variables, by introducing the definition of a frequency incre-ment, ∆ω, and a scaled amplitude, F (ωq).

∆ω ∆= ω1 = 2πT

(ωq = q ∆ω) (14)

F (ωq) ∆= TFq = 2π∆ωFq (15)

Where the scaled amplitude, F (ωq), has units of f(t) · t or f(t)/ω.

Using these new variables,

f(t) = 12π

q=∞∑q=−∞

F (ωq) eiωqt ∆ω , (16)

F (ωq) =∫ T/2

−T/2f(t) e−iωqt dt . (17)

Finally, taking the limit as T →∞, implies ∆ω → dω and ∑→ ∫f(t) = 1

∫ ∞−∞

F (ω) eiωt dω , (18)

F (ω) =∫ ∞−∞

f(t) e−iωt dt . (19)

These expressions are the famous Fourier transform pair. Equation (18) is commonly calledthe inverse Fourier transform and equation (19) is commonly called the forward Fouriertransform. They differ only by the sign of the exponent and the factor of 2π.

By convention, the forward fast Fourier transform (FFT) of an N -point time series ofduration T (xk = x((k − 1)∆t), k = 1, · · · , N) scales the N , complex-valued, Fourier am-plitudes/coefficients as follows: FFT(x) = X(ωq)/∆t = NXq, where the Fourier-transformfrequencies, ωq, are given by ωq = 2πq/T , and are sorted as follows:q = 0, · · · , N/2,−N/2 + 1, · · · ,−1.

cbnd H.P. Gavin February 14, 2022

Page 7: Fourier Series, Fourier Transforms, and Periodic Response

Fourier Series and Periodic Response to Periodic Forcing 7

4 Fourier Transform Pairs

Here is a table of a few Fourier transform pairs that can be used to derive other Fouriertransform pairs without evaluating the Fourier integral.

f(t) F (ω)

definition 12π

∫ ∞−∞

F (ω) eiωt dω∫ ∞−∞

f(t) e−iωt dt

scaling time f(t/τ) |τ | F (ωτ)shifting time f(t− τ) F (ω) e−iωτ

Dirac delta δ(t) 1cosine cos(ωot) π [ δ(ω + ωo) + δ(ω − ωo) ]sine sin(ωot) iπ [ δ(ω + ωo)− δ(ω − ωo) ]real exponential 1

Tet/T (t ≥ 0) 1/(1 + iωT )

imaginary exponential eiωot 2π δ(ω − ωo)exponential factor f(t) eiωot F (ω − ωo)Gaussian e−t

2/2 √2π e−ω2/2

derivitives in time dn

dtnf(t) (iω)n F (ω)

derivitives in frequency −(it)nf(t) dn

dωnF (ω)

signum in time sign(t) 2iω

signum in frequency i

πtsign(ω)

The Fourier transform of the Gaussian distribution,

f(t) = 1√2πσ

exp[−1

2

(t− µσ

)2],

can be derived using the information in the table above. First, scaling time in e−t2/2, if

g(t) = 1√2πσ

exp[−1

2

(t

σ

)2]then

G(ω) = exp[−1

2 (ωσ)2].

And next, shifting time, if

f(t) = 1√2πσ

exp[−1

2

(t− µσ

)2],

thenF (ω) = exp

[−1

2 (ωσ)2]

exp [−iωµ] = exp[−1

2((ωσ)2 + iωµ

)].

The Fourier transform of a Gaussian centered at zero is a Gaussian centered at zero!

cbnd H.P. Gavin February 14, 2022

Page 8: Fourier Series, Fourier Transforms, and Periodic Response

8 CEE 541. Structural Dynamics – Duke University – Fall 2020 – H.P. Gavin

5 Fourier Approximation

Any periodic function may be approximated as a truncated series expansion of Q sinesand Q cosines, as a Fourier series,

f(t) = 12a0 +

Q∑q=1

aq cos 2πqtT

+Q∑q=1

bq sin 2πqtT

, (20)

where the Fourier coefficients, aq and bq may be found by solving the Fourier integrals,

aq = 2T

∫ T/2

−T/2f(t) cos 2πqt

Tdt , q = 1, 2, . . . , Q (21)

bq = 2T

∫ T/2

−T/2f(t) sin 2πqt

Tdt , q = 1, 2, . . . , Q (22)

The Fourier approximation (20) may also be represented using complex exponential notation.

f(t) =q=Q∑q=−Q

Fq eiωqt = 1

T

q=Q∑q=−Q

F (ωq) eiωqt (23)

where eiωqt = cosωqt+ i sinωqt, ωq = 2πq/T , Fq = 12(aq − ibq), Fq = F ∗−q, and

Fq = 1T

∫ T/2

−T/2f(t) e−iωqt dt . (24)

The accuracy of Fourier approximations of non-sinusoidal functions increases with thenumber of terms, Q, in the series. Especially for time series that are discontinuous in time,such as square-waves or saw-tooth waves, Fourier approximations, f(t), will contain a degreeof over-shoot at the discontinuity and will oscillate about the approximated function f(t).This is called Gibb’s phenomenon. Examples in Section 8 demonstrate this effect for squarewaves and triangle waves.

The response of a system described by a frequency response function H(ω) to arbitraryperiodic forces described by a Fourier series may be found in the frequency domain,

Xq = H(ωq) Fq , (25)

or in the time domain,

x(t) =q=Q∑q=−Q

H(ωq) Fq eiωqt = 1T

q=Q∑q=−Q

H(ωq) F (ωq) eiωqt . (26)

cbnd H.P. Gavin February 14, 2022

Page 9: Fourier Series, Fourier Transforms, and Periodic Response

Fourier Series and Periodic Response to Periodic Forcing 9

6 Discrete Fourier Transform

If the function f(t) is represented by N uniformly-spaced points in time, tn = (n)(∆t),(n = 0, · · · , N−1), the N Fourier coefficients are computed by the discrete Fourier transform(DFT),

Fq = 1N

N−1∑n=0

f(tn) · exp[−i2πqn

N

], (27)

The frequency increment ∆f in the DFT is 1/(N∆t) Hertz, and the highest frequency is1/(2∆t) Hertz, the so-called Nyquist frequency.

Note that the exponentials in the DFT, (27), are periodic in N points.

exp[−i2πqn

N

]= exp

[−i2πqn

N+ 2π

]= exp

[−i2π(q −N)n

N

]

Further, referring to equation (11), as long as the set of frequency indices, q, contain Nconsecutive points, the indices may be shifted arbitrarily.

q ∈ −N/2 + 1, · · · , −1, 0, 1, 2, · · · , N/2− 1, N/2 q ∈ 0, · · · , N/2− 2, N/2− 1, N/2, −N/2 + 1, · · · , −2, −1 q ∈ 0, · · · , N/2− 2, N/2− 1, N/2, N/2 + 1, · · · , N − 2, N − 1

The N -point discrete Fourier approximation is computed by the inverse discrete Fouriertransform,

f(tn) =N/2∑

q=−N/2+1Fq · exp

[i2πqnN

]=

N−1∑q=0

Fq · exp[i2πqnN

](28)

With the normalization given in equations (27) and (28), the mean square in the time domainis the sum-square of the Fourier amplitudes.

1N

N−1∑n=0

f 2n =

N−1∑q=0|Fq|2,

The number of operations required to compute a DFT (equation (27)) increases withN2. The fast Fourier transform1 (FFT) algorithm computes the DFT by simply scaling andre-ordering the sequence fn. The number of operations required to compute a DFT usingthe FFT algorithm increases with N log2(N): if it takes 1 minute to compute an FFT withN = 106, it would take almost 35 days to carry out the same DFT using equation (27)!

By convention, the fast Fourier transform (FFT) computes the DFT without the (1/N)factor. Also, by convention, the Fourier frequencies, ωq = 2πq/T are sorted as follows: q ∈0, 1, · · · , N/2,−N/2 + 1, · · · ,−2,−1. Here is an animation for the steps in the Danielson-Lanczos FFT algorithm: http://www.duke.edu/∼hpgavin/StructuralDynamics/fft anim.m.

1Heideman, Michael T.; Johnson, Don H.; Burrus, C. Sidney (1985-09-01). “Gauss and the history ofthe fast Fourier transform,” Archive for History of Exact Sciences, 34(3): 265-277. doi:10.1007/BF00348431

cbnd H.P. Gavin February 14, 2022

Page 10: Fourier Series, Fourier Transforms, and Periodic Response

10 CEE 541. Structural Dynamics – Duke University – Fall 2020 – H.P. Gavin

7 Fourier Series and Periodic Responses of Dynamic Systems

The response of a system described by a frequency response function H(ω) to arbitraryperiodic forces f(t), described by a Fourier series f(t) = ∑

Fq exp[iωqt], may be representedin the frequency domain as Fourier coefficients Xq = H(ωq)Fq, or in the time domain as aFourier series x(t) = ∑

Xq exp[iωqt].

Complex exponential notation allows us to directly determine the steady-state periodicresponse to general periodic forcing, in terms of both the magnitude of the response and thephase of the response. Recall the relationship between the complex magnitudes X and Ffor a sinusoidally-driven spring-mass-damper oscillator is

Xq = H(ωq) Fq = 1(k −mω2

q ) + i(cωq)Fq (29)

The function H(ω) is called the frequency response function of a simple oscillator relating theinput f(t) to the output x(t). The frequency response function H(ω) for any linear dynamicsystem (such as a simple oscillator) may be derived from the system’s differential equations.

By definition for any linear dynamic system, if the response to f1(t) is x1(t), and if theresponse to f2(t) is x2(t), then the response to c1f1(t) + c2f2(t) is c1x1(t) + c2x2(t). Moregenerally, then,

x(t) =q=∞∑q=−∞

H(ωq) Fq eiωqt =q=∞∑q=−∞

1(k −mω2

q ) + i(cωq)Fq e

iωqt (30)

Equivalently, the periodic response can be expressed in terms of the Fourier series coefficientsaq and bq (equation (1)),

x(t) = 12a0/k +

∞∑q=1

1/k(1− Ω2

q)2 + (2ζΩq)2 ·[ (aq(1− Ω2

q)− bq(2ζΩq))

cosωqt+(aq(2ζΩq) + bq(1− Ω2

q))

sinωqt]

= 12a0/k +

∞∑q=1

1/k√(1− Ω2

q)2 + (2ζΩq)2· [ aq cos(ωqt+ θq) + bq sin(ωqt+ θq) ] (31)

where ωq = 2πq/T , Ωq = ωq/ωn, and tan θq = −2ζΩq/(1− Ω2q).

For this frequency response function H(ω), the series expansion for the response x(t)converges with fewer terms than the Fourier series for the external forcing, because |H(ωq)|decreases with ω. (In this example |H(ω)| decreases as 1/ω2).

Note that ωq is not the same symbol as ωn. The symbol ωn denotes the natural frequency.(The subscript n is not italicized because it does denote an index number.) The symbolωq = 2πq/T is the frequency of a Fourier component of a periodic forcing function of periodT , and q denotes the qth term in the series.

cbnd H.P. Gavin February 14, 2022

Page 11: Fourier Series, Fourier Transforms, and Periodic Response

Fourier Series and Periodic Response to Periodic Forcing 11

8 Examples

In the following examples, the external forcing is periodic with a period, T , of 2π (sec-onds). For functions periodic in 2π seconds, the frequency increment in the Fourier series(∆ω of equation (14)) is 1 radian/second. So in this case, the frequency index number, q, isalso the frequency, ωq, in radians per second. (Though in general, ωq = 2πq/T .)

The system is a forced spring-mass-damper oscillator,

x(t) + 2ζωnx(t) + ωn2x(t) = 1

mf ext(t) . (32)

The complex-valued frequency response function from the external force, f ext(t), to theresponse displacement, x(t), is given by

H(ω) = 1/ωn2

1− Ω2 + i 2ζΩ , (33)

where Ω is the frequency ratio, ω/ωn,

In the following three numerical examples, ωn = 10 rad/s, ζ = 0.1, m = 1 kg, andQ = 16 terms. The three examples consider external forcing in the form of a square-wave, asawtooth-wave, and a triangle-wave. In each example six plots are provided.

In the (a) plots, the solid line represents the exact form of f(t), the dashed lines representthe real-valued form of the Fourier approximation and the complex-valued form of the Fourierapproximation, and the circles represent 2Q sample points of the function f(t) for use in fastFourier transform (FFT) computations. The two dashed lines are exactly equal.

In the (b) plots, the triangles show the values of the Fourier coefficients, Fq, found byevaluating the Fourier integral, equation (24), and the circles represent the Fourier coefficientscomputed by the FFT. They are nearly (not exactly) identical,

In the (c) plots, the red solid lines show the cosine terms of the Fourier series and theblue dashed lines show the sine terms of the Fourier series.

The (d) and (f) plots show the magnitude and phase of the transfer function, H(ω) as asolid line, the Fourier coefficients, Fq, as the green circles, and H(ωq)Fq as the blue circles.

In the (e) plots, the solid line represents the true analytical solution for x(t) representedby equation (30), the circles represent the real part of the result of the inverse FFT calcula-tion, and the dots represent the imaginary part of the result of the inverse FFT calculation(which are nearly exactly zero, as they should be). The FFT calculation with 16 coefficientsis close to the analytical solution.

The numerical details involved in the correct representation of periodic functions andfrequency indexing for FFT computations are provided in the attached Matlab code.

cbnd H.P. Gavin February 14, 2022

Page 12: Fourier Series, Fourier Transforms, and Periodic Response

12 CEE 541. Structural Dynamics – Duke University – Fall 2020 – H.P. Gavin

8.1 Example 1: square wave

The external forcing is given by

f ext(t) = sgn(t− π) ; 0 ≤ t < 2π (34)

The Fourier coefficients for the real-valued Fourier series are:aq = 0 and bq = (2/(πq)) (−1q − 1).

(a)-1.5

-1

-0.5

0

0.5

1

1.5

0 1 2 3 4 5 6

funct

ion, f(

t), (N

)

time, t, (s)

true

sampled

real Fourier approx

complex Fourier approx

(b)-0.2

0

0.2

0.4

0.6

0.8

0 2 4 6 8 10 12 14 16

Fouri

er

coeffi

cients

, F(

w),

(N

)

frequency, ω, (rad/s)

real(F)

imag(F)

real(FFT(f))

imag(FFT(f))

(c)-1.5

-1

-0.5

0

0.5

1

1.5

0 1 2 3 4 5 6

cosi

ne a

nd s

ine t

erm

s

time, t, (s) (d)10-4

10-3

10-2

10-1

100

0 2 4 6 8 10 12 14 16

frequency

resp

onse

frequency, ω, (rad/s)

|F|

|H|

|H*F|

(e)-0.03

-0.02

-0.01

0

0.01

0.02

0.03

0 1 2 3 4 5 6

resp

onse

, x,

(m

)

time, t, (s)

x(t) - complex Fourier series

real(x(t)) - FFT

imag(x(t)) - FFT

(f)-200

-150

-100

-50

0

50

100

150

200

0 2 4 6 8 10 12 14 16

phase

lead, (d

egre

es)

frequency, ω, (rad/s)

Figure 1. (a): — = fext(t); -- = f ext(t). (b): 4= Re(Fq);4= Im(Fq); o = Fq from FFT. (c):— = cosine components, — = sine components. (d): — : |H(ω)|; o = |Fq|; o = |H(ωq)Fq|.(e): — = x(t); o = Re(x(t)) from IFFT; · · · = Im(x(t)) from IFFT. (f): — = phase of H(ω);o = phase of Fq; o = phase of H(ωq)Fq.

cbnd H.P. Gavin February 14, 2022

Page 13: Fourier Series, Fourier Transforms, and Periodic Response

Fourier Series and Periodic Response to Periodic Forcing 13

8.2 Example 2: sawtooth wave

The external forcing is given by

f ext(t) = t− π ; 0 ≤ t < 2π (35)

The Fourier coefficients for the real-valued Fourier series are:aq = 0 and bq = −(2/q).

(a)-4

-3

-2

-1

0

1

2

3

4

0 1 2 3 4 5 6

funct

ion, f(

t), (N

)

time, t, (s)

true

sampled

real Fourier approx

complex Fourier approx

(b)-0.2

0

0.2

0.4

0.6

0.8

1

0 2 4 6 8 10 12 14 16

Fouri

er

coeffi

cients

, F(

w),

(N

)

frequency, ω, (rad/s)

real(F)

imag(F)

real(FFT(f))

imag(FFT(f))

(c)-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

0 1 2 3 4 5 6

cosi

ne a

nd s

ine t

erm

s

time, t, (s) (d)10-4

10-3

10-2

10-1

100

0 2 4 6 8 10 12 14 16

frequency

resp

onse

frequency, ω, (rad/s)

|F|

|H|

|H*F|

(e)-0.08

-0.06

-0.04

-0.02

0

0.02

0.04

0 1 2 3 4 5 6

resp

onse

, x,

(m

)

time, t, (s)

x(t) - complex Fourier series

real(x(t)) - FFT

imag(x(t)) - FFT

(f)-200

-150

-100

-50

0

50

100

0 2 4 6 8 10 12 14 16

phase

lead, (d

egre

es)

frequency, ω, (rad/s)

Figure 2. (a): — = fext(t); -- = f ext(t). (b): 4= Re(Fq);4= Im(Fq); o = Fq from FFT. (c):— = cosine components, — = sine components. (d): — : |H(ω)|; o = |Fq|; o = |H(ωq)Fq|.(e): — = x(t); o = Re(x(t)) from IFFT; · · · = Im(x(t)) from IFFT. (f): — = phase of H(ω);o = phase of Fq; o = phase of H(ωq)Fq.

cbnd H.P. Gavin February 14, 2022

Page 14: Fourier Series, Fourier Transforms, and Periodic Response

14 CEE 541. Structural Dynamics – Duke University – Fall 2020 – H.P. Gavin

8.3 Example 3: triangle wave

The external forcing is given by

f ext(t) = π/2− (t− π) sgn(t− π) ; 0 ≤ t < 2π (36)

The Fourier coefficients for the real-valued Fourier series are:aq = (2/(πq2))(−1q − 1) and bq = 0.

(a)-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

0 1 2 3 4 5 6

funct

ion, f(

t), (N

)

time, t, (s)

true

sampled

real Fourier approx

complex Fourier approx

(b)-0.8

-0.6

-0.4

-0.2

0

0.2

0 2 4 6 8 10 12 14 16

Fouri

er

coeffi

cients

, F(

w),

(N

)

frequency, ω, (rad/s)

real(F)

imag(F)

real(FFT(f))

imag(FFT(f))

(c)-1.5

-1

-0.5

0

0.5

1

1.5

0 1 2 3 4 5 6

cosi

ne a

nd s

ine t

erm

s

time, t, (s) (d)10-5

10-4

10-3

10-2

10-1

100

0 2 4 6 8 10 12 14 16

frequency

resp

onse

frequency, ω, (rad/s)

|F|

|H|

|H*F|

(e)-0.02

-0.015

-0.01

-0.005

0

0.005

0.01

0.015

0.02

0 1 2 3 4 5 6

resp

onse

, x,

(m

)

time, t, (s)

x(t) - complex Fourier series

real(x(t)) - FFT

imag(x(t)) - FFT

(f)-200

-150

-100

-50

0

50

100

150

200

0 2 4 6 8 10 12 14 16

phase

lead, (d

egre

es)

frequency, ω, (rad/s)

Figure 3. (a): — = fext(t); -- = f ext(t). (b): 4= Re(Fq);4= Im(Fq); o = Fq from FFT. (c):— = cosine components, — = sine components. (d): — : |H(ω)|; o = |Fq|; o = |H(ωq)Fq|.(e): — = x(t); o = Re(x(t)) from IFFT; · · · = Im(x(t)) from IFFT. (f): — = phase of H(ω);o = phase of Fq; o = phase of H(ωq)Fq.

cbnd H.P. Gavin February 14, 2022

Page 15: Fourier Series, Fourier Transforms, and Periodic Response

Fourier Series and Periodic Response to Periodic Forcing 15

8.4 Matlab code1 function [Fq ,wq ,x,t] = Fourier (type,Q,wn ,z)2 % [F,w, x ] = Fourier ( type ,Q, wn, z )3 % Compute the Fourier s e r i e s c o e f f i c i e n t s o f a p e r i o d i c s i g n a l , f ( t ) ,4 % in two d i f f e r e n t ways :5 % ∗ complex e x p o n e n t i a l expansion ( i . e . , s ine and cos ine expansion )6 % ∗ f a s t Fourier transform7 %8 % The ’ type ’ o f p e r i o d i c s i g n a l may be9 % ’ square ’ a square wave

10 % ’ sawtooth ’ a saw−t oo th wave11 % ’ t r i a n g l e ’ a t r i a n g l e wave12 %13 % The per iod o f the s i g n a l , f ( t ) , i s f i x e d at 2∗ p i ( second ) .14 %15 % The number o f Fourier s e r i e s c o e f f i c i e n t s i s input as Q.16 % This r e s u l t s in a 2∗Q Fourier transform c o e f f i c i e n t s .17 %18 % The Fourier approximation i s then used to compute the steady−s t a t e19 % response o f a s i n g l e degree o f freedom (SDOF) o s c i l l a t o r , d e s c r i b e d by20 %21 % 222 % x ”( t ) + 2 z wn x ’ ( t ) + wn x ( t ) = f ( t ) ,23 %24 % where the mass o f the system i s f i x e d at 1 ( kg ) .25 %26 % see : h t t p :// en . w ik ipe d ia . org / wik i / F o u r i e r s e r i e s27 % h t t p ://www. jhu . edu/˜ s i g n a l s / f o u r i e r 2 / index . html28 %2930 i f nargin < 4, help Fourier ; return; end3132 T = 2* pi; % per iod o f e x t e r n a l forc ing , s3334 a = zeros (1,Q); % c o e f f i c i e n t s o f cos ine par t o f Fourier s e r i e s35 b = zeros (1,Q); % c o e f f i c i e n t s o f s ine par t o f Fourier s e r i e s3637 q = [1:Q]; % p o s i t i v e f requency index va lue38 wq = 2* pi*q/T; % p o s i t i v e f requency va lues , rad/ sec , eq ’ n (14)3940 dt = T/(2*Q); % 2Q d i s c r e t e p o i n t s in time f o r FFT sampling41 ts = [0:2*Q -1]* dt; % 2Q d i s c r e t e p o i n t s in time f o r FFT sampling42 P = 128; % l e n g t h o f the time−record ( f o r p l o t t i n g purposes only )43 t = [0:2* P]*T/2/P; % time a x i s4445 % =======================================================================46 % Fourier s e r i e s approximation o f genera l p e r i o d i c f u n c t i o n s4748 % sin ( q∗ p i ) = 0 , cos ( q∗ p i ) = (−1).ˆ q49 % f t r u e i s used only f o r p l o t t i n g50 % f samp i s used in FFT computations5152 i f strcmp( type,’square ’ ) % square wave53 b = 2./(q*pi) .* (( -1).ˆq - 1);54 f_true = sign(t-pi ); f_true (1) = 0; f_true (2*P+1) = 0;55 f_samp = sign(ts -pi );56 f_samp (1) = 0; % g e t p e r i o d i c i t y r i g h t , f (0) = 057 end5859 i f strcmp( type,’sawtooth ’ ) % sawtooth wave60 b = -(2./q);61 f_true = t-pi; f_true (1) = 0; f_true (2*P+1) = 0;62 f_samp = ts -pi;63 f_samp (1) = 0; % g e t p e r i o d i c i t y r i g h t , f (−p i ) = 064 end6566 i f strcmp( type,’triangle ’ ) % t r i a n g l e wave67 a = (2./( pi*q .ˆ2)) .* ( ( -1).ˆq - 1 );68 f_true = pi /2 - (t-pi) .* sign(t-pi );69 f_samp = pi /2 - (ts -pi ).* sign(ts -pi );70 end

cbnd H.P. Gavin February 14, 2022

Page 16: Fourier Series, Fourier Transforms, and Periodic Response

16 CEE 541. Structural Dynamics – Duke University – Fall 2020 – H.P. Gavin

7172 f_approxR = a * cos(wq ’*t) + b * sin (wq ’*t); % r e a l Fourier s e r i e s7374 Fq = (a - i*b)/2; % complex Fourier c o e f f i c i e n t s7576 % Complex Fourier s e r i e s ( p o s i t i v e and n e g a t i v e exponents )77 f_approxC = Fq * exp(i*wq ’*t) + conj(Fq) * exp(-i*wq ’*t);7879 % The imagniary par t o f the complex Fourier s e r i e s i s e x a c t l y zero !80 imag_over_real_1 = max(abs(imag( f_approxC ))) / max(abs( real ( f_approxC )))818283 % The f a s t Fourier transform (FFT) method84 % In Matlab , the forward Fourier transform has a n e g a t i v e exponent .85 % According to a convent ion o f the FFT method , index number 1 i s f o r time = 08687 F_FFT = f f t ( f_samp ) / (2*Q); % Fourier c o e f f ’ s8889 % =======================================================================90 % Steady−s t a t e response o f a s imple o s c i l l a t o r to genera l p e r i o d i c f o r c i n g .9192 % Complex−va lued frequency response funct ion , H(w) , has u n i t s o f [m/N]93 H = (1/ wn ˆ2) ./ ( 1 - (wq/wn ).ˆ2 + 2*i*z*( wq/wn) );9495 % Complex Fourier s e r i e s ( p o s i t i v e and n e g a t i v e exponents )96 x_approxC = (H .* Fq) * exp(i*wq ’*t) + (conj(H) .* conj(Fq )) * exp(-i*wq ’*t);9798 % In Matlab , the i n v e r s e Fourier transform has a p o s i t i v e exponent .99 % . . . see the t a b l e at the end o f t h i s f i l e f o r the s o r t i n g convent ion .

100 x_FFT = i f f t ( [ (1/ wn ˆ2) , H , conj(H(Q -1: -1:1)) ] .* F_FFT ) * (2*Q);101102 % The imaginary par t i s e x a c t l y zero f o r the complex exponent s e r i e s method !103 imag_over_real_2 = max(abs(imag( x_approxC ))) / max(abs( real ( x_approxC )))104105 % The imaginary par t i s p r a c t i c a l l y zero f o r the FFT method !106 imag_over_real_3 = max(abs(imag( x_FFT ))) / max(abs( real ( x_FFT )))107108 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−109 % SORTING of the FFT c o e f f i c i e n t s number o f data p o i n t s = N = 2∗Q110 % note : f max = 1/(2∗ dt ) ; d f = f max /(N/2) = 1/(N∗ dt ) = 1/T;111 %112 %113 % index time frequency114 % ===== ==== =========115 % 1 0 0 imag (F)=0116 % 2 dt d f117 % 3 2∗ dt 2∗ d f118 % 4 3∗ dt 3∗ d f119 % : : :120 % N/2−1 (N/2−2)∗ dt f max−2∗d f = ( N/2−2)∗ d f121 % N/2 (N/2−1)∗ dt f max−d f = ( N/2−1)∗ d f122 % N/2+1 (N/2)∗ dt +/− f max = ( N/2 )∗ d f imag (F)=0123 % N/2+2 (N/2+1)∗ dt −f max+df = (−N/2+1)∗ d f124 % N/2+3 (N/2+2)∗ dt −f max+2∗d f = (−N/2+2)∗ d f125 % : : : :126 % N−2 (N−3)∗ dt −3∗d f127 % N−1 (N−2)∗ dt −2∗d f128 % N (N−1)∗ dt −d f129 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

cbnd H.P. Gavin February 14, 2022