Applying a function to a product in a free algebra.

27 views
Skip to first unread message

broken_symlink

unread,
Jul 1, 2013, 10:08:40 AM7/1/13
to sage-s...@googlegroups.com
If I have a free algebra over Z generated by x and y and I write x*y is there a way to know that x*y is a product of the generators x and y? I would like to write a function that takes x*y to -2*x -2*y - 4. 

Maarten Derickx

unread,
Jul 1, 2013, 2:40:19 PM7/1/13
to sage-s...@googlegroups.com
What do you exactly want? There are multiple functions that take x*y to -2*x-2*y-4 so it might be good to give a description of the whole function to make this question easier to answer. One way to do what you ask is as follows, but I'm not sure wether this is what you want!

F.<x,y>=FreeAlgebra(ZZ,2)
g=x*y
g.substitute(x=-2,y=x+y+2)

broken_symlink

unread,
Jul 1, 2013, 5:03:44 PM7/1/13
to sage-s...@googlegroups.com
That doesn't seem it would work in general unless I already knew g was x*y.

What I really have is a free algebra with generators as0, as1, as2, a1s, a11, a12, a2s, a21, a22, b11, b12, b21, b22, c11, c12, c21, c22, d11, d12, d21, d22, e11, e22 and function that returns a matrix like this,

[2*a21 - a21*a12*a21         1 - a21*a12] 
[       -1 + a12*a21                            a12]

I would like to be able to go through the matrix and replace products aij*akl with -2*aij -2akl -4. So, for example, 1 - a21*a12 should become 5 + 2*a21 + 2*a12. I guess in order to be able to do that I need to be able index elements. So, if e = 1 - a21*a12 then e[0] would be 1, e[1] would be -a21*a12 and then e[1][0] would be -a21 and e[1][1] would be a12. 

Finally, the bij generators are of degree 1 and the aij generators are of degree 0, so I have a differential from b to a. For example, assuming I can do the above, the differential for b21 would be -6 + -2*a12 -*a21. I would like to build another matrix with bij's labeled as rows and 1 and aij labeled as columns so the row b21 would have a -6 in the first column, -2 in the a12 column and -1 in the a21 column. Then row reduce that matrix to get homology. I guess again though in order to be able to do this I need to be able to index algebra elements. 

Would it be possible to implement something like this by subclassing FreeAlgebraElement or something else? 

Maarten Derickx

unread,
Jul 1, 2013, 5:45:12 PM7/1/13
to sage-s...@googlegroups.com
Ok, I think the best way to do what you want is to toy around with the intrinsics of sage. All the data is already there, but not yet accessible in a user friendly way (i.e. everything is in _ methods that you don't see with tab completion). Below an example that shows you how to acces all the information you need:

F.<x,y>=FreeAlgebra(ZZ,2)
g=4+3*x^7*y^10*x^13
h=g._FreeAlgebraElement__monomial_coefficients
print h
print h.items()
print h.items()[1][0]._element_list

It should not be a lot of work to write useful functions that return exactly the information you want. You could indeed add the functions you want by subclassing sage.algebras.free_algebra_element.FreeAlgebraElement . There is one problem however, namely that you would also need to subclass a lot of other sage intrinsics in order for this to work seemlessly. I.e. you would also need to subclass sage.algebras.free_algebra.FreeAlgebra_generic and modify its element constructor so that it will use your new subclass instead of sage.algebras.free_algebra_element.FreeAlgebraElement . What is easier is instead to directly modify the sage source code and add this functionality directly to sage.algebras.free_algebra_element.FreeAlgebraElement (i.e. not subclassing). If you need help with this I can explain you how. If you create some usefull acces functions, then you can also create a patch so it can be included in sage so that others can also use your functions.

By the way, do you really need to work in a non commutative ring? I.e. will x*y mean something else for your computations then y*x? If there is no difference then I would advise you to work with F.<x,y>=PolynomialRing(ZZ,2) since there is a lot more functionality available for polyonmial rings then there is for free algebra's.




2013/7/1 broken_symlink <syam...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "sage-support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-support/okj9hs9cAAU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

broken_symlink

unread,
Jul 2, 2013, 12:32:06 AM7/2/13
to sage-s...@googlegroups.com
Thanks! That was what I was looking for. For right now, we want to work over a non-commutative ring. Someone is currently looking into abelianizing. 
Reply all
Reply to author
Forward
0 new messages