I have an array of values $f[x,y]$ which was calculated numerically for "grid" ${x,y}$ and I have steps ${dx,dy}$.
I would like to know how can I perform numerical integration, $$\sum_{i,j}dx_idx_jf(x_i,y_j)$$ with high precision. I use simply
Sum[dx[[i]]*dy[[j]]*f[x[[i]],y[[j]]],{i,Lenth[x]},{j,Length[y]}
I assume that there is a function in Mathematica which does it with higher precision. Or, can anyone suggest where can I found Mathematica realizations of methods of numerical integration (like Simpson's rule, etc.)
{x,y,z}
, where x and y represented points on an irregular mesh, and z - the values in these points. I did it as follows. First, used the 1st order interpolation to get an interpolation function. Second, I integrated it usingNIntegrate
routine, and, by trial and error, selected a suitable numeric strategy. Hope this helps. $\endgroup$array.dy.dx
is a speedier equivalent to yourSum
, assumingarray
is the array of values $f[x_i,y_j]$. YourSum
code suggests you have access tof
, so you could useNIntegrate
on it. WithNIntegrate
, you would probably get a more satisfactory result. If you have access only to the data, then interpolating as @Alexei suggests is a good idea. Most likely one could avoidNIntegrate
and directly apply the rule associated with interpolation, or use FEM to do it. $\endgroup$f[x,y]
. Thank you for advice witharray.dy.dx
. Can I simply use my array as the argument ofNIntegrate
? $\endgroup$NIntegrate
has to be a function. $\endgroup$f
. I have notf
explicitly. $\endgroup$