I am trying to compute symbolically a n-fold integral (n is a parameter of a function) over, say, the cube [0,a]^n. My code looks like this
intCube[n_, a_] := Module[{xvars, range, expression},
xvars = Table[Symbol["x" <> ToString[i]], {i, 1, n}];
range = Table[{xvars[[i]], 0, a}, {i, 1, n}];
range = Row[Riffle[range, ","]];
Print[range];
expression = Product[xvars[[i]], {i, 1, n}];
Print[expression];
Integrate[expression, range]
];
The range and the expression to integrate look both ok, however, I get an awkward result. Any ideas why ?
intCube[2, a]
{x1,0,a},{x2,0,a}
x1 x2
x1 x2 Row[{{x1, 0, a}, ",", {x2, 0, a}}]
Thanks,
Ion
Rowis for formatting (display) only. Bine ai venit pe Mathematica.SE! – Szabolcs Mar 14 '12 at 21:59