ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 27 Feb 2020 21:56:23 +010020 monomials of degree 3 in 4 variables in lexicographic orderinghttps://ask.sagemath.org/question/50082/20-monomials-of-degree-3-in-4-variables-in-lexicographic-ordering/ Hey community,
I've recently wanted to switch over to sage (very new) from Maple and I am having trouble understanding how to make monomials of degree 3 in 4 variables (hopefully in lexographic ordering think of the w coordinate as one). I am not very good at english, but this is for a Clebsch map up and down for a surface that I am studying.
These are the maps:
m1:=p-->p[1]^3;
m2:=p-->p[1]^2*p;
m3:=p-->p[1]^2*p[3];
m4:=p-->p[1]^2;
m5:=p-->p[1]*p[2]^2;
m6:=p-->p[1]*p[2]*p[3];
m7:=p-->p[1]*p[2];
m8:=p-->p[1]*p[3]^2;
m9:=p-->p[1]*p[3];
m10:=p-->p[1];
m11:=p-->p[2]^3;
m12:=p-->p[2]^2*p[3];
m13:=p-->p[2]^2;
m14:=p-->p[2]*p[3]^2;
m15:=p-->p[2]*p[3];
m16:=p-->p[2];
m17:=p-->p[3]^3;
m18:=p-->p[3]^2;
m19:=p-->p[3];
m20:=p-->1;
Then M:=[m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,m16,m17,m18,m19,m20]Wed, 26 Feb 2020 22:41:38 +0100https://ask.sagemath.org/question/50082/20-monomials-of-degree-3-in-4-variables-in-lexicographic-ordering/Answer by nbruin for <p>Hey community,
I've recently wanted to switch over to sage (very new) from Maple and I am having trouble understanding how to make monomials of degree 3 in 4 variables (hopefully in lexographic ordering think of the w coordinate as one). I am not very good at english, but this is for a Clebsch map up and down for a surface that I am studying. </p>
<p>These are the maps: <br>
m1:=p-->p[1]^3; <br>
m2:=p-->p[1]^2<em>p; <br>
m3:=p-->p[1]^2</em>p[3]; <br>
m4:=p-->p[1]^2; <br>
m5:=p-->p[1]<em>p[2]^2; <br>
m6:=p-->p[1]</em>p[2]<em>p[3]; <br>
m7:=p-->p[1]</em>p[2]; <br>
m8:=p-->p[1]<em>p[3]^2; <br>
m9:=p-->p[1]</em>p[3]; <br>
m10:=p-->p[1]; <br>
m11:=p-->p[2]^3; <br>
m12:=p-->p[2]^2<em>p[3]; <br>
m13:=p-->p[2]^2; <br>
m14:=p-->p[2]</em>p[3]^2; <br>
m15:=p-->p[2]*p[3]; <br>
m16:=p-->p[2];
m17:=p-->p[3]^3; <br>
m18:=p-->p[3]^2; <br>
m19:=p-->p[3]; <br>
m20:=p-->1; <br>
Then M:=[m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,m16,m17,m18,m19,m20]</p>
https://ask.sagemath.org/question/50082/20-monomials-of-degree-3-in-4-variables-in-lexicographic-ordering/?answer=50092#post-id-50092A function to get a list of monomials of specified degree would be good to have in sage. Perhaps it is already by now. Otherwise it's not hard to define once you know which primitives to use:
def monomials_of_degree(P,n):
V=[P({tuple(a):1}) for a in WeightedIntegerVectors(n,[1]*P.ngens())]
return V
With this you can do:
m=monomials_of_degree(PolynomialRing(QQ,'P',4),3)
R=PolynomialRing(QQ,'p',3)
M=[h(R.gens()+(1,)) for h in m]Thu, 27 Feb 2020 18:11:53 +0100https://ask.sagemath.org/question/50082/20-monomials-of-degree-3-in-4-variables-in-lexicographic-ordering/?answer=50092#post-id-50092Comment by bllooi for <p>A function to get a list of monomials of specified degree would be good to have in sage. Perhaps it is already by now. Otherwise it's not hard to define once you know which primitives to use: </p>
<pre><code>def monomials_of_degree(P,n):
V=[P({tuple(a):1}) for a in WeightedIntegerVectors(n,[1]*P.ngens())]
return V
</code></pre>
<p>With this you can do:</p>
<pre><code>m=monomials_of_degree(PolynomialRing(QQ,'P',4),3)
R=PolynomialRing(QQ,'p',3)
M=[h(R.gens()+(1,)) for h in m]
</code></pre>
https://ask.sagemath.org/question/50082/20-monomials-of-degree-3-in-4-variables-in-lexicographic-ordering/?comment=50096#post-id-50096Lovely, thank you so much for the help!Thu, 27 Feb 2020 21:56:23 +0100https://ask.sagemath.org/question/50082/20-monomials-of-degree-3-in-4-variables-in-lexicographic-ordering/?comment=50096#post-id-50096