Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
sage: Z = matrix(2,2)
sage: print Z.parent()

Full MatrixSpace of 2 by 2 dense matrices over Integer Ring

What you want is a matrix over the Symbolic Ring

sage: Z = matrix(SR,2,2)
sage: print Z.parent()
sage: Z[0,0] = sqrt(5)
sage: print Z

Alternatively a matrix over a Real Field

sage: Z = matrix(RR,2,2)
sage: print Z.parent()
sage: Z[0,0] = sqrt(5)
sage: print Z
sage: Z = matrix(2,2)
sage: print Z.parent()

Output:

Full MatrixSpace of 2 by 2 dense matrices over Integer Ring

Ring

That means your matrix can contain only Integers. What you want is a matrix over the Symbolic Ring Ring:

sage: Z = matrix(SR,2,2)
sage: print Z.parent()
sage: Z[0,0] = sqrt(5)
sage: print Z

Alternatively a matrix over a Real FieldField:

sage: Z = matrix(RR,2,2)
sage: print Z.parent()
sage: Z[0,0] = sqrt(5)
sage: print Z