Ask Your Question

Revision history [back]

There is indeed something wrong with how the Symbolic Ring deals with integer modulo 9.

What is even more weird is that i found some non-determinism, since i once get the following result (on Sage 6.8.beta5):

sage: var('A,B,C,D')
(A, B, C, D)
sage: Sigma=matrix(SR,2,[[1+3*A,3*B],[3*C,1+3*D]])
sage: garbage=matrix(SR,2,[[2,1],[2,6]]);garbageinverse=matrix(SR,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[  36*A + 42*B + 18*C + 21*D + 19    48*A + 12*B + 24*C + 6*D + 18]
[36*A + 42*B + 108*C + 126*D + 54  48*A + 12*B + 144*C + 36*D + 28]
36*A + 42*B + 108*C + 126*D + 54
sage: R=Integers(9)
sage: garbage=matrix(R,2,[[2,1],[2,6]]);garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[        6*B + 3*D + 1 3*A + 3*B + 6*C + 6*D]
[            0*A + 6*B         3*A + 3*B + 1]
6*B + 0*D

That said, for such algebraic questions, i would recommend to work on well defined rings:

sage: R.<a,b,c,d> = PolynomialRing(Integers(9),4)
sage: R
Multivariate Polynomial Ring in a, b, c, d over Ring of integers modulo 9
sage: Sigma = matrix(R,2,[[1+3*a,3*b],[3*c,1+3*d]])
sage: garbage = matrix(R,2,[[2,1],[2,6]])
sage: garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: garbage*Sigma*garbageinverse
[        6*b + 3*d + 1 3*a + 3*b + 6*c + 6*d]
[                  6*b         3*a + 3*b + 1]
sage: (Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
6*b

There is indeed something wrong with how the Symbolic Ring deals with integer modulo 9.9. Thanks for pointing this issue.

What is even more weird is that i found some non-determinism, since i once get the following result (on Sage 6.8.beta5):

sage: var('A,B,C,D')
(A, B, C, D)
sage: Sigma=matrix(SR,2,[[1+3*A,3*B],[3*C,1+3*D]])
sage: garbage=matrix(SR,2,[[2,1],[2,6]]);garbageinverse=matrix(SR,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[  36*A + 42*B + 18*C + 21*D + 19    48*A + 12*B + 24*C + 6*D + 18]
[36*A + 42*B + 108*C + 126*D + 54  48*A + 12*B + 144*C + 36*D + 28]
36*A + 42*B + 108*C + 126*D + 54
sage: R=Integers(9)
sage: garbage=matrix(R,2,[[2,1],[2,6]]);garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[        6*B + 3*D + 1 3*A + 3*B + 6*C + 6*D]
[            0*A + 6*B         3*A + 3*B + 1]
6*B + 0*D

That said, for such algebraic questions, i would recommend to work on well defined rings:

sage: R.<a,b,c,d> = PolynomialRing(Integers(9),4)
sage: R
Multivariate Polynomial Ring in a, b, c, d over Ring of integers modulo 9
sage: Sigma = matrix(R,2,[[1+3*a,3*b],[3*c,1+3*d]])
sage: garbage = matrix(R,2,[[2,1],[2,6]])
sage: garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: garbage*Sigma*garbageinverse
[        6*b + 3*d + 1 3*a + 3*b + 6*c + 6*d]
[                  6*b         3*a + 3*b + 1]
sage: (Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
6*b

There is indeed something wrong with how the Symbolic Ring deals with integer modulo 9. Thanks for pointing this issue.

What is even more weird is that i found some non-determinism, since i once get the following result without being able to reproduce (on Sage 6.8.beta5):

sage: var('A,B,C,D')
(A, B, C, D)
sage: Sigma=matrix(SR,2,[[1+3*A,3*B],[3*C,1+3*D]])
sage: garbage=matrix(SR,2,[[2,1],[2,6]]);garbageinverse=matrix(SR,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[  36*A + 42*B + 18*C + 21*D + 19    48*A + 12*B + 24*C + 6*D + 18]
[36*A + 42*B + 108*C + 126*D + 54  48*A + 12*B + 144*C + 36*D + 28]
36*A + 42*B + 108*C + 126*D + 54
sage: R=Integers(9)
sage: garbage=matrix(R,2,[[2,1],[2,6]]);garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[        6*B + 3*D + 1 3*A + 3*B + 6*C + 6*D]
[            0*A + 6*B         3*A + 3*B + 1]
6*B + 0*D

That said, for such algebraic questions, i would recommend to work on well defined rings:

sage: R.<a,b,c,d> = PolynomialRing(Integers(9),4)
sage: R
Multivariate Polynomial Ring in a, b, c, d over Ring of integers modulo 9
sage: Sigma = matrix(R,2,[[1+3*a,3*b],[3*c,1+3*d]])
sage: garbage = matrix(R,2,[[2,1],[2,6]])
sage: garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: garbage*Sigma*garbageinverse
[        6*b + 3*d + 1 3*a + 3*b + 6*c + 6*d]
[                  6*b         3*a + 3*b + 1]
sage: (Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
6*b

There is indeed something wrong with how the Symbolic Ring deals with integer modulo 9. Thanks for pointing this issue.issue, i opened trac ticket 18787.

What is even more weird is that i found some non-determinism, since i once get the following result without being able to reproduce (on Sage 6.8.beta5):

sage: var('A,B,C,D')
(A, B, C, D)
sage: Sigma=matrix(SR,2,[[1+3*A,3*B],[3*C,1+3*D]])
sage: garbage=matrix(SR,2,[[2,1],[2,6]]);garbageinverse=matrix(SR,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[  36*A + 42*B + 18*C + 21*D + 19    48*A + 12*B + 24*C + 6*D + 18]
[36*A + 42*B + 108*C + 126*D + 54  48*A + 12*B + 144*C + 36*D + 28]
36*A + 42*B + 108*C + 126*D + 54
sage: R=Integers(9)
sage: garbage=matrix(R,2,[[2,1],[2,6]]);garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[        6*B + 3*D + 1 3*A + 3*B + 6*C + 6*D]
[            0*A + 6*B         3*A + 3*B + 1]
6*B + 0*D

That said, for such algebraic questions, i would recommend to work on well defined rings:

sage: R.<a,b,c,d> = PolynomialRing(Integers(9),4)
sage: R
Multivariate Polynomial Ring in a, b, c, d over Ring of integers modulo 9
sage: Sigma = matrix(R,2,[[1+3*a,3*b],[3*c,1+3*d]])
sage: garbage = matrix(R,2,[[2,1],[2,6]])
sage: garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: garbage*Sigma*garbageinverse
[        6*b + 3*d + 1 3*a + 3*b + 6*c + 6*d]
[                  6*b         3*a + 3*b + 1]
sage: (Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
6*b

There is indeed something wrong with how the Symbolic Ring deals with integer modulo 9. Thanks for pointing this issue, i opened trac ticket 18787.

Here is the actual issue:

sage: _ = var('A,B')
sage: (A + 3*B)*Zmod(9)(6)
0*B

while the result should be 6*A.

What is even more weird is that i found some non-determinism, since i once get the following result without being able to reproduce (on Sage 6.8.beta5):

sage: var('A,B,C,D')
(A, B, C, D)
sage: Sigma=matrix(SR,2,[[1+3*A,3*B],[3*C,1+3*D]])
sage: garbage=matrix(SR,2,[[2,1],[2,6]]);garbageinverse=matrix(SR,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[  36*A + 42*B + 18*C + 21*D + 19    48*A + 12*B + 24*C + 6*D + 18]
[36*A + 42*B + 108*C + 126*D + 54  48*A + 12*B + 144*C + 36*D + 28]
36*A + 42*B + 108*C + 126*D + 54
sage: R=Integers(9)
sage: garbage=matrix(R,2,[[2,1],[2,6]]);garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[        6*B + 3*D + 1 3*A + 3*B + 6*C + 6*D]
[            0*A + 6*B         3*A + 3*B + 1]
6*B + 0*D

That said, for such algebraic questions, i would recommend to work on well defined rings:

sage: R.<a,b,c,d> = PolynomialRing(Integers(9),4)
sage: R
Multivariate Polynomial Ring in a, b, c, d over Ring of integers modulo 9
sage: Sigma = matrix(R,2,[[1+3*a,3*b],[3*c,1+3*d]])
sage: garbage = matrix(R,2,[[2,1],[2,6]])
sage: garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: garbage*Sigma*garbageinverse
[        6*b + 3*d + 1 3*a + 3*b + 6*c + 6*d]
[                  6*b         3*a + 3*b + 1]
sage: (Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
6*b

There is indeed something wrong with how the Symbolic Ring deals with integer modulo 9. 9.

Here is the actual issue:

sage: _ = var('A,B')
sage: (A + 3*B)*Zmod(9)(6)
0*B

while the result should be 6*A. Thanks for pointing this issue, i opened trac ticket 18787.

Here is the actual issue:

sage: _ = var('A,B')
sage: (A + 3*B)*Zmod(9)(6)
0*B

while the result should be 6*A.

What is even more weird is that i found some non-determinism, since i once get the following result without being able to reproduce (on Sage 6.8.beta5):

sage: var('A,B,C,D')
(A, B, C, D)
sage: Sigma=matrix(SR,2,[[1+3*A,3*B],[3*C,1+3*D]])
sage: garbage=matrix(SR,2,[[2,1],[2,6]]);garbageinverse=matrix(SR,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[  36*A + 42*B + 18*C + 21*D + 19    48*A + 12*B + 24*C + 6*D + 18]
[36*A + 42*B + 108*C + 126*D + 54  48*A + 12*B + 144*C + 36*D + 28]
36*A + 42*B + 108*C + 126*D + 54
sage: R=Integers(9)
sage: garbage=matrix(R,2,[[2,1],[2,6]]);garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: expand(garbage*Sigma*garbageinverse);(Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
[        6*B + 3*D + 1 3*A + 3*B + 6*C + 6*D]
[            0*A + 6*B         3*A + 3*B + 1]
6*B + 0*D

That said, for such algebraic questions, i would recommend to work on well defined rings:

sage: R.<a,b,c,d> = PolynomialRing(Integers(9),4)
sage: R
Multivariate Polynomial Ring in a, b, c, d over Ring of integers modulo 9
sage: Sigma = matrix(R,2,[[1+3*a,3*b],[3*c,1+3*d]])
sage: garbage = matrix(R,2,[[2,1],[2,6]])
sage: garbageinverse=matrix(R,2,[[6,8],[7,2]])
sage: garbage*Sigma*garbageinverse
[        6*b + 3*d + 1 3*a + 3*b + 6*c + 6*d]
[                  6*b         3*a + 3*b + 1]
sage: (Sigma*garbageinverse)[0,0]*garbage[1,0]+(Sigma*garbageinverse)[1,0]*garbage[1,1]
6*b