AUTHORS:
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
A free algebra element.
EXAMPLES:
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)
...
ValueError: must specify as many values as generators in parent
AUTHORS:
Compare two free algebra elements with the same parents.
The ordering is the one on the underlying sorted list of (monomial,coefficients) pairs.
EXAMPLES:
sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: x < y
True
sage: x * y < y * x
True
sage: y * x < x * y
False
Return sum of self and y (another free algebra element with the same parents)
EXAMPLES:
sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: x + y
x + y
Return latex representation of self.
EXAMPLES:
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
Return product of self and y (another free algebra element with the same parents)
EXAMPLES:
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
Return negation of self
EXAMPLES:
sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: -(x+y)
-x - y
Return string representation of self.
EXAMPLES:
sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
sage: repr(-x+3*y*z)
'-x + 3*y*z'
Return self minus y (another free algebra element with the same parents)
EXAMPLES:
sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: x - y
x - y