1
$\begingroup$
\[GothicCapitalR] = {{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{0, 1, 
 0}, {0, 0, 1}, {1, 0, 0}}, {{0, 0, 1}, {1, 0, 0}, {0, 1, 
 0}}, {{1, 0, 0}, {0, 0, 1}, {0, 1, 0}}, {{0, 0, 1}, {0, 1, 
 0}, {1, 0, 0}}, {{0, 1, 0}, {1, 0, 0}, {0, 0, 1}}};
i = 1;
j = 1;
det = 1;
a = Subsets[Range[6], {3}];
v = {x, y, z};
k = \[GothicCapitalR].v;
r = k[[a[[i]]]];
Det[r];
While[i < 21,
 r = k[[a[[i]]]];
 det = Factor[Det[r]];
 Print[det]; i++]


-(x+y+z) (x^2-x y+y^2-x z-y z+z^2)
(x-y) (y-z) (x+y+z)
-(x-z) (y-z) (x+y+z)
-(x-y) (x-z) (x+y+z)
(x-z) (y-z) (x+y+z)
(x-y) (x-z) (x+y+z)
-(x-y) (y-z) (x+y+z)
-(x-z) (y-z) (x+y+z)
-(x-y) (y-z) (x+y+z)
-(x-y) (x-z) (x+y+z)
-(x-y) (x-z) (x+y+z)
(x-y) (y-z) (x+y+z)
-(x-z) (y-z) (x+y+z)
(x-y) (y-z) (x+y+z)
(x-y) (x-z) (x+y+z)
-(x-z) (y-z) (x+y+z)
-(x-y) (x-z) (x+y+z)
(x-z) (y-z) (x+y+z)
(x-y) (y-z) (x+y+z)
-(x+y+z) (x^2-x y+y^2-x z-y z+z^2)  

Anyone have any suggestions on how to get the output of this loop to be a list of polynomials so that I can use the PolynomialLCM function on it? I will be adapting this loop to larger dimensions and will need to be able to have Mathematica perform this calculation for me.

$\endgroup$
1
  • $\begingroup$ Do you mean so it isn't a string? $\endgroup$
    – Feyre
    Jul 6, 2015 at 15:53

3 Answers 3

4
$\begingroup$

Instead of While[i<21,...], use Table[...,{i,20}]. The ... part can be reduced to

r = k[[a[[i]]]];
Factor[Det[r]]

To find the PolynomialLCM, simply replace the head ( List) of the table with PolynomialLCM using Apply, or @@ for short:

PolynomialLCM @@ Table[...,{i,20}]
$\endgroup$
2
  • 1
    $\begingroup$ This is indeed a much tighter means to create the same list, Is there a way to get the LCM of this output without selecting them manually? $\endgroup$ Jul 6, 2015 at 17:40
  • $\begingroup$ Yes, see my edited post. You should probably read the doc's on Apply, Map and Table, as these are some of the cornerstones in Mathematica ;) $\endgroup$ Jul 6, 2015 at 18:45
2
$\begingroup$

Replace the Print[det] in the print with:

Paste[det]
$\endgroup$
1
$\begingroup$
\[GothicCapitalR] = {{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{0, 1, 
 0}, {0, 0, 1}, {1, 0, 0}}, {{0, 0, 1}, {1, 0, 0}, {0, 1, 
 0}}, {{1, 0, 0}, {0, 0, 1}, {0, 1, 0}}, {{0, 0, 1}, {0, 1, 
 0}, {1, 0, 0}}, {{0, 1, 0}, {1, 0, 0}, {0, 0, 1}}};
i = 1;
j = 1;
det = 1;
a = Subsets[Range[6], {3}];
v = {x, y, z};
k = \[GothicCapitalR].v;
PolynomialLCM @@ Table[Factor[Det[k[[a[[i]]]]]], {i, 1, 20}]
$\endgroup$

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