# Two-dimensional integral over data

I am trying to calculate the integral of the data. Following this post, I know what to do with a one-dimensional list. But, let's consider a simple function, just to show you, what I want to do.

f[x_, y_]:= x y;


Now, I create a two-dimensional table

L = Table[f[x,y], {x, 0, 5}, {y,0, 5}];


Now on this data, I would like to do the following operation

Integrate[f[x,y,], {x, 0, 5}, {y, 0, 5}]


For one dimension, I would use the Simpson rule from the mentioned post, but is it possible to extend it to calculate the following integral?

Integrate[f[x, y], {x, 0, 5}, {y, 0, 5}](*625/4*)


integration weights

g = Table[1, {x, 0, 5}, {y, 0, 5}];
g[[All, 1]] = g[[1, All ]] = g[[All, 6]] = g[[6, All ]] = 1/2;
g[[1, 1]] = g[[1, 6]] = g[[6, 1]] = g[[6, 6]] = 1/4;


numerical integration

Flatten[g L] // Total (* 625/4 *)

• Thank you very much, can you explain, why you take such weights? Commented Apr 26 at 8:23
• @blahblah Have a look at the grid: Neighborhood of inner points is one, boundary points (except corners) is 1/2 and corners is 1/4. Sum of all weights should be 25 Commented Apr 26 at 9:07
• Ok, I understand, but why the sum should be 25 if the array is 6x6? Commented Apr 26 at 10:57
• Check the neighbourhood of your new gridpoints: innerpoints .1^2,boundary points .1^2/2, corner points .1^2/4 Commented May 28 at 11:19
• Yes , seems to be correct! Commented May 28 at 11:56