Re: Numerical integration and list of points
- To: mathgroup at smc.vnet.net
- Subject: [mg87672] Re: Numerical integration and list of points
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Tue, 15 Apr 2008 05:53:19 -0400 (EDT)
On 4/14/08 at 6:53 AM, guerom00 at gmail.com (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... What you've outlined above should work. Since it doesn't work for you there must be something else impacting the computation you aren't showing us. For example, I just did the following with no problems: In[9]:= data = Sort[Transpose@{#, Sin[#]} &@RandomReal[{0, \[Pi]}, {50}]]; f = Interpolation[data]; NIntegrate[f[x], {x, 0, \[Pi]}] Out[11]= 2.