1
$\begingroup$

For an multidimensional integration I want to build up the integration limits with the following code. (the length of vars is also variable)

x = 0.223144;
vars = {x1, x2, x3};
Table[{vars[[k]], -x/(1 + i), x/(1 + i)}, {k, 1, 3}, {i, 0, 2}]

which gives me:

{{{x1, -0.223144, 0.223144}, {x1, -0.111572, 0.111572}, {x1, -0.0743812, 0.0743812}}, {{x2, -0.223144,0.223144}, {x2, -0.111572, 0.111572}, {x2, -0.0743812,0.0743812}}, {{x3, -0.223144, 0.223144}, {x3, -0.111572,0.111572}, {x3, -0.0743812, 0.0743812}}}

As I see it, it makes an outer product. But I just want the the following integration variables with the corresponding limits.

{{x1, -0.223144, 0.223144}, {x2, -0.111572, 0.111572},{x3, -0.0743812, 0.0743812}}

How would I achieve that? Thank you

$\endgroup$
1
  • $\begingroup$ Thanks, but I also need to remove the unnecessary sublists of x1,x2,x3. I just want the first sublist for x1, second one for x2,... $\endgroup$
    – rainer
    Commented Feb 12, 2013 at 10:32

1 Answer 1

2
$\begingroup$
x = 0.223144;
vars = {x1, x2, x3};
Table[{vars[[k]], -x/k, x/k}, {k, 1, 3}]
(* {{x1, -0.223144, 0.223144}, {x2, -0.111572,  0.111572}, {x3, -0.0743813, 0.0743813}} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.