Ask Your Question

mpzajac's profile - activity

2020-05-02 09:03:02 +0200 commented answer Polynomials with multiple variables and abstract coefficients

Thanks, that helped, sorry for a delayed reply!

2020-05-02 09:02:44 +0200 received badge  Scholar (source)
2020-01-19 10:29:52 +0200 received badge  Famous Question (source)
2018-06-28 09:11:32 +0200 received badge  Notable Question (source)
2018-02-06 08:00:47 +0200 received badge  Popular Question (source)
2016-09-15 22:51:43 +0200 received badge  Student (source)
2016-09-15 16:11:04 +0200 asked a question Polynomials with multiple variables and abstract coefficients

Hey there,

I need to create a polynomials (say P1, P2) that will have a number of variables (ca. 5) and abstract coefficients (ca. 9) (but I can assume that coefficients are variables carrying integer values). Then I would like to multiply P1, P2 and collect variables and extract coefficients standing next to them, e.g

from XA * XB + XA^2 + 2 * A * XA + 4*XB / XC + 5 I should be able to get 2*A*XA + XA^2 + XA*XB + 4*XB/XC + 5 and from this a list of coefficients like [2A, 1, 1, 4, 5] (with zeros in proper places eg. coefficient for XAXBXC)

Browsing the net I have found sth like: B.<x,y,z> = QQ[]; A.<x,y,z>=B[]; ex = (1-a^2)*x*y^2+(a-b^2+c)*x*y*z+(b^2-c^2-a)*x^2*z; ex.coefficients(); ex.monomials()

And my questions are: (1.) how can I pass a list of variables to define a ring, I am interested in sth like B.list = QQ[]; A.list2 = B[] (2.) As you run the code above you can easily note that the output is: [-x*y^2, x^2*z - x*y*z, -x^2*z, -x^2*z + x*y*z, x*y*z, x*y^2]; [a^2, b^2, c^2, a, c, 1] As you can see the list from ex.coefficients() contains multiply entries for xy^2 and -xy^2 separately. And this is no go. Any ideas how can I fix it?

Thanks for any suggestions! Bests Michal