I know that I can do, say, a triple integral such as ∫bxax∫byay∫bzazf(x,y,z)dzdydx
with the input
Integrate[f[x,y,z],{x,ax,bx},{y,ay,by},{z,az,bz}]
.Now, however, I would like to do a multiple integral of the form ∫b1a1⋯∫bnanf(x1,…,xn)dxn…dx1
for some n that I specify. Is there a concise functional way to input this into Mathematica, or is the only way to manually type the full
Integrate[f[x1,...,xn],{x1,a1,b1},...,{xn,an,bn}]
. command?Answer
Here is another way:
multi[f_, x_, a_, b_, n_] :=
Inactive@Integrate @@ {f @@ Array[x[#] &, {n}]}~Join~Array[{x[#], a[#], b[#]} &, {n}]
I used Inactive because I don't know if the purpose is purely typesetting, or if you want it to try to evaluate (if so remove it, or use Activate later).
multi[g, y, ymin, ymax, 10]
(* Inactive[Integrate][
g[y[1], y[2], y[3], y[4], y[5], y[6], y[7], y[8], y[9],
y[10]], {y[1], ymin[1], ymax[1]}, {y[2], ymin[2], ymax[2]}, {y[3],
ymin[3], ymax[3]}, {y[4], ymin[4], ymax[4]}, {y[5], ymin[5],
ymax[5]}, {y[6], ymin[6], ymax[6]}, {y[7], ymin[7], ymax[7]}, {y[8],
ymin[8], ymax[8]}, {y[9], ymin[9], ymax[9]}, {y[10], ymin[10],
ymax[10]}] *)
perhaps a screenshot here is better:
If its just for typesetting then you can swap subscripts into it as follows:
Comments
Post a Comment