Re: Fourier series interpolation
- To: mathgroup at smc.vnet.net
- Subject: [mg41949] Re: Fourier series interpolation
- From: "Dana DeLouis" <delouis at bellsouth.net>
- Date: Wed, 11 Jun 2003 03:49:45 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hello. I am new at this, but I will take a chance. It sounds like you are asking about the features in the package <<NumericalMath`TrigFit` This uses Fourier Analysis to fit your data. Here, 12 is the Length of your data fx = TrigFit[data, 12, {x, 12}] 0.00524167 + 0.127211 Cos[0.523599 x] + 0.146225 Cos[1.0472 x] + 0.0761833 Cos[1.5708 x] + 0.287008 Cos[2.0944 x] + 0.227756 Cos[2.61799 x] + 0.0530484 Sin[0.523599 x] + 0.22443 Sin[1.0472 x] - 0.428567 Sin[1.5708 x] + 0.22316 Sin[2.0944 x] - 0.120965 Sin[2.61799 x] If this is what you are asking, be advised that this function has at least 2 bugs. First, it the number of points (n) is an even number, it does not capture the Cos term at harmonic n/2. This renders it useless. Second, the program assumes that the option for "FourierParameters" is set to default. This may not be the case, and it will not work if you have it set to something different. (Say data analysis). Therefore, in the example above, you will get wrong answers because the number of points is 12 (even)... Table[fx, {x, 0, 11}] This is because it is missing a Cos term. (The Cos term at n/2. In this case, it would be "- (853*(-1)^x)/8000" Therefore, if you add this in, you will get your original data back. Table[fx - (853*(-1)^x)/8000, {x, 0, 11}] {0.763, -0.1205, -0.0649, 0.6133, -0.2697, -0.7216, -0.0993, 0.9787, -0.5689, -0.108, -0.3685, 0.0293} -- Dana DeLouis Windows XP Mathematica $VersionNumber -> 4.2 delouis at bellsouth.net = = = = = = = = = = = = = = = = = "Bob Buchanan" <Bob.Buchanan at millersville.edu> wrote in message news:bbv4hr$22h$1 at smc.vnet.net... > Hello, > > If I use my own DFT function I can create an interpolatory least > squares polynomial for a set of discrete data points. For example if > my input data is the list: > > data = {0.7630, -0.1205, -0.0649, 0.6133, -0.2697, -0.7216, -0.0993, > 0.9787, -0.5689, -0.1080, -0.3685, 0.0293}; > > and > > MyFourier[f_List] := > Module[{tmp}, > tmp = Table[ > Exp[-2 Pi I n k/Length[f]], {n, -Length[f]/2 + 1, Length[f]/2, > > 1}, {k, -Length[f]/2 + 1, Length[f]/2, 1}]; tmp.f/Length[f]] > > Then > > fdata = Chop[MyFourier[data]] > > produces > > {0.06838\[InvisibleSpace] - 0.109318 \[ImaginaryI], -0.168383 + > 0.0684882 \[ImaginaryI], -0.214283 - 0.0380917 \[ImaginaryI], > -0.060625 + > 0.119425 \[ImaginaryI], -0.0418217 - > 0.0547732 \[ImaginaryI], 0.00524167, -0.0418217 + > 0.0547732 \[ImaginaryI], -0.060625 - 0.119425 \[ImaginaryI], > -0.214283 + > 0.0380917 \[ImaginaryI], -0.168383 - 0.0684882 \[ImaginaryI], > 0.06838\[InvisibleSpace] + 0.109318 \[ImaginaryI], 0.106625} > > I can then create the Fourier polynomial with > > Chop[ExpToTrig[ > fdata.Table[ > Exp[I 2Pi k x], {k, -Length[fdata]/2 + 1, Length[fdata]/2, > 1}]]] > > How do I create the Fourier polynomial from the output of > Mathematica's Fourier[] command with the default settings for the > FourierParameters? > > Thanks, > Bob Buchanan >