On Thursday, July 31, 2014 8:09:04 PM UTC-7, Stephen Kauffman wrote:
>
> # examples
> cliff_elt = g3*g2*g1*g0
> [ST.free_algebra()(str(cliff_elt)).coefficient(mon) for mon in 
> ST.monomial_basis()]       # st_elt.coefficients() results in error since 
> it has no such attribute
>

ST is constructed to be a finite dimensional QQ-vector space, so getting 
the coefficients is a matter of viewing the element as a vector over QQ. So 
this works:

sage:  zip(cliff_elt.vector(),ST.monomial_basis())

Here too: if you find yourself having to use going through string 
representations you're doing something wrong. If the system forces you to, 
then there's an essential access/coercion feature missing, which should be 
fixed. Unless you're trying to do something that's really odd to begin 
with, but your questions are entirely reasonable.

There's some awkwardness in reconstructing the element from this info:

sage: sum( c*m for c,m in zip(cliff_elt.vector(),ST.monomial_basis()))
TypeError: unsupported operand parent(s) for '*': 'Rational Field' and 
'Free monoid on 4 generators (g0, g1, g2, g3)'

Scalar multiplication isn't defined on the monoid. That's only defined for 
the module spanned by the monoid. So one would have to do one of

sage: sum( c*PRGA(m) for c,m in zip(cliff_elt.vector(),ST.monomial_basis()))
-4*g0*g1 + 4*g1*g2 - 2*g1*g3 + g0*g1*g2*g3
sage: sum( c*ST(m) for c,m in zip(cliff_elt.vector(),ST.monomial_basis()))
-4*g0*g1 + 4*g1*g2 - 2*g1*g3 + g0*g1*g2*g3

It wouldn't be unreasonable to have the first form available as 
cliff_elt.lift(). The second one just reconstructs the original element. 
Whether, the "common parent discovery" of the coercion system should be 
made aware of monoids and construct modules on monoids when encountering a 
scalar multiplication might be problematic (at first blush it seems like 
the right kind of construction *if any* is required, but it may have a few 
too many unintended consequences). Anyway, the error message is pretty 
clear.

cliff_vect = 5*g0+7*g1-2*g2+6*g3/7
> # to get the inner product back in the base ring, can't divide say 
> g3/(g3*g3) even though g3*g3 scalar ostensibly in base field but not...
>

Well, in my case g3*g3 happens to be 0 so you cannot divide by it, even 
though it is a "scalar". In general, the constructor for a 
FreeAlgebraQuotient doesn't require you to make "1" one of the basis 
vectors, so even though for you it's clear it lies "in the base field", 
sage doesn't know how the base field is embedded in this algebra (if at 
all) and hence has no easy way of answering this question for you. 
Therefore, "converting back" into the base field is probably never going to 
happen (semi) automatically for this kind of algebra.

For the free algebra it should be able to do this, however, because there 
"1" is guaranteed to be there and is recognizable.

sage: QQ(PRGA.0^0)
TypeError: Unable to coerce 1 (<class 
'sage.algebras.free_algebra_element.FreeAlgebra_generic_with_category.element_class'>)
 
to Rational

 That one could be fixed.

There is some extra machinery that would be nice to have. For instance, it 
would be nice if cliff_elt.matrix() were to return:

 M=matrix([(b*cliff_elt).vector() for b in ST.monomial_basis()])

then one could see what the characteristic polynomial of an element is and 
hence determine if an element is invertible:

F=M.characteristic_polynomial()
x=F.parent().0
cliff_elt_inv=(((F-F.constant_coefficient()) // x )/ 
F.constant_coefficient())(cliff_elt)

Having "char_poly", "min_poly", "inverse()" or "is_invertible()" methods on 
these finite dimensional free algebra quotient elements would be a 
reasonable thing to have.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to