Revision history [back]

Extracting terms of polynomial of certain powers

Let's say I have a polynomial f. I want to extract the monomials where every variable is divisible by a number, say 5. I have two ideas on how to do this.

Method 1:

R.<x,y,z> = QQ[]
f=x^(5)*y^(2)+z^(2)*x^(2)+y^(5)*x^(10)


The end result should give me y^(5)x^(10) as the first term has a power 2 which is not divisible by 5 and obviously the 2nd term is not. I am stuck here as I want to somewhat say the following.

f.exponents()


gives

[(10, 5, 0), (5, 2, 0), (2, 0, 2)]


Then I want to say

f.exponents()[i] % (5,5,5) == (0,0,0) is False, remove the ith term


There are 2 problems with this. The first is when I do f.exponents(), you see the tuples they give me are rearranged so the "ith" term is no longer what I think it is. For example, (10,0,5) is the 3rd term of f, but they put it as the first tuple. The second thing is f.exponents()[i] % (5,5,5) is not valid (i.e. gives error) but hopefully you get what I want. I basically want to divide component-wise and get all remainder 0. What is the correct code for this and the coding language for "remove the ith term"?

Method 2: I can consider f(x^(1/5),y^(1/5),z^(1/5)) and then check whether f.exponents()[i] belongs to Z^(3)-cartesian product of integers. The issue is again I don't know how to code this and f(x^(1/5),y^(1/5),z^(1/5)) gives error as I lie in the polynomial ring. The polynomial ring doesn't allow fractional exponents. I looked online and maybe I am suppose to work with Puiseux polynomials?

https://stackoverflow.com/questions/51077537/what-is-the-best-way-to-implement-polynomials-with-fractional-exponents-with-sag

Extracting terms of polynomial of certain powers

Let's say I have a polynomial f. I want to extract the monomials where every power of variable is divisible by a number, say 5. I have two ideas on how to do this.

Method 1:

R.<x,y,z> = QQ[]
f=x^(5)*y^(2)+z^(2)*x^(2)+y^(5)*x^(10)


The end result should give me y^(5)x^(10) as the first term has a power 2 which is not divisible by 5 and obviously the 2nd term is not. I am stuck here as I want to somewhat say the following.

f.exponents()


gives

[(10, 5, 0), (5, 2, 0), (2, 0, 2)]


Then I want to say

f.exponents()[i] % (5,5,5) == (0,0,0) is False, remove the ith term


There are 2 problems with this. The first is when I do f.exponents(), you see the tuples they give me are rearranged so the "ith" term is no longer what I think it is. For example, (10,0,5) is the 3rd term of f, but they put it as the first tuple. The second thing is f.exponents()[i] % (5,5,5) is not valid (i.e. gives error) but hopefully you get what I want. I basically want to divide component-wise and get all remainder 0. What is the correct code for this and the coding language for "remove the ith term"?

Method 2: I can consider f(x^(1/5),y^(1/5),z^(1/5)) and then check whether f.exponents()[i] belongs to Z^(3)-cartesian product of integers. The issue is again I don't know how to code this and f(x^(1/5),y^(1/5),z^(1/5)) gives error as I lie in the polynomial ring. The polynomial ring doesn't allow fractional exponents. I looked online and maybe I am suppose to work with Puiseux polynomials?

https://stackoverflow.com/questions/51077537/what-is-the-best-way-to-implement-polynomials-with-fractional-exponents-with-sag