Ask Your Question
1

Maps of monomials to monomials

asked 4 years ago

whatupmatt gravatar image

Let us assume I have a function F that takes say degree 1 monomials to degree 2 monomials and degree 3 monomials in variable x,y (example: multiplication by x+y2). I have a basis for degree 1 monomials given by x,y; a basis for degree 2 given by x2,xy,y2, and a basis for degree 3 monomials given by x3,x2y,xy2,y3. So if I want to express F as a matrix, I can say g1= F(x), g2=F(y).

Then the first row of my matrix will be coefficient of x2 in g1, coefficient of xy in g1, coefficient of y2 in g1, coefficient of x3 in g1, ...., coefficient of y3 in g1. The second row will just be the same with g1 replaced with g2.

The issue is if I want degree 10 monomials, the writing out each basis element is too much, especially if there were more variables. I was wondering if there was a simpler way in Sage to write this in coding language without writing out each basis element. Suppose I want degree k monomials to degree m and n monomials. Basically, I feel I need some command like the following. I feel there should be a package for this maybe?

  1. Define F. Let B be a k x (m+n) matrix. Take the space of all degree k monomials (maybe ordered lexigraphically?). Apply F to that space. For each element F is applied to, in the image, extract degree m part. Write it out as a vector in the space of degree m monomials. Same for degree n part. Put vector into part of matrix B.
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 4 years ago

vdelecroix gravatar image

updated 4 years ago

Getting the list of monomials are "one-liners". Using the monomial method as in

sage: R.<x,y,z> = QQ[]
sage: R.monomial(1,2,3)
x*y^2*z^3

You can do

sage: degree = 2; [R.monomial(*[x-1 for x in c]) for c in Compositions(3+degree, length=3)]
[x^2, x*y, x*z, y^2, y*z, z^2]
sage: degree = 3; [R.monomial(*[x-1 for x in c]) for c in Compositions(3+degree, length=3)]
[x^3, x^2*y, x^2*z, x*y^2, x*y*z, x*z^2, y^3, y^2*z, y*z^2, z^3]

(note you can also do the more convenient [R.monomial(*c) for c in Compositions(3+degree, length=3, min_part=0)] but you get an annoying warning).

EDIT: It will help you to learn a bit of Python. Given a polynomial, here is how to multiply it by the list of monomials

sage: degree = 2
sage: monomials = [R.monomial(*[x-1 for x in c]) for c in Compositions(3+degree, length=3)]
sage: f = x + y + z
sage: [f * m for m in monomials]
[x^3 + x^2*y + x^2*z, x^2*y + x*y^2 + x*y*z, ..., x*z^2 + y*z^2 + z^3]
Preview: (hide)
link

Comments

How exactly would I multiply a function to every element in the list. Say f(x,y,z)=x+y+z, putting something like f[R.monomial([x-1 for x in c]) for c in Compositions(3+degree, length=3)] or even an element of the list---say 3rd element f[R.monomial([x-1 for x in c]) for c in Compositions(3+degree, length=3)] [3] gives an error saying "unable to convert (x,y,z) |---> x+y+z to an integer."

whatupmatt gravatar imagewhatupmatt ( 4 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 4 years ago

Seen: 487 times

Last updated: Apr 13 '20