MathGroup Archive 2001

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

Search the Archive

Re: NIntegrate problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27822] Re: NIntegrate problem
  • From: "Paul Lutus" <nospam at nosite.com>
  • Date: Mon, 19 Mar 2001 01:29:13 -0500 (EST)
  • References: <98vh78$8t6@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Martin Richter" <mrMICE.fi at cbs.dk> wrote in message
news:98vh78$8t6 at smc.vnet.net...
> Hi
>
> I'm trying to integrate a simple function, defined as follows:
>
> SeasonTab = {{0/12, -0.5}, {1/12, -.2}, {2/12, -0.5}, {3/12, -0.5}, {4/12,
>         0. - .25}, {5/12, 0.1}, {6/12, 0.5}, {7/12, 0.7}, {8/12,
>         1.1}, {9/12, -0.3}, {10/12, -0.7}, {11/12, -0.6}, {12/12, -0.5}};
> SeasonFunction =
>     Interpolation[SeasonTab, PeriodicInterpolation -> True,
>       InterpolationOrder -> 3];
> NIntegrate[SeasonFunction[t]*Cos[2*Pi*t], {t, 0, 1}]
>
> I think I have tried every setting in NIntegrate.
>
> The function SeasonFunction[t]*Cos[2*Pi*t] is of course not C\infinity but
> it should not give any problems. So at the moment I'm just ignoring
> the error message but if anyone could tell what this the problem is it
would
> be great.

After my last post on this issue, I realized I had overlooked something.
What is being modeled is (presumably) a periodic function, therefore the
resulting function should also be periodic.

So, instead of using "Interpolation[]," IMHO you should be using "Fit[]"
with trigonometric terms, like this:

f[x_] = Fit[st,Table[Cos[2 Pi i x],{i,0,6,1/2}],x]

Where "st" is your data table.

This fit function *matches* the original data points --

x     data[x]  f[x/12]
---------------------
0.    -0.5    -0.5
1.    -0.2    -0.2
2.    -0.5    -0.5
3.    -0.5    -0.5
4.    -0.25   -0.25
5.    0.1     0.1
6.    0.5     0.5
7.    0.7     0.7
8.    1.1     1.1
9.    -0.3    -0.3
10.   -0.7    -0.7
11.   -0.6    -0.6
12.   -0.5    -0.5

-- but, unlike the data table, it is continuous and cyclical. And, unlike
with the interpolation approach, this function can be trivially integrated:

Integrate[f[x] * Cos[2 Pi x],{x,0,1}]//Chop

-0.28422

You should definitely take this next step also, just to see the degree to
which the trig-series function matches the original data:

a = ListPlot[st,DisplayFunction->Identity];

b = Plot[f[x],{x,0,1},DisplayFunction->Identity];

Show[a,b,DisplayFunction->$DisplayFunction]

--
Paul Lutus
www.arachnoid.com





  • Prev by Date: Re: Simple question about plot
  • Next by Date: Re: How write output to another notebook?
  • Previous by thread: Re: simulating limited precision
  • Next by thread: Re: NIntegrate problem