Im looking at n particles and functions of their coordinates which I want to integrate over:
{r1, r2,..., rn} = Table[Symbol["r" <> ToString@i], {i, n}] =: LoC[n_]
then I want to define functions e.g.
f[x_] := x
g[L_] := Sum[f[i], {i, L}]
where later I plug in L = LoC[n].
Then I define intervals for integration:
IB[i_] := {Symbol["r" <> ToString@i], x, R} = {r1, x, R}
IIB[n_] := Array[IB, n] = {{r1, x, R},...., {rn, x, R}}
but the integration doesnt work:
NIntegrate[g[LoCC[3]], Row[IIB[3], ","]].
With errors like "NIntegrate::ilim: Invalid integration variable or limit(s) in {r1,1,100}, {r2,1,100}, {r3,1,100}."
What am I doing wrong? I guess the arguments or the integration limits arent defined properly.
n=2 (x=1, R=100):
LoC[2]
IB[2]
IIB[2]
Out[10]= {r1, r2}
Out[11]= {r2, 1, 100}
Out[12]= {{r1, 1, 100}, {r2, 1, 100}}
In[32]:= g[LoC[2]]
Out[32]= r1 + r2
The row command removes one pair of brackets {} because Integrate wants the integration limits like
{r1, 1, 100}, {r2, 1, 100}
In[33]:= Row[IIB[2], ","]
Out[33]= {r1, 1, 100}, {r2, 1, 100}
but then
In[34]:= NIntegrate[g[LoC[2]], Row[IIB[2], ","]]
During evaluation of In[34]:= NIntegrate::ilim: Invalid integration
variable or limit(s) in {r1,1,100},{r2,1,100}.
Out[34]= NIntegrate[g[LoC[2]], Row[IIB[2], ","]]
Row
- that's for presentation. Remove theRow
. $\endgroup$