Addendum: The Fourier transform of decaying oscillations Robert DeSerio The Acquire and Analyze Transient vi is a LabVIEW program that takes and analyzes decaying oscillations. In this addendum, the mathematics associated with the creation and fitting of the signal’s Fourier transform is presented. The initial sections deal with determining a model for the fitting function. The final section gives a description of the chi-square that is minimized in the fit. Driven harmonic oscillator equation A driven harmonic oscillator satisfies the following diffential equation: " d 1 d2 + γ + ω02 x(t) = f (t) 2 dt dt m # (1) where x(t) satisfies initial conditions and f (t) is a known time dependent force acting on the mass m. Solving this equation using Fourier transforms begins with the idea of expressing x(t) and f (t) as a superposition of complex oscillations of the form e−jωt . We define their Fourier transforms Z ∞ x̃(ω) = x(t)e−jωt dt (2) −∞ f˜(ω) = Z ∞ f (t)e−jωt dt (3) −∞ The inverse Fourier transform allow us to recover the functions x(t) if x̃(ω) is known. 1 Z∞ x̃(ω)ejωt dω (4) x(t) = 2π −∞ Similarly for f (t) from f˜(ω) 1 Z∞ ˜ f (ω)ejωt dω 2π −∞ Using these inverse Fourier transforms in Eq. 1 then gives f (t) = Z ∞ d2 d 1 Z∞ ˜ 2 jωt + γ + ω x̃(ω)e dω = f (ω)ejωt dω 0 dt2 dt m −∞ −∞ # Z ∞ " 2 d d 1 Z∞ ˜ 2 jωt + γ + ω0 x̃(ω)e dω = f (ω)ejωt dω dt m −∞ −∞ dt2 Z ∞ h i 1 Z∞ ˜ 2 2 jωt −ω + jγω + ω0 x̃(ω)e dω = f (ω)ejωt dω m −∞ −∞ " (5) # (6) Taking the Fourier transform of both sides then gives h i −ω 2 + jγω + ω02 x̃(ω) = 1 ˜ f (ω) m (7) The differential equation is now an algebraic one and is easily solved x̃(ω) = 1 f˜(ω) m −ω 2 + jγω + ω02 (8) Consequently, if f˜(ω) is known, x(t) can be found by taking the inverse Fourier transform of both sides x(t) = f˜(ω) 1 Z∞ 1 ejωt dω 2π −∞ m −ω 2 + jγω + ω02 (9) Example 1: The force is a delta function (impulse). A force of this form is given by f (t) = ∆p δ(t), where δ(t) is the Dirac delta function and ∆p characterizes its net impulse. Impulse = = Z ∞ −∞ Z ∞ f (t)dt ∆p δ(t)dt −∞ = ∆p With Fourier analysis, the force is specified over all times and the solution is specified over all times. A delta function at t = 0, with no force before t = 0 implies a solution starting at rest at equilibrium x0 = 0 (10) before the impulse and, while holding that position after the impulse, the mass gains a non-zero initial velocity v0 = ∆p/m (11) after the impulse. Let’s see how this turns out. The Fourier transform of the impulsive force is f˜(ω) = Z ∞ −∞ = ∆p ∆p δ(t)e−jωt dt implying that an impulse is equal amounts of complex oscillations at all real frequencies. Using this force in Eq. 9 gives ∆p 1 2 m −ω + jγω + ω02 v0 = 2 −ω + jγω + ω02 x̃(ω) = (12) We will see next that the right side is also an expression for the frequency response—giving the amplitude and phase of the steady state oscillations as a function of the frequency of a sinusoidal driving force of fixed amplitude. Consequently, Eq. 12 is the well known result that the Fourier transform of the impulse response is the frequency response. Taking the inverse Fourier transform of Eq. 12 gives x(t) = v0 1 Z∞ ejωt dω 2 2π −∞ −ω + jγω + ω02 (13) We have already solved the equation of motion for an impulsive force—as the solution to the homogeneous differential equation, satisfying general initial conditions. We will check back on this issue shortly. Example 2: The force is a uniform oscillating force of magnitude f0 , frequency ωf and phase constant φf f (t) = f0 cos(ωf t + φf ) (14) In treating this problem with Fourier transforms we will need the Fourier transform pair that can be expressed: δ(ω − ω 0 ) = 1 Z ∞ −j(ω−ω0 )t e dt 2π −∞ The Fourier transform of f (t) becomes f˜(ω) = Z ∞ −∞ f0 cos(ωf t + φf )e−jωt dt f0 Z ∞ j(ωf t+φf ) = e + e−j(ωf t+φf ) e−jωt dt 2 −∞ f0 Z ∞ jφf −j(ω−ωf )t = e e + e−jφf e−j(ω+ωf )t dt 2 −∞ f0 jφf = 2π e δ(ω − ωf ) + e−jφf δ(ω + ωf ) 2 (15) Thus x̃(ω) = πf0 ejφf δ(ω − ωf ) + e−jφf δ(ω + ωf ) −ω 2 + jγω + ω02 and ejφf δ(ω − ωf ) + e−jφf δ(ω + ωf ) jωt 1 Z∞ πf0 e dω x(t) = 2π −∞ −ω 2 + jγω + ω02 ! f0 ej(ωf t+φf ) e−j(ωf t+φf ) = + 2 −ωf2 + jγωf + ω02 −ωf2 − jγωf + ω02 This is just the real part of the first term. Calling the drive frequency ω rather than ωf we have the result f0 ej(ωt+φf ) 1 < x(t) = m −ω 2 + jγω + ω02 ( ) Continuum equations—general case Consider a complex function f (t) z(t) = x(t) + jy(t) (16) described by the real functions x(t) and y(t) and having the Fourier transform z̃(ω) = = Z ∞ −∞ Z ∞ z(t)e−jωt dt [x(t) + jy(t)] e−jωt dt −∞ = x̃(ω) + j ỹ(ω) (17) where x̃(ω) and ỹ(ω) are the Fourier transforms x̃(ω) = ỹ(ω) = Z ∞ −∞ Z ∞ x(t)e−jωt dt (18) y(t)e−jωt dt (19) −∞ Then z̃ ∗ (−ω) = = Z ∞ −∞ Z ∞ z ∗ (t)e−jωt dt [x(t) − jy(t)] e−jωt dt −∞ = x̃(ω) − j ỹ(ω) (20) and the transforms for both the real and imaginary components of z(t) can be recovered from z̃(ω) according to 1 (21) x̃(ω) = [z̃(ω) + z̃ ∗ (−ω)] 2 and 1 ỹ(ω) = [z̃(ω) − z̃ ∗ (−ω)] (22) 2j In general, both x̃(ω) and ỹ(ω) are complex, with non-zero real and imaginary parts. However, because x(t) and y(t) are purely real functions, their Fourier transforms will have certain symmetry properties. These symmetries can be derived from 1 ∗ [z̃ (−ω) + z̃(ω)] 2 1 = [z̃(ω) + z̃ ∗ (−ω)] 2 = x̃(ω) x̃∗ (−ω) = (23) and ỹ ∗ (−ω) = − 1 ∗ [z̃ (−ω) − z̃(ω)] 2j 1 [z̃(ω) − z̃ ∗ (−ω)] 2j = ỹ(ω) = (24) The complex conjugates of Eqs. 23 and 24 are x̃(−ω) = x̃∗ (ω) and ỹ(−ω) = ỹ ∗ (ω) and demonstrate that the Fourier transforms of real functions will have real parts that are symmetric about ω = 0 and imaginary parts that are antisymmetric. Decaying oscillations Decaying oscillations (from t = 0 → ∞) can be expressed as the real function x(t) = Ae−γt/2 cos(ω00 t + φ)u(t) (25) where u(t) is the Heaviside step function u(t) = 1 t ≥ 0 = 0 t<0 (26) and A and φ depend on initial conditions. It is easy to demonstrate that x(t) is the real part of the complex function 0 z(t) = Aejφ e−γt/2 ejω0 t u(t) 0 = Ae−γt/2 ej(ω0 t+φ) u(t) = Ae−γt/2 cos(ω00 t + φ)u(t) + j Ae−γt/2 sin(ω00 t + φ)u(t) The complex function z(t) has the Fourier transform z̃(ω) = = Z ∞ z(t)e−jωt dt −∞ Z ∞ 0 Aejφ e−γt/2 ejω0 t u(t)e−jωt dt −∞ = Ae jφ Z ∞ 0 e−[γ/2+j(ω−ω0 )]t dt 0 = −γ 2 = −γ 2 = γ 2 Aejφ −[γ/2+j(ω−ω00 )]t ∞ e t=0 + j (ω − ω00 ) Aejφ (0 − 1) + j (ω − ω00 ) Aejφ + j (ω − ω00 ) (27) Frequency response from decaying oscillations Eq. 12 states that the Fourier transform of the impulse response is the frequency response. The impulse gives the system an initial velocity v0 , but it starts at x0 = 0. For x = Ae−γt/2 cos(ω00 t + φ), this would correspond to φ = −π/2 so that the impulse response becomes x(t) = Ae−γt/2 sin ω00 t (28) giving x(0) = x0 = 0 and v(0) = v0 = Aω00 as required. With φ = −π/2, Eq. 27 gives z̃(ω) = γ 2 −jA + j (ω − ω00 ) (29) and z̃ ∗ (−ω) = γ 2 jA + j (ω + ω00 ) (30) Then from Eq. 21 A x̃(ω) = 2 γ 2 = = A 2 −j + + j (ω − ω00 ) −j γ 2 γ 2 j + j (ω + ω00 ) γ 2 + j (ω + ω00 ) + j (ω + ω00 ) + j γ 2 Aω00 ω00 ) + jγ 2 + j (ω − ω00 ) γ2 4 ! − (ω − ω00 ) (ω + v0 = γ2 2 − ω + ω002 + jωγ 4 v0 = 2 −ω + ω02 + jωγ γ 2 + j (ω − ω00 ) ((ω + ω00 ) + (ω − ω00 )) where the final substitution arises because the decaying oscillation frequency ω00 satisfies ω002 = ω02 − γ 2 /4. Thus demonstrating the validity of Eq. 12 for the harmonic oscillator. Effects of finite sample size To take into account that a real signal is over a finite interval 0 ≤ t ≤ τ , z(t) should be further corrected to the form zτ (t) as 0 zτ (t) = Aejφ e−γt/2 ejω0 t u(t)rτ (t) = z(t)rτ (t) (31) (32) so that it is a product of the original function z(t) and the symmetric “rectangle function” rτ (t) = u(t − τ ) − u(t + τ ) (33) which is non-zero and equal to unity only in the interval −τ ≤ t ≤ τ . It has the Fourier transform r̃τ (ω) = = = Z ∞ −∞ Z τ rτ (t)e−jωt dt e−jωt dt −τ Z τ −τ [cos ωt + j sin ωt] dt τ 1 = [sin ωt − j cos ωt] ω t=−τ sin ωτ = 2 ω (34) The definite integral for r̃τ (ω) can be shown to give1 Z ∞ −∞ r̃τ (ω)dω = 2π (35) The Fourier transform of a product p(t) = g(t) · h(t) (36) is given by the Fourier convolution theorem p̃(ω) = = Z ∞ −∞ Z ∞ p(t)e−jωt dt g(t)h(t)e−jωt dt −∞ = 1 g̃(ω) ∗ h̃(ω) 2π (37) where g̃(ω) and h̃(ω) are the individual Fourier transforms of g(t) and h(t) g̃(ω) = h̃(ω) = Z ∞ −∞ Z ∞ g(t)e−jωt dt h(t)e−jωt dt −∞ and g̃(ω) ∗ h̃(ω) represents the convolution integral g̃(ω) ∗ h̃(ω) = Z ∞ g̃(ω − ω 0 )h̃(ω 0 )dω 0 (38) −∞ Applying the convolution theorem to Eq. 32 then gives z̃τ (ω) = 1 1 Z∞ z̃(ω − ω 0 )r̃τ (ω 0 )dω 0 2π −∞ http://en.wikipedia.org/wiki/Dirichlet integral (39) Discrete versions Our analog to digital converter will obtain a sampling of values on the decaying oscillations at a conversion rate or frequency f0 . A typical rate, also the maximum for our data acquisition board, is 500,000 per second. The spacing of measurements in time ∆t is then given by 1 (40) ∆t = f0 Data are collected at N points equally spaced in time with this time interval between them. Defining t = 0 at the first point, the time grid for the sampling can be expressed: ti = i∆t (41) for i = 0...N − 1 and the full sample becomes xi = x(ti ) (42) The discrete Fourier transform (DFT) of such a sample is defined by x̃k = N −1 X xi e−j2πki/N (43) i=0 For a complex series of the same length N zi = xi + jyi = z(ti ) (44) (45) the discrete Fourier transform (DFT) takes the same form z̃k = N −1 X zi e−j2πki/N (46) i=0 Algorithms to implement DFTs such as Eq. 46 then return values of z̃k for −N/2 ≤ k ≤ N/2−1, i.e., N complex values. Note that the discrete Fourier transforms of real functions, such as xi or yi , have only N independent quantities; their real parts being constrained to be symmetric and their imaginary parts constrained to be antisymmetric as demonstrated by Eqs. 23 and 24. To see how the DFT and continuous Fourier transforms are related, use the “rectangle rule” for numerical integration of Eq. 17 (taking z(t) = 0 for t < 0 and for t > N ∆t, i.e., outside the sampling interval) as Z ∞ z̃(ω) = z(t)e−jωt dt −∞ N −1 X z(ti )e−jωti ∆t = i=0 N −1 X zi e−jωti ∆t (47) 2π N ∆t (48) ωk = k∆ω (49) = i=0 Now define the angular spacing ∆ω = so that the frequency grid can be expressed2 Using Eqs. 41 and 49, Eq. 46 becomes z̃k = N −1 X z(ti )e−jωk ti (50) i=0 and comparing this with Eq. 47 shows z̃(ωk ) = z̃k ∆t (51) With z̃(ω) determined on a grid of spacing ∆ω, the appropriate representation of r̃τ (ω), would be on that same grid spacing. The rectangle rule for integration then gives Eq. 39 as M 1 X z̃τ (ωi ) = z̃(ωi−k )r̃τ (ωk )∆ω (52) 2π k=−M where M is not infinite as the theory requires, but is chosen large enough to give a satisfactory representation of r̃τ (ω). Note that the size of M will limit the values of i for which all terms in the convolution exist. Values for z̃τ (ωi ) within M points of the ends will not be calculable. Normally, fits are over regions well away from the end points and even large values of M can be accommodated, although larger M values slow execution speed. 2 The frequency spacing ∆f = ∆ω/2π changes the spacing units from rad/sec to hertz. Dividing Eq. 48 by 2π and using Eq. 40 shows that this spacing is ∆f = f0 /N . Let the discrete version of r̃τ (ωk ) include all normalization factors so that r̃τ k = ∆ω r̃τ (ωk ) 2π (53) Then Eq. 52 becomes M X z̃τ (ωi ) = z̃i−k r̃τ k (54) k=−M and Eq. 35 translates to the normalization condition for r̃τ k ∞ X r̃τ k = 1 (55) k=−∞ Experiment vs. theory The user selects a subset of the acquired data for analysis—typically extending from the start of the freely decaying oscillations to a point where the oscillations are small compared to the noise. The beginning point defines t = 0, i = 0. The user also selects a length N for a DFT and the program either truncates the subset to this length or pads the subset with zeros to make the input series have the length N . The program then performs a DFT on that series to get x̃k and multiplies it by ∆t to get the “measured” x̃m (ωk ). The program also determines the appropriate frequency grid ωk and calculates the convolution function r̃τ k . On the Frequency domain tab, graphs of the real and imaginary parts of x̃m (ωk ) and of r̃τ k are displayed. The user selects a continuous subset around the resonance on the plots of x̃m (ωk ) to fit to the theoretical predictions. The predictions, of course, are based on the values of the ωk in the subset. The theory, along with its four parameters A, φ, γ, and ω00 , predicts values for x̃(ωk ). The parameters are determined by a fit that minimizes the chi-square. Before describing the chi-square, lets go over the prediction. The theory predicts each x̃(ωk ) should be given by Eq. 21 with a z̃(ω) replaced by the prediction of Eq. 52 with Eqs. 27 for z̃k = z̃(ωk ) and Eq. 53 with Eq. 34 for r̃τ k . The program rescales the value of r̃τ k slightly. It has a control that sets how many oscillations (to each side of zero) should be included in the convolution function, making it have finite length −M ≤ k ≤ M , with r̃τ k = 0 outside this range. The values for r̃τ k start from Eq. 53, which have the normalization given by Eq. 55, but then the values are renormalized such that M X k=−M r̃τ k = 1 (56) This is done so that the convolution gives the same normalization of z̃τ (ωi ) as for z̃(ωi ) even with the finite convolution. In the Time domain|Fourier transform page, the user finds the controls to determine the value of N , the size of the Fourier transform. N is only allowed to be a power of 2 so that fast Fourier transform algorithms can be used. In the Frequency domain|Fit tab, the program gives the user the option to skip the convolution step and fit with z̃(ω) given by Eq. 27. Skipping the convolution step is appropriate whenever the subset of xi continues out to times when any remaining oscillations are much smaller than the noise. In this case, the data subset interval satisfies τ γ 1 and the width of the convolution function is small compared to the width of the resonance peak. The convolution then has little or no effect on the prediction and this step need not be included. It is only when the τ is small enough that the decaying oscillations are obviously truncated that the x̃(ωk ) shows the effects of the truncation and the convolution is required to get accurate results from the fit. As a check, one can also perform the fit without the convolution, check the sample standard deviation, and then see if its value decreases when the convolution is included. The program assumes that the real and imaginary parts of each value of x̃(ωk ) have the same standard deviation or uncertainty σx̃ . With this assumption the chi-square is proportional to the sample variance s2 which can be calculated from s2 = X 1 (<{x̃m (ωk )} − <{x̃(ωk )})2 + (={x̃m (ωk )} − ={x̃(ωk )})2 2Nk − 4 all k where Nk is the number of points chosen on the x̃(ωk ) plots as the fitting region. (57)