smita
smita

Reputation: 123

How to write arrays in sagemath which stores polynomials?

My problem is to calculate the S-polynomials of 8 polynomials given to me. Sage already has an inbuilt function (called spol) which calculates the S-polynomial of the different polynomials which goes like this:

from sage.rings.polynomial.toy_buchberger import spol
R.<y_1, y_2, y_3, y_4, x_1, x_2, x_3, x_4> = PolynomialRing(QQ, order='lex')
g = spol(-y_2*x_1 + y_2*x_4 - y_3*x_1^2 + y_3*x_4^2 - y_4*x_1^3 + y_4*x_4^3,
         -y_2*x_2 + y_2*x_4 - y_3*x_2^2 + y_3*x_4^2 - y_4*x_2^3 + y_4*x_4^3)

If I take 2 polynomials from the given 8 polynomials and calculate the S-polynomials manually there will be 32 possible combinations.

Is there a better way to approach the problem?

So I want to

create an array which stores the 8 polynomials and create a for loop which would take the polynomials from the array and calculate their S-polynomial and then it would give me my list.

I am not well-versed in coding (I am from the mathematics background). I really need some help.

Upvotes: 1

Views: 354

Answers (1)

Cryptolis
Cryptolis

Reputation: 94

It could be something like this:

from sage.rings.polynomial.toy_buchberger import spol
R.<y_1, y_2, y_3, y_4, x_1, x_2, x_3, x_4> = PolynomialRing(QQ, order='lex')
polinoms = [p1, p2, p3, p4, p5, p6, p7, p8] #add the polynoms
spols = [] #the S-polynomials

for i in polinoms:
  for j in polinoms:
    if i != j:
      spols.append(spol(i, j))

This will give you a list of 56 items, but you mentioned 32, so please comment here what other combinations should be excluded too.

Upvotes: 2

Related Questions