Can I get some help with this:
P[f_, {x_, xmin_, xmax_}] :=
Block[{ x1 = xmin, x2 = xmax}, f = Sin[2x];
NIntegrate[f[x], {x,x1,x2}]]
Quiet[Table[P[x], {x1, 0.02, 0.06, .01},{x2, 0.02, 0.06, .01}]]
I want to solve the above integral using Block. This is a single integral after knowing the right syntax, I want to generalize the function so that it can evaluate double and triple integrals. Any help please
f = Sin[2x]in theBlock, whenfis already an argument of the functionP? It would make more sense to do:P[f_, {xmin_, xmax_}] := NIntegrate[f[x], {x, xmin, xmax}]; g[x_]:=Sin[2 x]; Quiet[Table[ P[g, {x1, x2}], {x1, 0.02, 0.06, .01}, {x2, 0.02, 0.06, .01}]]– flinty Sep 30 '20 at 15:57NIntegratealready supports higher dimensional integration. For exampleg[x_, y_, z_] := Cos[x*y*z]; NIntegrate[g[x, y, z], {x, y, z} \[Element] Ball[]]so I don't know why you need to generalize it. You should probably have a look at this question: https://mathematica.stackexchange.com/questions/21622/syntax-for-integrating-over-limits-specified-by-a-table?rq=1 – flinty Sep 30 '20 at 16:54