Ask Your Question

Tilpo's profile - activity

2023-04-21 03:14:15 +0200 received badge  Notable Question (source)
2023-02-17 19:02:07 +0200 received badge  Nice Question (source)
2023-02-17 19:02:04 +0200 received badge  Nice Answer (source)
2022-10-12 04:24:32 +0200 received badge  Popular Question (source)
2022-07-12 14:18:14 +0200 asked a question Manipulating matrices in Cython

Manipulating matrices in Cython I need to do low-level arithmetic with (dense, integer) matrices in Cython. Right now I

2019-09-09 20:13:30 +0200 commented answer Run sage notebook without sage.all imported

That makes sense, thanks for clearing that up.

2019-09-09 15:55:59 +0200 commented answer Run sage notebook without sage.all imported

But my point is that I don't want to use from sage.all import *. I only need a couple libraries. If I try to import a sage library from a Python 2 kernel, I either get an ImportError or the kernel crashes. Is it really only possible to import the entire sage library or nothing at all?

2019-09-09 12:25:11 +0200 asked a question Run sage notebook without sage.all imported

When I create a create a sage Jupyter notebook the kernel seems to always run from sage.all import *. This can be useful since you don't have to worry about importing all the things you need. However I find it has two big disadvantages:

  • The sage kernel takes a while to start (roughly one minute for me)
  • It causes naming conflicts when we define a function or class that already has a meaning somewhere in the huge sage library.

Therefore I wonder if it is possible to run a notebook with a sage kernel without importing the entire sage library.

2019-07-24 13:56:31 +0200 received badge  Supporter (source)
2019-05-16 15:59:12 +0200 received badge  Self-Learner (source)
2019-05-16 15:59:12 +0200 received badge  Teacher (source)
2019-05-16 15:41:08 +0200 answered a question Coercion from PBW to universal enveloping algebra

One can use the .to_word_list() method on a monomial in PBW basis.

E.g.

sage: PBW[-alpha[1]-alpha[2]]*PBW[-alpha[1]].to_word_list()
>>>>  [-alpha[1]-alpha[2],-alpha[1]]

The resulting list of roots are keys in the basis of the original Lie algebra, and can hence be easily converted. This solves my problem.

2019-05-11 08:41:30 +0200 received badge  Student (source)
2019-05-10 18:49:40 +0200 asked a question Coercion from PBW to universal enveloping algebra

I'm using sage.algebras.lie_algebras.poincare_birkhoff_witt to do computations in the universal enveloping algebras of some Lie algebras. I want to then use the resulting elements in the PBW basis to act on (a subalgebra) of the Lie algebra. For this I need to use the Lie algebra's bracket() method, which only works with elements of the Lie algebra. Hence I need to coerce elements of PBW back into (NC polynomials of) elements of the Lie algebra. How do I do this?

Example

sage: lie_algebra = LieAlgebra(QQ, cartan_type='A4')
sage: pbw_basis = lie_algebra.pbw_basis()
sage: pbw_basis.an_element()
>>> PBW[alpha[4]]^2*PBW[alpha[3]]^2*PBW[alpha[2]]^3 + 2*PBW[alpha[4]] + 3*PBW[alpha[3]] + 1

Then I want to obtain

>>> E[alpha[4]]^2*E[alpha[3]]^2*E[alpha[2]]^3 + 2*E[alpha[4]] + 3*E[alpha[3]] + 1

Or rather it's enough if I can convert a term like PBW[alpha[4]] to E[alpha[4]], because I want to essentially use the following function

def universal_enveloping_algebra_action(pbw_elt,e):
    result=0
    for term,coefficient in pbw_elt:
            sub_result=e
            for factor,power in term:
                for _ in range(power):
                    sub_result=lie_algebra.bracket(factor,sub_result)
            result+=sub_result
    return result

Here pbw_elt is an element of the PBW basis, and e is in the Lie algebra. In this case 'factor' needs to be coerced into an element of the Lie algebra.

Right now I solved the problem by making a dictionary converting algebra generators of pbw_basis into basis elements of the Lie algebra, but it feels like there should be a much more elegant solution.