Is there a way to get the homogeneous part of certain degree of a (multivariate) polynomial?
Every multivariate polynomial f∈F[x1,…,xn] of degree d can be written as f=f0+f1+⋯+fd, where fi is a homogeneous polynomial of degree i. Is there a direct way to get each fi given f in SageMath? For a specific application I have where I only need fd I am homogenizing and then setting h=0, and based on this I wrote an ugly script that recursively finds fi.
Is there a cleaner (and more efficient) way to do this?
Thanks for the help!
EDIT:
This is the code I'm using to obtain fd from f
fd = R( f.homogenize()(h=0) )
where R is the multivariate polynomial ring (parent of f). If I want fd−1 for example, I can define g as f−fd and apply the line to g. This recursive definition is not satisfactory since to get fi I need to have all fi+1,…,fd first, which is inefficient. Also, that trick of homogenizing, evaluating h=0 and coercing the result back to the original polynomial ring is not very neat.
Hint: if you provide your code, the collective wisdom of Ask Sage answerers may help improve it!
@slelievre Ok! I'm new in this forum, thanks for pointing that out! I've edited my answer, hopefully that helps :)