Variable Matrices on Sage

asked 2024-02-03 12:34:40 +0200

yeetcode gravatar image

updated 2024-02-03 19:57:17 +0200

I am using Sagemath 10. I wish to work with matrices whose entries are multivariate polynomial ring variables (nothing funky with the base ring, R = PolynomialRing(QQ, 100, 'x'); R.gens() is what I am trying). I create a matrix.zero(n,n) for reasonable n (currently just 3) and then try to alter each entry manually. However, Sage complains that the entries can't be non-constant polynomials.

So I tried to provide the ring above as an argument by writing matrix.zero(R, n,n), but this generated the error

TypeError: unbound method Parent.category() needs an argument

I have also tried using M=MatrixSpace(R,n,n); M(L) where L is a list of appropriate design. It still complains about getting non-constant polynomial entries.

How do I circumvent this issue? I only plan to analyse the determinant of a specific kind of matrix. Based on this information, feel free to offer alternatives with more restricted functionality than just a matrix. Thank you!

edit retag flag offensive close merge delete

Comments

like this

sage: R = PolynomialRing(QQ, 'x', 2)
sage: matrix(R, 5, 5)
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
FrédéricC gravatar imageFrédéricC ( 2024-02-03 14:06:40 +0200 )edit

@FrédéricC : could you resend your comment as an answer (possibly with amplification/explanations ? This would be useful for the edification of future generations of this site users ;-)...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-02-03 14:19:14 +0200 )edit

Before that, I must remark that it didn't resolve the issue. It complains about getting too many arguments. Which makes sense, because as far as I recall, matrix() takes in a list of lists and returns the corresponding matrix.

yeetcode gravatar imageyeetcode ( 2024-02-03 19:47:33 +0200 )edit

You say "it complains". What command yields the complaint? The comment from @FrédéricC was intended (I believe) to address your first question: how to create a zero matrix that can be modified one entry at a time.

John Palmieri gravatar imageJohn Palmieri ( 2024-02-03 21:42:43 +0200 )edit

Okay, I am not sure what happened. The command matrix(R,n,n) seemed to be yielding this error. But when I ran the notebook today, stuff seems to be fine. As of this moment, I am unable to recover the original code I wrote which was causing issues. There is a small chance I just did not run the appropriate cells. Apologies.

yeetcode gravatar imageyeetcode ( 2024-02-04 07:59:01 +0200 )edit