MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Efficiently compute Fourier coefficients for discrete function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105425] Efficiently compute Fourier coefficients for discrete function
  • From: Kelly Jones <kelly.terry.jones at gmail.com>
  • Date: Wed, 2 Dec 2009 06:25:51 -0500 (EST)

Mathematica-wise, how to efficiently compute the Fourier coefficients
for a function defined at finite "random" points. Example:

This defines Sin[3*x] for 100 random values of x:

l = Table[Random[],{i,1,100}]
l2 = Table[{l[[i]],Sin[3*l[[i]]]},{i,1,Length[l]}]

This calculates the nth Fourier coefficient:

pfourier[s_,n_] := Sum[s[[i]][[2]]*Exp[-I*n*s[[i]][[1]]], {i,1,Length[s]}]

(I realize I'm off by a factor of pi; I'm only interested in relative
size for now).

As expected, the imaginary/sine part of the 3rd coefficient has the
greatest magnitude:

Table[Im[pfourier[l2,n]],{n,1,10}]

I could compute pfourier[l2,n] for all n, but that seems inefficient.

Is there a simpler function (similar to Fourier and FourierTransform)
that does this?

-- 
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.


  • Prev by Date: Re: By Reference
  • Next by Date: Re: Permanent Computation Efficiency
  • Previous by thread: Re: Re: Combine images, Show[] and its effect on
  • Next by thread: Re: Efficiently compute Fourier coefficients for discrete function