Extracting one-degree terms from polynomial

18 views
Skip to first unread message

Wbwvwv 2fwcweg

unread,
May 23, 2025, 1:13:09 PMMay 23
to Macaulay2
Dear all,
Good day! I am new to Macaulay2, so I am not quite familiar with all of the stuff around here.
So, the issue is that I have a polynomial with many variables (x_00..x_22,y_00..y_22 to be precise), and I want to kind of sort it out.
I did split all the terms of the polynomial into separate ones and combine them into list, as it is shown in the picture. Now, I want to know how many are there terms that have second degree variable (in the picture, there are 10 of them); also, I want to extract only the "one-degree-variable" terms. I tried to play around with select, but I couldn't make it out. Any help will be appreciated! (just don't know where to start since I am quite new here). Thanks in advance.
Photo.jpg

Michael Burr

unread,
May 23, 2025, 1:37:14 PMMay 23
to Macaulay2
The following code can be used to find the monomials that have some exponent that has degree 2 or all exponents of 1 or 0.  Hopefully, this is what you're looking for (and you can adapt it to your use case).

-- Set up the ring
R = QQ[x,y,z]

-- A list of monomials, similar to the problem
L = {x*y*z^2,x*y*z,x*y,z^2,x^3*y^2}

-- For each monomial in L, first compute the exponents
-- Search the exponents and select all 2's
-- If there is at least one 2 in the list of exponents, then select that element
select(L,i->(E = flatten exponents i;T = select(E,i->i==2);if #T > 0 then true else false))

-- For each monomial in L, first compute the exponents
-- Search the exponents and any instances where the exponent is not 1
-- If there is at least one entry of the exponent that's larger than one, then do not select that element
select(L,i->(E = flatten exponents i;T = select(E,i->i>1);if #T > 0 then false else true))

Lily Silverstein

unread,
May 23, 2025, 2:17:27 PMMay 23
to maca...@googlegroups.com
It could also be helpful to use "any" and "all" here.

select(L, m -> any(flatten exponents m, i -> i==2))

to list the monomials where at least one exponent equals 2

select(L, m -> all(flatten exponents m, i -> i<2))

for the ones where all exponents are 0 or 1

--
You received this message because you are subscribed to the Google Groups "Macaulay2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/macaulay2/def87e6a-dd98-4911-a237-7ca9293e9aacn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages