Ask Your Question
1

Maps of monomials to monomials

asked 2020-04-12 16:55:35 +0100

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+y^{2}$). I have a basis for degree 1 monomials given by x,y; a basis for degree 2 given by $x^{2},xy,y^{2}$, and a basis for degree 3 monomials given by $x^{3},x^{2}y,xy^{2},y^{3}$. 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 $x^{2}$ in g1, coefficient of $xy$ in g1, coefficient of $y^{2}$ in g1, coefficient of $x^{3}$ in g1, ...., coefficient of $y^{3}$ 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.
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-04-12 20:39:06 +0100

vdelecroix gravatar image

updated 2020-04-13 14:28:40 +0100

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]
edit flag offensive delete link more

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 ( 2020-04-12 22:41:49 +0100 )edit

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: 2020-04-12 16:55:35 +0100

Seen: 464 times

Last updated: Apr 13 '20