Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
    
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,... –  rainer Feb 12 '13 at 10:32
add comment

1 Answer 1

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}} *)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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