[Date Index]
[Thread Index]
[Author Index]
Re: Fourier Series Expansions and it's Coefficients question revised tia
*To*: mathgroup at smc.vnet.net
*Subject*: [mg85402] Re: Fourier Series Expansions and it's Coefficients question revised tia
*From*: "Dana DeLouis" <dana.del at gmail.com>
*Date*: Sat, 9 Feb 2008 04:15:52 -0500 (EST)
> If I'm giving a repeating wave at (T) period of 10 seconds
> with amplitudes 14, 18.7,9,4.1,6.7,6,6.3,8.4,4,2.9
> how can I find the Fourier Series Expansions
> in Trigonometric form using mathematica 6.
Hi. I recognize this problem from the book "Who is Fourier," page 131.
It's an Excellent book. :>)
Although not directly supported in Ver. 6, under help for "TrigFit," there
is a link to an on-line version. One can also load it in version 6 via:
Needs["NumericalMath`TrigFit`"]
(located under the LegacyPackagesprogram's folder. Help forgets to mention
this)
Just note the Bug that is still there when we have an even number of points
that I mentioned earlier.
To follow along in the book, what you need to use is "Fourier"
We get 10 outputs. However, note that positions 7-10 are mirror images of
positions 2-5. They are Complex Conjugates. In a custom program to do what
we want, we can ignore the bottom half.
f=Take[N[Rationalize[Chop[Fourier[d,FourierParameters->{-1,1}]]]],6]
{8.01,
1.5112054648812023+1.018786064854467 I,
1.0062054648812022+2.0112673197265365 I,
0.493794535118798+1.499566588737676 I,
-0.011205464881202155+0.020706728375915695 I,
-0.01}
The first and last have no Conjugate, so the equation from these two is:
8.01 -.01 Cos((2 Pi x 5)/10) ->
8.01 - .01 Cos(Pi x)
However, the middle 4 terms do not match the book. Why? This is because
these are "Half" the values. The other half is the conjugates that we
discarded. Hence, we multiply the middle terms by 2.
2 * Take[f,{2,-2}]
{3.0224109297624047 + 2.037572129708934 I,
2.0124109297624044 + 4.022534639453073 I,
0.987589070237596 + 2.999133177475352 I,
-0.02241092976240431 + 0.04141345675183139 I}
You should recognize these values, where the Real number is associated with
Cos, and the Imaginary part goes with Sin.
The integer solution on page 133 is just rounding the values to the nearest
integer. (We don't double the 8.01 zero frequency value)
Round(2 Rest[f])
3+2 I,
2+4 I,
1+3 I,
0,
0
As a side note, you may find this interesting. I have a custom function
that joins the Cos & Sin like terms. Here is the general outline:
We extract the first 6 terms of Fourier Output as above.
With an even number of points, we take the first and last value to begin
making our equation. (Cos(Pi x) is either +1, or -1 with integer values of
x)
Equ = 8.01 - 0.01*(-1)^x
If we want to favor using Cos, we phase them together with something like
this:
fftCos[n_,{f_}] := 2*Norm[n]*Cos[(2*Pi*f*x)/p-ArcTan[Re[n],Im[n]]]
p=10;
equ += Plus@@MapIndexed[fftCos,Take[f,{2,-2}]]
8.01 - 0.01*(-1)^x
+0.04708847176274919*Cos[2.0668202337133366-(4*Pi*x)/5]
+3.1575515811916928*Cos[1.2526878202179634-(3*Pi*x)/5]
+4.4978420020969*Cos[1.10692130297598-(2*Pi*x)/5]
+3.645088203612341*Cos[0.5931686344232912-(Pi*x)/5]
If we use the above equation, we see that we get our original data (d)
N[Rationalize[Table[equ, {x, 0, 9}]]]
{14., 18.7, 9., 4.1, 6.7, 6., 6.3, 8.4, 4., 2.9}
% == d
True
One reason I like to do it this way is that a secondary program can go back
and try to eliminate frequencies that are not significant.( to a user's
choice of course)
In the above, note that the following has a very small maximum amplitude,
and does not contribute much.
+0.04708847176274919*Cos[2.0668202337133366-(4*Pi*x)/5]
If a user wishes, one could probably eliminate this frequency without
harming the output. If you round the results to 1-2 digits, then the output
matches the input data.
Note that if one wishes to favor using Sin, then
fftSin[n_,{f_}]:=
2 Norm[n]*Sin[(2 Pi f x)/p+ArcTan[Im[n],Re[n]]]
Anyway, hope this helps.
:>)
Dana DeLouis
Prev by Date:
**Re: How should I start with mathematica?**
Next by Date:
**Re: number pattern sequence tia sal2**
Previous by thread:
**Re: Fourier Series Expansions and it's Coefficients question revised tia**
Next by thread:
**Re: Point is not a Graphics primitive?**
| |