Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

First, x=F.gen() defines x as the generating polynomial variable of the ring F. That is, any linear combinations of nonnegative powers of x will define a polynomial from F. Alternatively, you can define x and F via F.<x> = PolynomialRing(GF(3)) or F.<x> = GF(3)[], or just x via x = polygen(GF(3)).

Second, var('d1,d2,d3') defines d1, d2, d3 as generic symbolic variables. It may be not a good idea to simultaneously work with polynomial and symbolic variables unless there is a clear need to do so. Your equations are polynomial in nature and so it's better to stick with variables over S:

K.<d1,d2,d3,r1,r2,r3> = S[]

Third, your equations are quadratic over $d_i,r_i$, thus you cannot solve them using linear algebra. The (lhs of) equations can be obtained via:

eq = ( matrix([[d1, -1, 0], [-1, d2, -1], [0, -1, d3]]) * vector([r1,r2,r3]) ).list()
print(eq)

which gives [d1*r1 - r2, d2*r2 - r1 - r3, d3*r3 - r2]. All possible solutions form the variety of the ideal:

J = K.ideal( eq )

which gives Ideal (d1*r1 - r2, d2*r2 - r1 - r3, d3*r3 - r2) of Multivariate Polynomial Ring in d1, d2, d3, r1, r2, r3 over Univariate Quotient Polynomial Ring in a over Finite Field of size 3 with modulus x^2. For 0-dimensional ideals over fields, one can get all elements of the variety by calling J.variety().


Unfortunately, you cannot do much with ideals over non-field rings (which is S), but in the case of small underlying ring you can gen all solutions simply by bruteforce. Here is a complete code:

F = PolynomialRing(GF(3),'x'); x = F.gen() S = F.quotient(x^2,'a'); a = S.gen()

for d1,d2,d3,r1,r2,r3 in Tuples(S,6):
    r = vector([r1,r2,r3])
    if r!=0 and matrix([[d1, -1, 0], [-1, d2, -1], [0, -1, d3]]) * r == 0:
        print([d1,d2,d3],[r1,r2,r3])

which will prints all 756 solutions with nonzero vector (r1,r2,r3).

First, x=F.gen() defines x as the generating polynomial variable of the ring F. That is, any linear combinations of nonnegative powers of x will define a polynomial from F. Alternatively, you can define x and F via F.<x> = PolynomialRing(GF(3)) or F.<x> = GF(3)[], or just x via x = polygen(GF(3)).

Second, var('d1,d2,d3') defines d1, d2, d3 as generic symbolic variables. It may be not a good idea to simultaneously work with polynomial and symbolic variables unless there is a clear need to do so. Your equations are polynomial in nature and so it's better to stick with variables over S:

K.<d1,d2,d3,r1,r2,r3> = S[]

Third, your equations are quadratic over $d_i,r_i$, thus you cannot solve them using linear algebra. The (lhs of) equations can be obtained via:

eq = ( matrix([[d1, -1, 0], [-1, d2, -1], [0, -1, d3]]) * vector([r1,r2,r3]) ).list()
print(eq)

which gives [d1*r1 - r2, d2*r2 - r1 - r3, d3*r3 - r2]. All possible solutions form the variety of the ideal:

J = K.ideal( eq )

which gives Ideal (d1*r1 - r2, d2*r2 - r1 - r3, d3*r3 - r2) of Multivariate Polynomial Ring in d1, d2, d3, r1, r2, r3 over Univariate Quotient Polynomial Ring in a over Finite Field of size 3 with modulus x^2. For 0-dimensional ideals over fields, one can get all elements of the variety by calling J.variety().


Unfortunately, you cannot do much with ideals over non-field rings (which is S), but in the case of small underlying ring you can gen get all the solutions simply by using bruteforce. Here is a complete code:

F = PolynomialRing(GF(3),'x'); x = F.gen() S = F.quotient(x^2,'a'); a = S.gen()

for d1,d2,d3,r1,r2,r3 in Tuples(S,6):
    r = vector([r1,r2,r3])
    if r!=0 and matrix([[d1, -1, 0], [-1, d2, -1], [0, -1, d3]]) * r == 0:
        print([d1,d2,d3],[r1,r2,r3])

which will prints all 756 solutions with nonzero vector (r1,r2,r3).

First, x=F.gen() defines x as the generating polynomial variable of the ring F. That is, any linear combinations of nonnegative powers of x will define a polynomial from F. Alternatively, you can define x and F via F.<x> = PolynomialRing(GF(3)) or F.<x> = GF(3)[], or just x via x = polygen(GF(3)).

Second, var('d1,d2,d3') defines d1, d2, d3 as generic symbolic variables. It may be not a good idea to simultaneously work with polynomial and symbolic variables unless there is a clear need to do so. Your equations are polynomial in nature and so it's better to stick with variables over S:

K.<d1,d2,d3,r1,r2,r3> = S[]

Third, your equations are quadratic over $d_i,r_i$, thus you cannot solve them using linear algebra. The (lhs of) equations can be obtained via:

eq = ( matrix([[d1, -1, 0], [-1, d2, -1], [0, -1, d3]]) * vector([r1,r2,r3]) ).list()
print(eq)

which gives [d1*r1 - r2, d2*r2 - r1 - r3, d3*r3 - r2]. All possible solutions form the variety of the ideal:

J = K.ideal( eq )

which gives Ideal (d1*r1 - r2, d2*r2 - r1 - r3, d3*r3 - r2) of Multivariate Polynomial Ring in d1, d2, d3, r1, r2, r3 over Univariate Quotient Polynomial Ring in a over Finite Field of size 3 with modulus x^2. For 0-dimensional ideals over fields, one can get all elements of the variety by calling J.variety().


Unfortunately, you cannot do much with ideals over non-field rings (which is S), but in the case of small underlying ring you can get all the solutions using bruteforce. Here is a complete code:

F = PolynomialRing(GF(3),'x'); x = F.gen()
S = F.quotient(x^2,'a'); a = S.gen()

S.gen()

for d1,d2,d3,r1,r2,r3 in Tuples(S,6):
    r = vector([r1,r2,r3])
    if r!=0 and matrix([[d1, -1, 0], [-1, d2, -1], [0, -1, d3]]) * r == 0:
        print([d1,d2,d3],[r1,r2,r3])

which will prints all 756 solutions with nonzero vector (r1,r2,r3).