I wish to use NIntegrate
to compute multidimensional integrals. However, I don't want to manually input the limits for the dimensions. I want to store the integration limits in a list and have NIntegrate
to run with the limits in that list.
I hope the following example is illustrative:
vars = {x, y, z, u, v};
func = x + y + u + z;
limits = Table[{vars[[i]], -∞, ∞},{i, 1, Length[vars]}]
{{x, -∞, ∞}, {y, -∞, ∞}, {z, ∞, ∞}, {u, -∞, ∞}, {v, -∞, ∞}}
Now I add constraints on the integration variables:
consts =
x >= 0 &&
3152 + 81 y - 4 (788+20 y) >= 0 &&
-3572 + u + 4 v + 16 x - 76 y - 4 (314 + 13 y) + 6 (788 + 20 y)+2 z >= 0 &&
1649 - 4 u - 15 v - 66 x + 28 y + 6 (314 + 13 y) - 4 (788 + 20 y) - 6 z >= 0 &&
788 + 6 u + 20 v + 111 x + 20 y - 4 (314 + 13 y) + 6 z >= 0;
I now try the syntax which seems intuitive to me, for integrating over the limits specified by limits
:
NIntegrate[func Boole[consts], limits]
During evaluation of the above, I get the result:
NIntegrate::vars: Integration range specification limits is not of the form {x, xmin, ..., xmax}. >>
NIntegrate[func Boole[consts], limits]
Could anyone kindly help me find the right syntax to achieve integration over the limits specified in limits
?
Comments
Post a Comment