Ask Your Question
0

way to subs var by matrix in polynomial

asked 2021-06-22 08:34:49 +0200

ortollj gravatar image

HI

What is the best way to substitute to the variables of a polynomial x, y with 2 matrices X, Y

R.<x,y> = QQ[]
p = x^2 + 5*y + 2*x*y + 3*x + y^2
show("p : ",p," \t degre : \t",p.degree(x))
for ex in range(1,p.degree(x)+1) :
    coefx=p.coefficient(x^ex)
    print(" ex : ",ex," \t coefx : ",coefx)
for ey in range(1,p.degree(x)+1) :
    coefy=p.coefficient(y^ey)
    print(" ey : ",ey," \t coefy : ",coefy)
#for ey in range(1,p.degree(y)+1) :
#    coefy=p.coefficient(y^ex)
#    for ex in range(0,coefy.degree(y)+1) :
#        coefx=p.coefficient(x^ex)
#        print(" ex : ",ex," \t coefx : ",coefx," \t ey : ",ey," \t coefy : ",coefy)

var('x_00,x_01,x_10,x_11',domain='integer')
var('y_00,y_01,y_10,y_11',domain='integer')
X=matrix(SR,[[x_00,x_01],[x_10,x_11]]); Y=matrix(SR,[[y_00,y_01],[y_10,y_11]])
show(X,Y)
#p.subs([x==X,y==Y])
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-06-22 09:34:23 +0200

tmonteil gravatar image

You can use one of the following:

sage: p.subs({x:X,y:Y})

sage: p.subs(x=X,y=Y)

The first passes a dictionary to the subs method, the second sets two arguments.

When you write p.subs([x==X,y==Y]), you try to pass a list of booleans to the subs method.

edit flag offensive delete link more

Comments

Thank you @tmonteil

ortollj gravatar imageortollj ( 2021-06-22 09:49:06 +0200 )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-06-22 08:34:49 +0200

Seen: 92 times

Last updated: Jun 22 '21