I try to apply nested integration to lists of functions. The code works fine for a single function (not a list), but returns error when trying to calculate the same expression with a list of functions.
A function f[x,args...]
is simplified preliminary by defining argument x
(let say X={1,2,3,4}
) and I obtain a list of functions for given x
's. Next step, I define integral functions f2[args...]
and f3[args...]
and try to compute a nested integration with the list, desiring to obtain a list of result for all x
's. May it be done without use of 'Indexed' or calling a part of the function list in general f[[i]]
? I would like to send a list into Nintegrates
and obtain list of outputs.
Currently my solution is the following, but I like to avoid use of indexes:
ListExpressions = {x + y + z, 2 x + y + z, 3 x + y + z, 4 x + y + z, 5 x + y + z};
f[x_?NumericQ, y_?NumericQ, z_?NumericQ, KK_?NumericQ] := Evaluate[Indexed[ListExpressions, KK]]
f2[K1_?NumericQ, y_?NumericQ, z_?NumericQ, KK_?NumericQ] := NIntegrate[f[x, y, z, KK], {x, 0, K1}];
f3[K1_?NumericQ, K2_?NumericQ, K3_?NumericQ, KK_?NumericQ] := NIntegrate[f2[K1, y, z, KK], {y, 0, K2}, {z, 0, K3}];
f3[1,1,10,#]&/@Range[5]
Out= {60.,65.,70.,75.,80.}