Professional Documents
Culture Documents
Fourier Analysis Using A Spreadsheet: Articles You May Be Interested in
Fourier Analysis Using A Spreadsheet: Articles You May Be Interested in
Spreadsheets Tackle Physics ProblemsUsing Lotus 1-2-3 and software from the AAPT bulletin board,
physicists can quickly solve and graph a multitude of problems
Computers in Physics 2, 37 (1988); https://doi.org/10.1063/1.4822723
or many tasks involving Fourier analysis, a spread- fast Hartley transform (FHT) should be practical.
Fourier [Hample 1.
acceptable accuracy may require a substantial number of The "norm" elements are entered in the form
integration nodes ,x-j ' Integration nodes are arranged "I = surntsi' si' dxl j"using the command key and a
downward, with harmonic numbers across, because that carriage return, to make them array function formulas,
fits the screen format best. If the data to be analyzed are which can act, for example, to give the inner product of
gen erate d by another program, Fortran for example, they the elements of the vectors "sin " and "dx" [that is,
can b e stored one number per row, so that they can ~ (sin ) j . (sin), . tdxl] . Function formulas are set off by
con ven ie n tly be pasted into Excel using the Macintosh braces: I···J.
Clipboard. The rows labeled " Cosin e Coefficients" and "Sin e
At the bottom of the column blocks labeled "si n " Coefficients" are filled with similar array function
and "co n " are formulas for the integrations. The formulas having the forms:
numbers labeled "n orm " are the values of j'sin" nx dx and "! = SUM(y' R[ - 23]C:R[ - 3]C' dxl/B] + 3]Cj " and
jcos'' nx dX" multiplied by an overall normalizing number
" facto r." For the present sine and cosine basis and ,, ' = SUM(y' R[ - 24]C:R[ - 4]C' dX"l/R[ + 2]Cj"
assumed integration interval [O,p1T], these values are all where the divisor picks up the value of "n o rm" from the
p1T exce p t those for n = 0, which are 0 and 2p1T. To save same colu m n and the symbol "R[ - 25]C:R[ - 5]C " calls
time, these could be changed to con stan t values 1, 0, and 2 out the basis function vector from the same column.
and " fa cto r " to p1T; they are as indicated to provide for If more integration nodes are needed, one can in sert
use with another set of orthogonal functions. the appropriate number of blank rows somewhere after
" 0 which preface the n value with the text =SUM(R[ -27)C :RH - SUM(R[- 27 )C:R[- 7 )C" 2 * dx) ' -SUM (R(-27)C :R[- 7 )C"2 * dx)
31
in quotes.
the second row of nodes and before the last one. Then the Macintosh II and use of a floating point co-processor chip
relative duplication command ("Fill Down") can be used the calculation time for about a thousand elements and a
to populate the template from the second node down half dozen coefficients is roughly a minute.
through the last. This should provide the required higher The approach here is generally the same as in the
integration accuracy when new data Wi) are added. first example, except that the coefficients are entered as
If another harmonic value is required, the user can the array function formulas
copy the two-column rectangle from "si n co n" down
through the "n orm " line into the two blank columns at
the right of the presently filled zone. To make this
"! = SUMly' SIN (n*X))/norm I" and
possible, the sine and cosine formulas were written in "I =SUMly 'COS(n*X))/normj " where the
mixed form .. = si ' RC[ - 1] + co RC[ - 2]," which
means multiply the element on this row of the vector row array n is defined as labeled, and norm is set to p1T for
named "si" by the element of this row and one column the Fourier transform to eliminate some repetition of the
back, and add the corresponding element of vector "co " sine and cosine calculations . An easily misleading
times the element two columns back. These formulas are complication arose in this example. An initial assumption
not array function formulas because the intent is to proved incorrect: that the proper element of a row array
eva lu ate a column vector row by row using data from the norm, as in Example 1, would be used by the array
same row of other column vectors. The vectors "si" and formula definingfn and Sn- Instead, the first element of
" co " were defined to be columns C6 and C7, elements R4 the norm array was used even for succeeding columns.
through R24 in the present case, and should not be This feature could be called a bug in Excel (version 1.04),
confused with functions SIN(argument) and COS(argu- but might be specified somewhere in fine print in the
ment). manual. The work-around chosen here was to reduce
norm to a scalar and then insert the necessary factor 2 in
Fourier Template 2
the formula for fa.
To reduce memory usage (by about half) in the case Integration nodes could be added to this template in
of large data sets f (;JCj), the basic functions in this example the same manner as in the first example. Providing more
are not determined once and stored. Instead, they are coefficients is also about the same: insert new columns
recalculated for each coefficient and case. Calculation after the n = 1 calculation and replicate the n,fn, gn and
time is about doubled, but still not large; with a norm columns to the right, as far as the last one.
t.~ffl~l-tf!~:~;:~·rl~lfff
~ :?....__........ ..
l..._......._....._....._................
tz, .~_.._............... ';;;;RFi·iE~· R·2'c·i
;'Ri': 'j" jC-';:R2C7'
;;;b·ii·~·~·i ;,;·s·i~i(~f.;:·. Si neo
·;;·bo:;::;·i"*s·ii·j·(·~·j·~·
j
,
8 4
5. A partial listing of the 'program' for
1
2 4 20
2S
=R[-1 lC+R2C7 =RC[- 1)- R[- 1lC[-1
!( 0'l1) , !
=bO+al *S IN( x ) +
,.l!.~~.~..9~~.~~.C~.!.t~·i·f.~r.·T.~..!.~..~~..!.n..\~.gr..~. template 2. Columns 5 and 7 are not
shown fully.
Fouri er [ Hampl e 3.
vel)' rapid analysis, at the expense of substantially more '2.Jikt/Jn ) cos kt/Jn = [co - CI costPn ]
k~o
involved logic, restriction to uniform data spacing and to
a number of data points that can be decomposed into a and
K
product of powers of small prime numbers [z'" ·3" ...].
"Lfikt/Jn) sinkt/Jn = C 1 sint/Jn,
A compact and elegant process arising from a k=o
suggestion in F. S. Acton's book Numerical Methods That
Work, Harper and Row, 1970, provides an intermediate
when ck = (2 cost/Jn ),ck + 1 - ck + 2 + fl.kt/Jn), for
k=K, ...,I,O, with CK+l =CK+2 =0.
level of speed and complexity. It applies to uniformly
spaced data with arbitral)' number of points, and gives
an attractively simple template requiring only one sine
FOR FURTHER READING
and cosine per harmonic. The scaling of calculation time Numerical Methods That Work, mentioned above,
is asjM times nmex rather thanjM InjM for the FFT gives a fine discussion of the merits of using recurrence
process; it can be competitive then when only a few tens formulas to extend tables of standard functions. A more
of data points are needed and the required highest recent book is Numerical Recipes by Press, Flannel)',
harmonic, nmex, is not large. The speed is about twice Teolkowsky and Vetterling, Cambridge Press, 1986.
that of Example I, and four times that of Example 2.; Readers' suggestions for useful or especially effective
storage requirements are slightly (10%) under those for texts on numerical/mathematical methods would be
Example 1, twice that of Example 2. appreciated. They can be sent in care of Computers In
The process is based on recurrence formulas for Physics, American Institute of Physics, 335 East 45th
cosines and sines: Street, New York, N.Y., 10017. •