Can I integrate something that is specified by the values in an array

Dear All,
I would like to integrate something that is the values in an array (y) as a function of a variable that is given by the values in another array x.
Graphically I would just plot y against x and find the area under the graph. Is there a more sophisticated way of doing it using Mathematica?
All help welcome. Thanks.
John Hey

John,

If the values are equally spaced use Total[] to integrate the curve and multiply by the time spacing. If not, you can do the calculation point by point

Regards

Neil

Dear Neil,
You are wonderful. Many thanks.
John

Hi John,

Expanding on Neil’s answer:

For equally spaced points

delta = Pi/50;
data = Table[N@Sin[x], {x, 0, Pi, delta}];
Total[delta*data]
(* 1.99934 *)

For unequally spaced points you can use Interpolation

xVals = Table[x + RandomReal[{-delta, delta}/2], {x, 0, Pi, delta}];
yVals = Sin[xVals];
points = Transpose[{xVals, yVals}];

iFun = Interpolation[points]
Integrate[iFun[x], {x, Min@xVals, Max@xVals}]
(* 1.9995 *)

Dear Rohit,

Thanks. All is clear now.

John