Hi Rajeev,

On 24 Mai, 06:35, Rajeev Singh <[email protected]> wrote:
> sage: R.<a,b> = FreeAlgebra(QQ, 2)
> sage: a*(a+b)
> a^2 + a*b
>
> Is there a simple way to get a*a instead of a^2 ?

I don't know if this can be done without patching the _repr_ method of
free monoid elements.

However, you said that you want that print representation in order to
parse strings. But then, it might be easier to express the free
algebra elements as lists:

sage: R.<a,b> = FreeAlgebra(QQ, 2)
sage: p = a*(a+2*b)
sage: list(p)
[(2, a*b), (1, a^2)]
sage: L = list(p)
sage: [(c,list(m)) for c,m in L]
[(2, [(a, 1), (b, 1)]), (1, [(a, 2)])]

I guess parsing these lists is as easy as parsing strings.

Cheers,
Simon

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to