Consider some toy-function which I then interpolate:
Function1[x_, y_] = If[4<x^3 + y^4 - x^2 < 5, Exp[-x^2 + y^2], 0];
DataInt =
Flatten[ParallelTable[{x, y, Function1[x, y]}, {x, 0, 100,
0.05}, {y, 0, 100, 0.05}], {2, 1}];
FunctionInt[x_, y_] =
Interpolation[DataInt, InterpolationOrder -> 1][x, y];
Note that there is a lot of points in which the interpolated function is zero. I want then to integrate this function:
NIntegrate[FunctionInt[x, y], {x, 0, 100}, {y, 0, 100}]
The integral gives zero due to the fact that the domain in which FunctionInt is non-zero is very narrow. An brute-force way to improve this is to increase the integration accuracy. However, it may be more useful to define somehow the domain in which the function is non-zero, i.e. to get a function y = y[x] which defines this region.
Is it possible to do having the data?
SparseArray[Head[FunctionInt[x, y]]["ValuesOnGrid"]]["NonzeroValues"] // Total[#] 0.05^2 &
-- tends to overestimate the trapezoidal rule on a nonnegative function. $\endgroup$4<x^3 + y^4 - x^2 < 5
for your actual use case? Do you know the formula for the data being interpolated such asExp[-x^2 + y^2]
? $\endgroup$