Group Abstract Group Abstract

Message Boards Message Boards

Application of integration to a continuous list (xi,yi) of numbers; see nb.

Attachments:
4 Replies

Decided to try an experiment

In[1]:= f[x_] = Sin[x]*Sin[3 x];

In[10]:= NIntegrate[f[x], {x, 0, 10}]

Out[10]= 0.135097

In[12]:= pts = Sort[RandomReal[{0, 10}, 100]];

In[14]:= data = Table[{pts[[i]], f[pts[[i]]]}, {i, 100}];

In[21]:= i[n_] := Interpolation[data, InterpolationOrder -> n]

In[24]:= Off[InterpolatingFunction::dmvali]

In[25]:= Table[Integrate[i[n][x], {x, 0, 10}], {n, 0, 3}]

Out[25]= {0.154373, 0.0429017, 0.163184, 0.181286}
POSTED BY: Frank Kampas
Posted 10 years ago

Hi Luke, As Sean points out, integrating an interpolating function for experimental data is questionable. There is the issue of what the interpolation has done between the data points. One way to restrict this is to use InterpolationOrder->1 in the function to cause NIntegrate to be getting something close to a trapezoidal rule. But questions still remain. One way to eliminate all questions is to just execute a known rule. For example, the user-defined function below performs numerical integration by the trapezoidal rule. It assumes the data is a list of x-y pairs, and is sorted by increasing x values. But that's all. There is no question about added information.

Best regards, David

trapezoidal[list_] := Total@Table[
   (list[[n, 1]] - 
      list[[n - 1, 1]]) (list[[n - 1, 2]] + list[[n, 2]])/2,
   {n, 2, Length[list]}
   ]
POSTED BY: David Keith
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard