Professional Documents
Culture Documents
f 2 (t)dt < .
X
2qt X
2qt
1
aq cos
bq sin
+
,
f (t; a, b) = a0 +
2
T
T
q=1
q=1
(1)
where the Fourier coefficients, aq and bq are given by the Fourier integrals,
2ZT
2qt
f (t) cos
dt ,
T 0
T
2ZT
2qt
f (t) sin
dt ,
=
T 0
T
aq =
q = 1, 2, . . .
(2)
bq
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,
RT 2
J(a, b) = 0 e (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) =
Z T
2
f (t) f(t; a, b)
dt
Z T
0
(4)
CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin
i
h 2
f (t) 2f (t)f(t; a, b) + f2 (t; a, b) dt
0 a0
Z T
Z T
f(t; a, b)
f (t; a, b)dt + 2
f (t; a, b)dt
= 2
f (t)
a0
a0
0
0
0 =
= 2
Z T
0
Z T
1
f (t) dt + 2
2
f (t)dt +
Z T
0
Z T
Z T
0
1
2qt
2qt 1
a0 +
aq cos
+
bq sin
dt
2
T
T
2
q=1
q=1
Z T
Z T
X
X
1
2qt
2qt
cos
sin
a0 dt +
aq
dt +
bq
dt
2
T
T
0
0
q=1
q=1
X
X
1
f (t)dt + a0 T +
aq 0 +
bq 0
2
q=1
q=1
From which,
2ZT
a0 =
f (t) dt.
T 0
(5)
i
h 2
f (t) 2f (t)f(t; a, b) + f2 (t; a, b) dt
0 ak
Z T
Z T
f (t; a, b)dt + 2
f(t; a, b)
f (t; a, b)dt
= 2
f (t)
ak
ak
0
0
0 =
Z T
0
Z T
Z T
0
Z T
0
2kt
dt +
T
Z T
Z T
X
X
2qt
2qt
2kt
2qt
2kt
cos
dt +
aq
cos
cos
dt +
bq
sin
cos
dt
T
T
T
T
T
0
0
q=1
q=1
f (t) cos
a0 Z T
2
Z T
X
2kt
2qt X
2qt
2kt
a
0 +
f (t) cos
aq cos
bq sin
cos
dt +
+
dt
T
2
T
T
T
0
q=1
q=1
Z T
X
a0
2kt
2 2kt
f (t) cos
dt +
0 + ak
cos
dt +
bq 0
T
2
T
0
q=1
f (t) cos
T
2kt
dt + 0 + ak + 0
T
2
From which,
ak =
2ZT
2kt
f (t) cos
dt.
T 0
T
(6)
(7)
CC BY-NC-ND H.P. Gavin
The derivation of the Fourier integrals (equations (5), (6), and (7)) make use of orthogonality
properties of sine and cosine functions.
Z T
nt
dt
sin
T
0
Z T
nt
cos2
dt
T
0
Z T
nt
mt
sin
sin
dt
T
T
0
Z T
nt
mt
cos
cos
dt
T
T
0
Z T
nt
mt
sin
cos
dt
T
T
0
2
T
,
2
T
,
=
2
=
n = 1, 2,
n = 1, 2,
= 0,
n 6= m ,
n, m = 1, 2,
= 0,
n 6= m ,
n, m = 1, 2,
= 0,
n 6= m ,
n, m = 1, 2,
(8)
Note that the left hand side of equation (8) is the sum of complex conjugates, and that the
right hand side is the sum of real values. So complex conjugates can be used to express the
real Fourier series given in equation (1). Substituting equation (8) into equation (1),
X
2qt
1
2qt
aq cos
a0 +
+ bq sin
f (t; a, b) =
2
T
T
q=1
X
1
1
2q
1
2q
a0 +
(aq ibq ) exp i
t + (aq + ibq ) exp i
t
2
T
2
T
q=1 2
X
X
1
2q
2q
a0 +
Fq exp i
t +
Fq exp i
t
2
T
T
q=1
q=1
1
X
X
2q
2q
1
a0 +
Fq exp i
t +
Fq
exp i
t
=
2
T
T
q=
q=1
X
2q
=
Fq exp i
t =
Fq eiq t
T
q=
q=
(9)
condition Fq = Fq holds for the Fourier series of any real-valued function that is periodic
CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin
q=+
X
Fq eiq t
q=
= F0 +
q=1
X
iq t
Fq e
q=
= F0 +
q=+
X
q=+
X
q=1
Fq eiq t +
q=+
X
q=1
= F0 +
= F0 +
= F0 +
h
X
q=1
h
X
q=1
h
X
Fq eiq t
Fq eiq t
q=1
Fq eiq t + Fq eiq t
q=1
So, the real part of Fq , Fq0 , is half of aq , the imaginary part of Fq , Fq00 , is half of bq , and
. The real Fourier coefficients, aq , are even about q = 0 and the imaginary Fourier
Fq = Fq
coefficients, bq , are odd about q = 0.
Just as the Fourier expansion may be expressed in terms of complex exponentials, the
coefficients Fq may also be written in this form.
1
2q
1ZT
2q
Fq = (aq ibq ) =
f (t) cos
t i sin
t
2
T 0
T
T
2q
1ZT
f (t) exp i
=
t dt
T 0
T
(10)
Since the integrand, f (t)eiq t , of the Fourier integral is periodic in T , the limits of integration
can be shifted arbitrarily without affecting the resulting Fourier coefficients.
Z T
0
iq t
f (t)e
dt =
iq t
f (t)e
dt +
Z T +
iq t
f (t)e
dt
Z T +
f (t)eiq t dt.
iq t
f (t)e
dt =
Z T +
f (t)eiq t dt .
f (t)eiq t dt =
Z T +
f (t)eiq t dt.
0+
On the other hand, shifting the function in time, affects the relative values of aq and bq
(i.e.,
the phase the the complex coefficeint Fq ), but does not affect the magnitude, |Fq | =
q
P
1
iq t
2 + b2 . If f(t) =
(t + ) = P Fq eiq (t+ ) = P (Fq eiq ) eiq t , and
a
F
e
,
then
f
q
q
q
2
|Fq | = |Fq eiq |.
CC BY-NC-ND H.P. Gavin
2.1 a periodic square wave function: f (t) = sgn(t) on < t < and f (t) = f (t + n(2))
> assume (k::integer);
>
f := signum(t);
> ak := (2/(2*Pi)) * int(f*cos(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);
ak := 0
>
bk := (2/(2*Pi)) * int(f*sin(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);
k
2 ((-1)
- 1)
bk := - -------------Pi k
2.2 a periodic sawtooth function: f (t) = t on < t < and f (t) = f (t + n(2))
> assume (k::integer);
> f := t;
> ak := (2/(2*Pi)) * int(f*cos(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);
ak := 0
> bk := (2/(2*Pi)) * int(f*sin(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);
(1 + k)
2 (-1)
bk := -------------k
2.3 a periodic triangle function: f (t) = /2 t sgn(t) on < t < and f (t) = f (t + n(2))
> assume (k::integer);
> f := Pi/2 - t * signum(t);
> ak := (2/(2*Pi)) * int(f*cos(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);
k
2 ((-1)
- 1)
ak := - -------------2
Pi k
>
bk := (2/(2*Pi)) * int(f*sin(2*Pi*k*t/(2*Pi)),t=-Pi..Pi);
bk := 0
CC BY-NC-ND H.P. Gavin
CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin
3 Fourier Transforms
Recall for periodic functions of period, T , the Fourier series expansion may be written
f (t) =
q=
X
Fq eiq t ,
(11)
q=
where the Fourier coefficients, Fq , have the same units as f (t), and are given by the Fourier
integral,
1 Z T /2
Fq =
f (t) eiq t dt ,
(12)
T T /2
in which the limits of integration have been shifted by = T /2.
Now, consider a change of variables, by defining a frequency increment, , and a scaled
amplitude, F (q ).
2
(q = q )
T
2
F (q ) = T Fq =
Fq
= 1 =
(13)
(14)
F (q ) =
Z T /2
f (t) eiq t dt .
P
1 Z
F () eit d ,
2 Z
F () =
(16)
T /2
(15)
f (t) eit dt .
(17)
(18)
These expressions are the famous Fourier transform pair. Equation (17) is commonly called
the inverse Fourier transform and equation (18) is commonly called the forward Fourier
transform. They differ only by the sign of the exponent and the factor of 2.
4 Fourier Approximation
Any periodic function may be approximated as a truncated series expansion of sines and
cosines, as a Fourier series,
Q
Q
X
2qt X
2qt
1
aq cos
+
bq sin
,
f(t) = a0 +
2
T
T
q=1
q=1
(19)
where the Fourier coefficients, aq and bq may be found by solving the Fourier integrals,
aq
bq
2 Z T /2
2qt
=
f (t) cos
dt ,
T T /2
T
2 Z T /2
2qt
=
f (t) sin
dt ,
T T /2
T
q = 1, 2, . . . , Q
(20)
q = 1, 2, . . . , Q
(21)
The Fourier approximation (19) may also be represented using complex exponential notation.
f(t) =
q=Q
X
Fq eiq t =
q=Q
X
1 q=Q
F (q ) eiq t
T q=Q
(22)
1 Z T /2
f (t) eiq t dt .
Fq =
T T /2
(23)
q = [N/2 + 1, , 2, 1, 0, 1, , N/2]
(24)
and the N -point discrete Fourier approximation is computed by the inverse discrete Fourier
transform,
N/2
X
2qn
f (tn ) =
Fq exp i
(25)
N
q=N/2+1
With the normalization given in equations (24) and (25), N1 fn2 = |Fq |2 . By convention,
in the fast Fourier transform (FFT) the factor (1/N ) is applied to equation (25) instead of
equation (24). Also, by convention, the Fourier frequencies, q = 2q/T are sorted as follows:
q = 0, 1, , N/2, N/2 + 1, , 2, 1. The lowest positve frequency in the FFT is 1/T
Hertz, and the highest frequency is 1/(2t) Hertz, which is called the Nyquist frequency.
P
CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin
1
(k
mq2 )
+ i(cq )
(26)
Fq
The function H() is called the frequency response function for the dynamic system relating
the input f (t) to the output x(t).
Because the oscillator is linear, if the response to f1 (t) is x1 (t), and the response to f2 (t)
is x2 (t), then the response to c1 f1 (t) + c2 f2 (t) is c1 x1 (t) + c2 x2 (t). More generally, then,
x(t) =
q=
X
q=
H(q ) Fq e
iq t
q=
X
q= (k
1
mq2 )
+ i(cq )
Fq eiq t
(27)
where q = 2q/T .
q
Note that q is not the same symbol as n . The natural frequency, k/m, has the symbol
n . The symbol q = 2q/T is the frequency of a component of a periodic forcing function
of period T .
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 as 1/q2 .
7 Examples
In the following examples, the external forcing is periodic with a period, T , of 2 (seconds). For functions periodic in 2 seconds, the frequency increment in the Fourier series is
1 radian/second. In this case, the frequency index number, q, is also the frequency, q , in
radians per second, otherwise, q = 2q/T .
The system is a forced spring-mass-damper oscillator,
x(t) + 2n x(t)
+ n2 x(t) =
1 ext
f (t) .
m
(28)
The complex-valued frequency response function from the external force, f ext (t), to the response displacement, x(t), is given by
1/n2
H() =
,
1 2 + i 2
(29)
10
CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin
< t <
(30)
0
-0.1
Fourier coefficients, Fq, (N)
0.5
-0.5
-1
-0.2
-0.3
-0.4
-0.5
-0.6
-1.5
-0.7
-3
-2
-1
(a)
(b)
time, t, (s)
10
12
14
16
frequency, , (rad/s)
1
1.5
0.1
frequency response
0.5
-0.5
0.01
0.001
-1
1e-04
-1.5
-3
-2
-1
(c)
(d)
time, t, (s)
10
12
14
16
12
14
16
frequency, , (rad/s)
200
0.025
0.02
150
0.015
response, x, (m)
0.01
0.005
0
-0.005
-0.01
100
50
0
-50
-100
-0.015
-150
-0.02
-200
-0.025
(e)
-3
-2
-1
0
time, t, (s)
(f)
10
frequency, , (rad/s)
Figure 1. (a): = f ext (t); - - = fext (t). (b): red solid = <(Fq ); blue dashed = =(Fq );
*: Fq from FFT. (c): red solid = component cosine terms, blue dashed = component sine terms.
(d): : |H()|; *: |Fq | and |H(q )Fq |. (e): : x(t); *: x(t) from IFFT; : =(x(t)) from
IFFT. (f): : phase of H(); *: phase of Fq and H(q )Fq .
11
< t <
(31)
0.4
Fourier coefficients, Fq, (N)
2
1
0
-1
-2
-3
0.2
0
-0.2
-0.4
-0.6
-0.8
-4
-1
-3
-2
-1
(a)
(b)
time, t, (s)
10
12
14
16
frequency, , (rad/s)
1
0.1
1
frequency response
1.5
0.5
0
-0.5
0.01
0.001
-1
-1.5
1e-04
-2
-3
-2
-1
(c)
(d)
time, t, (s)
10
12
14
16
12
14
16
150
100
phase lead, (degrees)
0.02
response, x, (m)
frequency, , (rad/s)
0.04
-0.02
-0.04
-0.06
50
0
-50
-100
-150
-200
-0.08
(e)
-3
-2
-1
0
time, t, (s)
(f)
10
frequency, , (rad/s)
Figure 2. (a): = f ext (t); - - = fext (t). (b): red solid = <(Fq ); blue dashed = =(Fq );
*: Fq from FFT. (c): red solid = component cosine terms, blue dashed = component sine terms.
(d): : |H()|; *: |Fq | and |H(q )Fq |. (e): : x(t); *: x(t) from IFFT; : =(x(t)) from
IFFT. (f): : phase of H(); *: phase of Fq and H(q )Fq .
12
CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin
< t <
(32)
2
1.5
1
0.5
0
-0.5
-1
-1.5
-2
-2
-1
0.2
0.1
(b)
time, t, (s)
10
12
14
16
frequency, , (rad/s)
1
1.5
0.1
frequency response
0.3
-0.1
-3
0.5
-0.5
0.01
0.001
1e-04
-1
1e-05
-1.5
-3
-2
-1
(c)
(d)
time, t, (s)
0.02
200
0.015
150
0.01
100
0.005
0
-0.005
10
12
14
16
12
14
16
frequency, , (rad/s)
response, x, (m)
0.4
(a)
50
0
-50
-0.01
-100
-0.015
-150
-200
-0.02
(e)
0.5
-3
-2
-1
0
time, t, (s)
(f)
10
frequency, , (rad/s)
Figure 3. (a): = f ext (t); - - = fext (t). (b): red solid = <(Fq ); blue dashed = =(Fq );
*: Fq from FFT. (c): red solid = component cosine terms, blue dashed = component sine terms.
(d): : |H()|; *: |Fq | and |H(q )Fq |. (e): : x(t); *: x(t) from IFFT; : =(x(t)) from
IFFT. (f): : phase of H(); *: phase of Fq and H(q )Fq .
13
29
30
31
32
33
i f nargin < 4
help Fourier
return
end
34
35
36
T = 2* pi ;
37
38
39
a
b
= zeros (1 , Q );
= zeros (1 , Q );
40
41
42
q = [1: Q ];
wq = 2* pi * q / T ;
dt = T /(2* Q );
ts = [ - Q :Q -1]* dt ;
% 2Q d i s c r e t e p o i n t s i n time f o r FFT s a m p l i n g
% 2Q d i s c r e t e p o i n t s i n time f o r FFT s a m p l i n g
eq n ( 1 3 )
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
% =======================================================================
% Fourier s e r i e s approximation of general p e r i o d i c f u n c t i o n s
59
60
61
62
% s i n ( q p i ) = 0 , c o s ( q p i ) = ( 1). q
% f t r u e i s used o n l y f o r p l o t t i n g
% f samp i s used i n FFT c o m p u t a t i o n s
63
64
65
66
67
68
69
70
14
71
CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin
end
72
73
74
75
76
77
78
79
80
81
82
83
84
% t r i a n g l e wave
f_approxR = a * cos (q * t ) + b * s i n (q * t );
% r e a l Fourier s e r i e s
Fq = ( a - i * b )/2;
% complex F o u r i e r c o e f f i c i e n t s
85
86
87
88
89
90
91
92
% Complex F o u r i e r s e r i e s ( p o s i t i v e and n e g a t i v e e x p o n e n t s )
f_approxC = Fq * exp( i * wq * t ) + conj ( Fq ) * exp( - i * wq * t );
93
94
95
96
% The i m a g n i a r y p a r t o f t h e complex F o u r i e r s e r i e s i s e x a c t l y z e r o !
i m a g _ o v e r _ re al _ 1 = max(abs(imag( f_approxC ))) / max(abs( r e a l ( f_approxC )))
97
98
99
100
101
102
103
%
%
%
%
%
104
105
% Fourier coeff s
106
107
108
% c o e f = [ Fq F FFT ( 2 :Q+1) ]
% d i s p l a y the Fourier c o e f f i c i e n t s
109
110
% P l o t t i n g
111
112
113
114
115
116
117
118
119
120
121
122
f i g u r e (1);
plot (t , f_true , -r , ts , f_samp , * r , t , f_approxR , -c , t , f_approxC , -b )
xlabel ( time , t , ( s ) )
ylabel ( function , f ( t ) , ( N ) )
axis (1.05*[ - pi , pi ])
legend ( true , sampled , real Fourier approx , complex Fourier approx )
plot ( wq , r e a l ( Fq ) , r , wq ,imag( Fq ) , b , ...
wq , r e a l ( F_FFT (2: Q +1)) , * r , wq ,imag( F_FFT (2: Q +1)) , * b )
ylabel ( Fourier coefficients , F ( w ) , ( N ) )
xlabel ( frequency , {/ Symbol w } , ( rad / s ) )
legend ( real ( F ) , imag ( F ) , real ( FFT ( f )) , imag ( FFT ( f )) )
123
124
125
126
127
128
129
f i g u r e (2);
plot (t ,a * ones (1 ,2* P +1).* cos (q * t ) , -r , t ,b * ones (1 ,2* P +1).* s i n (q * t ) , -b );
xlabel ( time , t , ( s ) )
ylabel ( cosine and sine terms )
axis (1.05*[ - pi , pi ])
130
131
132
133
% =======================================================================
% Steadys t a t e r e s p o n s e o f a SDOF o s c i l l a t o r t o g e n e r a l p e r i o d i c f o r c i n g .
134
135
136
137
138
139
% Complex F o u r i e r s e r i e s ( p o s i t i v e and n e g a t i v e e x p o n e n t s )
x_approxC = ( H .* Fq ) * exp( i * wq * t ) + ( conj ( H ) .* conj ( Fq )) * exp( - i * wq * t );
140
141
% In Matlab , t h e i n v e r s e F o u r i e r t r a n s f o r m has a p o s i t i v e e x p o n e n t .
15
%
. . . s e e t h e t a b l e a t t h e end o f t h i s f i l e f o r t h e s o r t i n g c o n v e n t i o n .
x_FFT = i f f t ( [ (1/ wn 2) , H , conj ( H (Q -1: -1:1)) ] .* F_FFT ) * (2* Q );
144
145
146
147
148
149
f i g u r e (3);
% p l o t frequency response functions
semilogy ( wq ,abs( Fq ) , * g , wq ,abs( H ) , -r , wq ,abs( H .* Fq ) , * b )
xlabel ( frequency , {/ Symbol w } , ( rad / s ) )
ylabel ( frequency response )
legend ( | F | , | H | , | H * F | )
150
151
152
153
154
155
156
157
158
159
160
161
f i g u r e (4);
% p l o t time r e s p o n s e
ts = [ ts ( Q +1:2* Q ) ts (1: Q ) ];
% res o r t t h e time a x i s
plot ( t , x_approxC , -r , ts , r e a l ( x_FFT ) , * b , ts , imag( x_FFT ) , . b )
axis (1.05*[ - pi , pi ])
xlabel ( time , t , ( s ) )
ylabel ( response , x , ( m ) )
legend ( x ( t ) - complex Fourier series , real ( x ( t )) - FFT , imag ( x ( t )) - FFT )
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
SORTING o f t h e FFT c o e f f i c i e n t s
number o f d a t a p o i n t s = N = 2Q
note :
f max = 1/(2 d t ) ;
d f = f max /(N/2) = 1/(N d t ) = 1/T;
index
time
frequency
=====
====
=========
1
0
0
2
dt
df
3
2 d t
2 d f
4
3 d t
3 d f
:
:
:
N/21
(N/22) d t
f max 2 d f = ( N/22) d f
N/2
(N/21) d t
f maxd f
= ( N/21) d f
N/2+1
(N/2) d t
+/ f max
= ( N/2 ) d f
N/2+2
(N/2+1) d t
f max+d f
= (N/2+1) d f
N/2+3
(N/2+2) d t
f max+2 d f = (N/2+2) d f
:
:
:
:
N2
(N3) d t
3 d f
N1
(N2) d t
2 d f
N
(N1) d t
d f