Re: Interpolation with FourierTrigSeries with mathematica 6 tia sal2
- To: mathgroup at smc.vnet.net
- Subject: [mg88489] Re: Interpolation with FourierTrigSeries with mathematica 6 tia sal2
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 6 May 2008 06:43:51 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fvmmo4$8a6$1@smc.vnet.net>
ratullochjk2 at gmail.com wrote:
> Interpolation with FourierTrigSeries with mathematica 6 tia sal2
<snip>
> When I change different data points to the code example:
>
> data2 = {{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17, 6}, {19, -2},
> {25, -6}, {34, 6}, {41, 4}, {49, -6}, {56, -5}, {63, 4}, {69, 3}, {74,
> -5}, {77, -3}, {86, 3}, {90, 7}, {95, -3}, {96, -8}, {103, 7}, {112,
> 9}, {120, -8}, {129, -9}, {138, 9}};
=============================^^^^^^^
The endpoint must have a y-value equals to the y-value of the start
point. In your case, since the function starts with a value of zero, the
last point must be {138, 0} because the function *must* be periodic.
This is exactly what Mathematica complains about in the *error message*
you have chosen to disregard.
Needs["FourierSeries`"]
data2 = {{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17,
6}, {19, -2}, {25, -6}, {34, 6}, {41, 4}, {49, -6}, {56, -5}, {63,
4}, {69, 3}, {74, -5}, {77, -3}, {86, 3}, {90,
7}, {95, -3}, {96, -8}, {103, 7}, {112,
9}, {120, -8}, {129, -9}, {138, 9}};
f = Interpolation[data2, PeriodicInterpolation -> True];
s[x_] = N[
FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]]
Interpolation::per: In dimension 1 the data at the endpoints of the \
fundamental period are not equal. >>
> f = Interpolation[data2, PeriodicInterpolation -> True];
> << "FourierSeries`"
>
> s[x_] = N[
> FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]]
>
> my partial output becomes :
>
> 0.00729927 NIntegrate[
> Interpolation[{{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17,
> 6}, {19, -2}, {25, -6}, {34, 6}, {41,
> 4}, {49, -6}, {56, -5}, {63, 4}, {69,
> 3}, {74, -5}, {77, -3}, {86, 3}, {90,
> 7}, {95, -3}, {96, -8}, {103, 7}, {112,
> 9}, {120, -8}, {129, -9}, {138, 9}},
> PeriodicInterpolation -> True][x], {x, -(137/2), 137/2}] +
> 0.0145985 Cos[0.0458627 x] NIntegrate..........................
>
> does anyone know why this no longer outputs in the form of just sin
> and cos?
> (which I really want)
Therefore, using *periodic* data points, we get
Needs["FourierSeries`"]
data2 = {{0, 0}, {1, 1}, {3, 0}, {7, -2}, {14, 1}, {17,
6}, {19, -2}, {25, -6}, {34, 6}, {41, 4}, {49, -6}, {56, -5}, {63,
4}, {69, 3}, {74, -5}, {77, -3}, {86, 3}, {90,
7}, {95, -3}, {96, -8}, {103, 7}, {112,
9}, {120, -8}, {129, -9}, {138, 0}};
f = Interpolation[data2, PeriodicInterpolation -> True];
s[x_] = N[
FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]]
[Warning messages about slow convergence discarded]
-1.33366 - 1.93771 Cos[0.0455303 x] - 1.84218 Cos[0.0910607 x] -
0.915718 Cos[0.136591 x] + 1.96324 Cos[0.182121 x] +
1.32678 Cos[0.227652 x] + 0.178997 Cos[0.273182 x] -
1.85621 Cos[0.318712 x] + 1.24014 Cos[0.364243 x] +
2.53467 Cos[0.409773 x] + 0.178343 Cos[0.455303 x] -
0.597821 Cos[0.500834 x] + 0.59092 Cos[0.546364 x] -
0.129048 Cos[0.591894 x] - 0.377664 Cos[0.637425 x] +
0.303572 Cos[0.682955 x] + 1.10636 Cos[0.728485 x] +
0.234811 Cos[0.774016 x] - 0.339997 Cos[0.819546 x] -
0.247664 Cos[0.865076 x] + 0.136132 Cos[0.910607 x] -
0.0551202 Cos[0.956137 x] - 0.146821 Cos[1.00167 x] -
0.028917 Cos[1.0472 x] + 0.0668191 Cos[1.09273 x] -
0.0534889 Cos[1.13826 x] - 0.19826 Sin[0.0455303 x] +
0.823365 Sin[0.0910607 x] + 0.967715 Sin[0.136591 x] +
3.57456 Sin[0.182121 x] + 3.72198 Sin[0.227652 x] -
4.41631 Sin[0.273182 x] - 0.783889 Sin[0.318712 x] +
0.985987 Sin[0.364243 x] + 0.297933 Sin[0.409773 x] -
0.182527 Sin[0.455303 x] + 1.85795 Sin[0.500834 x] +
0.603078 Sin[0.546364 x] - 0.92085 Sin[0.591894 x] -
0.693979 Sin[0.637425 x] + 0.0286992 Sin[0.682955 x] +
0.0714767 Sin[0.728485 x] - 0.0838198 Sin[0.774016 x] +
0.284645 Sin[0.819546 x] + 0.296819 Sin[0.865076 x] -
0.138192 Sin[0.910607 x] - 0.320014 Sin[0.956137 x] +
0.0703057 Sin[1.00167 x] + 0.176853 Sin[1.0472 x] +
0.0718324 Sin[1.09273 x] - 0.10215 Sin[1.13826 x]
Regards,
-- Jean-Marc