Ask Your Question

doubly indexed variables in a non-commutative ring

asked 2013-02-20 05:44:19 -0500

annab gravatar image

I'm trying to do some basic arithmetic in a non-commutative polynomial ring with variables indexed by two indices i and j (say 1 \le i < j \le 6). Does anyone know how to ask for a doubly indexed variable like this?
Thanks, Anna

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2013-02-20 13:53:32 -0500

benjaminfjones gravatar image

Symbolic variables don't have a notion of index directly, just a name. You can create a list of variables to send to the var() command that have a systematic naming scheme that corresponds to double indexing:

sage: var(','.join(['x_%d%d' % (i,j) for i in [1..6] for j in [1..6]]))
(x_11, x_12, x_13, x_14, x_15, x_16, x_21, x_22, x_23, x_24, x_25, x_26, x_31, x_32, x_33, x_34, x_35, x_36, x_41, x_42, x_43, x_44, x_45, x_46, x_51, x_52, x_53, x_54, x_55, x_56, x_61, x_62, x_63, x_64, x_65, x_66)

... and they even typeset correctly:

sage: latex(x_11)
edit flag offensive delete link more


Ok, so I can make this list of variables, but how do I make it the *non-commuting* variables over ZZ? I thought FreeAlgebra would do this, but it seems to make a FreeAlgebra in the commuting list of variables I give it.

annab gravatar imageannab ( 2013-02-25 09:52:47 -0500 )edit

answered 2013-02-21 04:07:28 -0500

ppurka gravatar image

updated 2013-02-22 06:20:55 -0500

@benjaminfjones: I think what the OP wanted was how to define this in case of PolynomialRing. Something similar to this (obtained from the documentation):

sage: PolynomialRing(GF(7), 'y', 5)
Multivariate Polynomial Ring in y0, y1, y2, y3, y4 over Finite Field of size 7

The answer is a simple modification to what you did, since I don't think two variable indices can be automatically created. But we can just create the same list as you did and provide it as the second argument:

sage: R = PolynomialRing(ZZ, ['x_%d%d' % (i,j) for i in [1..2] for j in [1..2]]); R
Multivariate Polynomial Ring in x_11, x_12, x_21, x_22 over Integer Ring
sage: R.inject_variables()
Defining x_11, x_12, x_21, x_22
sage: x_11*x_12 # Now we can use the variables
edit flag offensive delete link more


Thanks, but this makes a polynomial ring in a commuting list of variables. Do you know a way to make them not commute?

annab gravatar imageannab ( 2013-02-25 09:53:34 -0500 )edit

Then maybe you don't want a polynomial ring. There is a `FreeAlgebra` class, or (from sage-5.7) a `FreeGroup` class which can give you noncommutative variables. sage: G = FreeAlgebra(ZZ, ['x_%d%d'%(i,j) for i in range(2) for j in range(2)]) sage: G Free Algebra on 4 generators (x_00, x_01, x_10, x_11) over Integer Ring sage: G.inject_variables() Defining x_00, x_01, x_10, x_11 sage: x_00 * x_01 == x_01 * x_00 False

ppurka gravatar imageppurka ( 2013-02-25 20:06:08 -0500 )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


Asked: 2013-02-20 05:44:19 -0500

Seen: 328 times

Last updated: Feb 22 '13