Lyons FFT Interpolation Based On FFT Samples PDF
Lyons FFT Interpolation Based On FFT Samples PDF
My fixation on one equation in that paper led to the creation of this blog.
Background
The notion of FFT interpolation is straightforward to describe. That is, for
example, given an N = 16 sample x(n) time-domain sequence shown in Figure
1(a), performing an N = 16 point FFT on x(n) produces the |X(m)| magnitude of
samples shown by the red dots in Figure 1(b). The blue dashed curve in Figure
1(b) is the magnitude of the discrete-time Fourier transform (DTFT) of x(n),
what I like to call the "true spectrum" of x(n).
0.5
0
(a) 0 5 10 15
n
magnitude samples
0
0 3 4 5 10 15
Freq (m)
(b) |X(k)| where
k = 4.4688
The process of FFT interpolation is estimating an X(k) spectral value at, for
example, a non-integer frequency of k = 4.4688 lying between the m = 4 and
m = 5 FFT samples. The magnitude of X(k) is marked by the bold 'x' in Figure
1(b).
where:
To avoid overwhelming the reader with too many algebra equations, I've
included the derivation of Eq. (1) in Appendix.
Not having seen Eq. (1) before I decided to model it using MATLAB software.
Plugging my Figure 1(b) complex-valued X(m) FFT samples and k = 4.4688 into
Eq. (1) I computed an XRef.[1](4.4688) value of:
Next, padding the x(n) time sequence with lots of zero-valued samples I
computed a finer-granularity spectrum shown by the blue dashed curve in
Figure 1(b). From that finer-resolution spectrum I learned the true value of
XTrue(4.4688) is:
which is not even close to the above XRef.[1](4.4688) spectral value computed
using Eq. (1)! So what's going on here(!)?
So now it seems likely that Eq. (1) is not valid. But if that is true, how
could the three authors of Reference [1] have missed that error? That was the
mystery I set out to solve.
We'll revisit Eq. (1) later in this blog and learn something interesting in
our quest to understand that equation.
N 1 X(m) 1 ej2k
X(k) N . (3)
m 0 1 ej2(k m)/N
1 ej2k N 1 X(m)
X(k) . (4)
N j2(k m)/N
m 0 1 e
N 1
1 sin[(k-m)]
X(k) X(m) ej(k m)(1-1/N ) . (5)
N sin[(k-m)/ N]
m 0
Equation (5) works just fine for computing our desired X(k)! So now it's
interesting to see what went wrong in Eq. (1). The authors of [1] applied two
algebraic approximations to Eq. (5) to produce the faulty Eq. (1):
Approximation# 1:
Based on the assumption that N >> 1, they used the venerable
approximation 'sin(x) = x for small x' (employed in almost
every DSP textbook) to simplify the Eq. (5) ratio's
sin[(k-m)/N] denominator to (k-m)/N for Eq. (1). The problem
in doing this is factor (k-m) can be almost as large as N in
which case the angle (k-m)/N is not small making the
approximation invalid.
Approximation# 2:
In the exponent of Eq. (5) they replaced the factor
0 3
–1
Radians
2
–2 1
–3
0
0 20 40 60 0 20 40 60
m m
Incorrect denominator (b) Incorrect angle of
(a) in Eq. (1) exponent in Eq. (1)
Analyzing the errors induced by those two approximations solves the mystery
of why Eq. (1) is flawed. By the way, I've modeled Eq. (1) for values of
N = 16 out to N = 16384 with no improvement in its accuracy for larger N.
Next we discuss the computational costs of this blog's FFT interpolation
equations.
Assuming we have previously computed and stored all the constant factors in
our equations that are not functions of k or m, Table 1 shows the reduction
in the necessary computations needed by Eqs. (4) and (5) relative to Eqs. (2)
and (3). (In Table 1, a "Trigonometric Computation" means computing the sine
or cosine of some given angle.)
We remind the reader that Trigonometric Computations and Real Divides are far
more computationally costly than Real Adds and Real Multiplies.
N 1
X(k) x(n) ej2(kn)/N (6)
n 0
where, again, 0 ≤ k ≤ N-1, and k is not an integer. Assuming the x(n) input
in Eq. (6) is real-only, the computational workload comparison of Eq. (6) to
my favorite Eq. (4) is given in Table 2.
Eq. (4) 7N + 1 7N + 5 2N + 1 2N + 2
{Ref. [3]}
Eq. (6) 2N 4N + 1 1* 2N
{DFT}
[* This single divide is the 1/N operation is used once to compute
and store the constant 2/N factor for the exponent of Eq. (6).
From Table 2 we see that Eq. (6) requires significantly fewer arithmetic
operations—notably eliminating 2N of those costly 'Real Divides'—than Eq.
(4).
Conclusions
I presented an X(k) FFT interpolation equation published in the literature,
Eq. (1), for computing a single X(k) spectral value based on N FFT samples,
where frequency k is not an integer. Equation (1) is not valid and I showed
why that is so. (I remain troubled by this and perhaps someone can prove me
wrong.) Next I presented four different expressions, Eq. (2) through Eq. (5),
for computing an X(m) sample and compared their computational costs. Finally
I realized the most efficient method for computing a single X(m) sample is to
simply perform an N-point DFT using Eq. (6).
I apologize for this blog being so lengthy. I didn't have the time to make it
shorter.
References
[1] S. Ransom, S. Eikenberry, and J. Middleditch, "Fourier Techniques For
Very Long Astrophysical Time-Series Analysis", The Astronomical Journal,
Sept. 2002, Section 4.1, pp. 1796.
[http://iopscience.iop.org/article/10.1086/342285/pdf]
N 1
X(k) x(n) ej2(kn)/N (A-1)
n 0
Because we have the X(m) sequence (the DFT of x(n)) available to us, we can
replace x(n) in Eq. (A-1) with the inverse DFT of X(m) as:
1 N 1
N 1
X(k)
N
X(m)ej2(mn)/N ej2(kn)/N
n 0 m 0
N 1 N 1 N 1 N 1
ej2n(k-m)/N ej2[(k-m)/N]n .
1 1
N
X(m)
N
X(m) (A-2)
m 0 n 0 m 0 n 0
The second summation in Eq. (A-2) is a 'sum of a power series in n' and it
has a closed form. Using the summation–to-closed form identity:
N 1 sin(N /2)
ejn ej(N -1)/2 (A-3)
sin(/2)
n 0
N 1
sin[(k-m)]
ej2[(k-m)/N]n ej2[(k-m)(N -1)/(2N )]
sin[(k-m)/N]
n 0
sin[(k-m)]
ej[(k-m)
(1-1/N ) . (A-4)
sin[(k-m)/N]
Plugging Eq. (A-4) in for the second summation in Eq. (A-2) allows us to
rewrite Eq. (A-2), our desired A(k) expression, as:
N 1
sin[(k-m)]
X(m) ej[(k-m)
1 (1-1/N)
X(k)
N
sin[(k-m)/N]
(A-5)
m 0
applied to the exponent in Eq. (A-5) yielding [1]'s final expression for X(k)
as:
N 1
sin[(k-m)]
X(k) X(m) ej(k m) (A-6)
(k-m)
m 0
N 1
X(z) x(n)zn . (B-1)
n 0
Because we have the X(m) sequence (the DFT of x(n)) available to us, we can
replace x(n) in Eq. (B-1) with the inverse DFT of X(m) as:
N 1 n
1 N 1
N 1 N 1
X(m) ej2m/N z1
X(z)
N
X(m)ej2(mn)/N zn
N
(B-2)
n 0 m 0 m 0 n 0
The summation within the brackets in Eq. (B-2) is a 'sum of a power series in
n' and it has a closed form. Using the summation–to-closed form identity:
N 1 1-rN
rn (B-3)
1-r
n 0
j2m/N -1
where r = e z , we can write
N
N 1 1 ej2m/N z1
n 1 zN
ej2m/N z1 j2m/N z1
j2m/N z1
. (B-4)
n 0 1 e 1 e
Plugging Eq. (B-4) in for the second summation in Eq. (B-2) allows us to
write our X(z) expression as:
N 1 X(m) 1 zN
X(z) N . (B-5)
m 0 1 ej2m/N z1
So here's where we stand; Eq. (B-5) tells us how to compute X(z), for any z,
using our X(m) DFT samples. Now all we have to do is evaluate Eq. (B-5) on
the z-plane's unit circle at a frequency of radians, 0 ≤ < 2, to obtain
j
a desired X() spectral value. So on the unit circle with z = e we have:
N 1 X(m) 1 ejN
N . (B-6)
m 0 1 ej(-2m/N )
We can now simplify Eq. (B-6)—here's the clever step. If we multiply and
divide the numerator and denominator of Eq. (B-6)'s right hand side by the
appropriate half-angled exponentials, we break the exponentials into two
parts and obtain:
N 1 X(m)
X()
ejN/2 ejN/2 ejN/2
.
(B-7)
m 0
N e
j(/2-m/N) ej(/2-m/N) ej(/2-m/N)
Using Euler's equation: 2jsin()= (e -e- ) we can rewrite Eq. (B-7) as:
N 1 X(m) ejN/2(2j)sin(N/2)
X() N j(/2-m/N)
m 0 e (2j)sin(/2-m/N)
Equation (B-8) is Eq. (2.142) in [2]. Next, when we determine our value for
based on k, where = 2k/N, we have:
N 1 X(m) ej(2k/N )
[(N -1)/2] sin(k)
X(k) N
m 0 ejm/N sin[(2k/N)/2-m/N]
N 1 X(m) 1 zN
X(z) N . (C-1)
m 0 1 ej2m/N z1
Equation (C-1) tells us how to compute X(z), for any z, using our X(m) DFT
samples. Now all we have to do is evaluate Eq. (C-1) on the z-plane's unit
circle at a frequency of 2k/N radians to obtain our desired X(k) spectral
j2k/N
value. On the unit circle with z = e we have:
N 1 X(m) 1 e j2k
N . (C-2)
m 0 1 ej2(k m)/N
Again, keep in mind that our DFT bin index-like frequency variable k, where
0 ≤ k ≤ N-1, is not restricted to be an integer.