MathGroup Archive 2008

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

Search the Archive

Re: Numerical integration and list of points

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87638] Re: Numerical integration and list of points
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 15 Apr 2008 05:46:48 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <ftvd4f$d89$1@smc.vnet.net>

guerom00 wrote:

  > I have a function which I read as a list of points. I want then to
> estimate its integral. I do more or less this :
> 
> data={{x1,y1},{x2,y2},...,{xN,yN}}
> f=Interpolation[data]
> NIntegrate[f[x],{x,x1,xN}]
> 
> Is it the correct way ? Because Mathematica hangs without giving me an
> answer although it seems a pretty straightforward thing to do...

Well, the method is correct, but its implementation must be faulty in 
some way since Mathematica hangs. Without an actual sample of the code 
and data you are using, it is indeed hard to tell where the error is 
located. For instance, the following works like a charm on my system 
(and should on your system too)


     data = RandomReal[{0, 10}, {10, 2}]
     f = Interpolation[data]
     f // FullForm
     f[[1, 1]]
     f[2.5]
     Plot[f[x], {x, f[[1, 1, 1]], f[[1, 1, 2]]}]
     Show[%, ListPlot[data]]
     Integrate[f[x], {x, f[[1, 1, 1]], f[[1, 1, 2]]}]
     NIntegrate[f[x], {x, f[[1, 1, 1]], f[[1, 1, 2]]}]


Regards,
-- Jean-Marc


  • Prev by Date: Re: Player Pro and Packages
  • Next by Date: Re: Player Pro and Packages
  • Previous by thread: Re: Numerical integration and list of points
  • Next by thread: Re: Numerical integration and list of points