MathGroup Archive 2008

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

Search the Archive

Re: Interpolation and plot doing strange things with mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88978] Re: Interpolation and plot doing strange things with mathematica
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 22 May 2008 06:16:59 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <g134je$m3l$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

if you make a approximation based on a Fourier series
it converges "in the middle" and never point wise
The most famous example is the Gibbs phenomenon.
http://en.wikipedia.org/wiki/Gibbs_phenomenon

Regards
   Jens

ratullochjk2 at gmail.com wrote:
> Greetings All
> 
> I run these commands that I've had plenty of help getting to
> work...but the plot doesn't follow the points, as you can see in the
> plot.  At the end it just goes crazy and when I test the points with
> 
> input s[0]
> output is -3.73293
> why are the numbers so out of sync... at s[0] it should be -2 not
> -3.73293
> 
> I try increasing the number in the line
> N[FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]]
> (I've changed the number 25 to over 100 and the problem seems to get
> worse)
> 
> See code below:
> 
> In[89]:= data3 = {{0, -2}, {7, 1}, {10, 6}, {12, -2}, {18, -6}, {27,
> 6}, {34,
>     4}, {42, -6}, {49, -5}, {56, 4}, {62, 3}, {67, -5}, {70, -3}, {79,
>      3}, {83, 7}, {88, -3}, {89, -8}, {96, 7}, {105,
>     9}, {113, -8}, {122, -9}, {131, 9}, {132,
>     1}, {134, -9}, {138, -2}};
> f = Interpolation[data3, PeriodicInterpolation -> True];
> 
> << "FourierSeries`"
> 
> s[x_] = N[
>   FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]]
> 
> discr = Interpolation[data3 /. {x_, y_} -> {x, y},
>    InterpolationOrder -> 1];
> 
> g[x_] = Piecewise[{{discr[x], 0 < x < 138}, {0, True}}];
> 
> Show[Plot[s[x], {x, 0, 138}, PlotStyle -> Red,
>   PlotRange -> {-15, 15}], Plot[g[x], {x, 0, 138}, Filling -> Axis],
>  ListPlot[data3, Filling -> Axis, PlotRange -> {0, 138}]]
> 
> tia sal2
> 


  • Prev by Date: Re: Help with find root needed
  • Next by Date: Re: how to determine the center or foci of an ellipse from a slope
  • Previous by thread: Mathematica SIG (Washington DC Area)
  • Next by thread: Re: Interpolation and plot doing strange things with mathematica