30.2 Free algebra elements

Module: sage.algebras.free_algebra_element

Free algebra elements

Author: David Kohel, 2005-09

TESTS:

sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: x == loads(dumps(x))
True
sage: x*y
x*y
sage: (x*y)^0
1
sage: (x*y)^3
x*y*x*y*x*y

Class: FreeAlgebraElement

class FreeAlgebraElement
A free algebra element.
FreeAlgebraElement( self, A, x)

Create the element x of the FreeAlgebra A.

Special Functions: __call__,$ \,$ __cmp__,$ \,$ __init__,$ \,$ _add_,$ \,$ _latex_,$ \,$ _mul_,$ \,$ _neg_,$ \,$ _repr_,$ \,$ _sub_

__call__( self)

sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
sage: (x+3*y).subs(x=1,y=2,z=14)
7
sage: (2*x+y).subs({x:1,y:z})
2 + z
sage: f=x+3*y+z
sage: f(1,2,1/2)
15/2
sage: f(1,2)
Traceback (most recent call last):
...
ValueError: must specify as many values as generators in parent

Author: Joel B. Mohler (2007.10.27)

__cmp__( left, right)

Compare two free algebra elements with the same parents.

The ordering is the one on the underlying sorted list of (monomial,coefficients) pairs.

sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: x < y
True
sage: x * y < y * x
True
sage: y * x < x * y
False

_add_( self, y)

Return sum of self and y (another free algebra element with the same parents)

sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: x + y
x + y

_latex_( self)

Return latex representation of self.

sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
sage: latex(-x+3*y^20*z)
\left(-1\right)x + 3y^{20}z
sage: alpha,beta,gamma=FreeAlgebra(ZZ,3,'alpha,beta,gamma').gens()
sage: latex(alpha-beta)
\alpha + \left(-1\right)\beta

_mul_( self, y)

Return product of self and y (another free algebra element with the same parents)

sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
sage: (x+y+x*y)*(x+y+1)
x + y + x^2 + 2*x*y + y*x + y^2 + x*y*x + x*y^2

_neg_( self)

Return negation of self

sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: -(x+y)
-x - y

_repr_( self)

Return string representation of self.

sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
sage: repr(-x+3*y*z)
'-x + 3*y*z'

_sub_( self, y)

Return self minus y (another free algebra element with the same parents)

sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: x - y
x - y

See About this document... for information on suggesting changes.