Ask Your Question

Tilpo's profile - activity

2019-09-09 13:13:30 -0600 commented answer Run sage notebook without sage.all imported

That makes sense, thanks for clearing that up.

2019-09-09 08:55:59 -0600 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 05:25:11 -0600 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 06:56:31 -0600 received badge  Supporter (source)
2019-05-16 08:59:12 -0600 received badge  Self-Learner (source)
2019-05-16 08:59:12 -0600 received badge  Teacher (source)
2019-05-16 08:41:08 -0600 answered a question Coercion from PBW to universal enveloping algebra

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


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 01:41:30 -0600 received badge  Student (source)
2019-05-10 11:49:40 -0600 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?


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):
    for term,coefficient in pbw_elt:
            for factor,power in term:
                for _ in range(power):
    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.