Matrix with polynomial entries in Sage.
I am trying to define a function to produce matrices with polynomial entries. I defined the following
def BraidMatrices(i,n,z):
r=identity_matrix(n,n)
r[i,i]=0
r[i,i+1]=1
r[i+1,i]=1
r[i+1,i+1]=z
return r
z=VariableGenerator('z')
n=3
t1=BraidMatrices(1,n,z[1])
t1
But it has some errors: 1099 n = self.pyobject() 1100 except TypeError: -> 1101 raise TypeError("unable to convert %r to an integer" % self) 1102 if isinstance(n, sage.rings.integer.Integer): 1103 return n
TypeError: unable to convert z1 to an integer
How to define a matrix with polynomial entries in Sage? Thank you very much.