Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

constructing a matrix from lists

Our goal is to build the $6\times 6$ matrix whose rows are the coefficients of monomials ${z^2,xy,y^2,y^3,y^4,y^5}$ of the six polynomials $g_{(0, 0, 0)},g_{(0, 0, 1)},g_{(0, 0, 2)},g_{(0, 0, 3)},g_{(0, 0, 4)},g_{(0, 0, 5)}\in\mathbb{Z}[x,y,z]$ such that $g_{k,i,j}=x^iy^j f^k$ where $f=x+y+z$. My attempt in sage is to create a list $L$ defining the monomials and computing the six as rows lists as follows.

R.<x,y,z>=ZZ['x, y, z']
f=x+y+z
L=[(2, 0, 0),(0, 1, 1),(0, 0, 2),(0, 0, 3),(0, 0, 4),(0, 0, 5)]
for (k,i,j) in L:
               g=x^i*y^j*f^k
               L1=[g[x^i*y^j*z^k] for (k,i,j) in L]
               print(L1)

A naive solution, since sage outputs 6 rows $L1,L2,L3,L4,L5,L6$, the resulting matrix is

matrix([L1,L2,L3,L4,L5,L6])

But in practice I manipulate with more 100 polynomials, so I want to get a solution which outputs directly the matrix.

constructing a matrix from lists

Our goal is to build the $6\times 6$ matrix whose rows are the coefficients of monomials ${z^2,xy,y^2,y^3,y^4,y^5}$ of the six polynomials $g_{(0, 0, 0)},g_{(0, 0, 1)},g_{(0, 0, 2)},g_{(0, 0, 3)},g_{(0, 0, 4)},g_{(0, 0, 5)}\in\mathbb{Z}[x,y,z]$ such that $g_{k,i,j}=x^iy^j f^k$ where $f=x+y+z$. My attempt in sage is to create a list $L$ defining the monomials and computing the six as rows lists as follows.

R.<x,y,z>=ZZ['x, y, z']
f=x+y+z
L=[(2, 0, 0),(0, 1, 1),(0, 0, 2),(0, 0, 3),(0, 0, 4),(0, 0, 5)]
for (k,i,j) in L:
               g=x^i*y^j*f^k
               L1=[g[x^i*y^j*z^k] for (k,i,j) in L]
               print(L1)

A naive solution, since sage outputs 6 rows $L1,L2,L3,L4,L5,L6$, the resulting matrix is

matrix([L1,L2,L3,L4,L5,L6])

But in practice I manipulate with more than 100 polynomials, so I want to get a solution which outputs directly the matrix.