Ask Your Question
0

Matrix with polynomial entries in Sage.

asked 2021-11-11 17:09:18 +0100

lijr07 gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2021-11-11 17:59:18 +0100

FrédéricC gravatar image

nihao

like that

sage: A = QQ['x']
sage: x = A.gen()
sage: m = matrix(A, 2, 2)
sage: m[1, 1] = x
sage: m
[0 0]
[0 x]
edit flag offensive delete link more

Comments

@FrédéricC, thank you very much!

lijr07 gravatar imagelijr07 ( 2021-11-11 18:35:20 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-11-11 17:09:18 +0100

Seen: 534 times

Last updated: Nov 11 '21