The usual unary and binary ring operations are available for noncommutative polynomials, noting that multiplication is associative but noncommutative, of course.
The functions in this subsection allow one to access noncommutative polynomials.
Given a noncommutative polynomial f with coefficients in R, this function returns a sequence of `base' coefficients, that is, a sequence of elements of R occurring as coefficients of the monomials in f. Note that the monomials are ordered, and that the sequence of coefficients corresponds exactly to the sequence of monomials returned by Monomials(f).
Given a noncommutative polynomial f with coefficients in R, this function returns the leading coefficient of f as an element of R; this is the coefficient of the leading monomial of f, that is, the first among the monomials occurring in f with respect to the ordering of monomials used in F.
Given a noncommutative polynomial f with coefficients in R, this function returns the trailing coefficient of f as an element of R; this is the coefficient of the trailing monomial of f, that is, the last among the monomials occurring in f with respect to the ordering of monomials used in F.
Given a noncommutative polynomial f and a monomial m, this function returns the coefficient with which m occurs in f as an element of R.
Given a noncommutative polynomial f∈F, this function returns a sequence of the monomials (monoid words) occurring in f. Note that the monomials in F are ordered, and that the sequence of monomials corresponds exactly to the sequence of coefficients returned by Coefficients(f).
Given a noncommutative polynomial f∈F this function returns the leading monomial of f, that is, the first monomial element of F that occurs in f, with respect to the ordering of monomials used in F.
Given a noncommutative polynomial f∈F, this function returns the sequence of (non-zero) terms of f as elements of F. The terms are ordered according to the ordering on the monomials in F. Consequently the i-th element of this sequence of terms will be equal to the product of the i-th element of the sequence of coefficients and the i-th element of the sequence of monomials.
Given a noncommutative polynomial f∈F, this function returns the leading term of f as an element of F; this is the product of the leading monomial and the leading coefficient that is, the first among the monomial terms occurring in f with respect to the ordering of monomials used in F.
Given a noncommutative polynomial f∈F, this function returns the trailing term of f as an element of F; this is the last among the monomial terms occurring in f with respect to the ordering of monomials used in F.
Given a noncommutative monomial (word) m, return the length of m, i.e., the number of letters of m. Note that this differs from the commutative case, where the number of terms in a polynomial is returned.
Given a noncommutative monomial (word) m of length l, and an integer i with 1≤i≤l, return the i-th letter of m.
Given a noncommutative polynomial f, this function returns the total degree of f, which is the maximum of the lengths of all monomials that occur in f. If f is the zero polynomial, the return value is -1.
Given a noncommutative polynomial, this function returns the leading total degree of f, which is the length of the leading monomial of f.
> K := RationalField(); > F<x,y,z> := FreeAlgebra(K, 3); > f := (3*x*y - 2*y*z)*(4*x - 7*z*y) + 23*x*y*z; > f; -21*x*y*z*y + 14*y*z^2*y + 12*x*y*x + 23*x*y*z - 8*y*z*x > TotalDegree(f); 4 > Coefficients(f); [ -21, 14, 12, 23, -8 ] > Monomials(f); [ x*y*z*y, y*z^2*y, x*y*x, x*y*z, y*z*x ] > Terms(f); [ -21*x*y*z*y, 14*y*z^2*y, 12*x*y*x, 23*x*y*z, -8*y*z*x ] > MonomialCoefficient(f, x*y*z); 23 > LeadingTerm(f); -21*x*y*z*y > LeadingCoefficient(f); -21 > m := Monomials(f)[1]; > m; x*y*z*y > Length(m); 4 > m[1]; x > m[2]; y
Given an element f of a free algebra F=R< x1, ..., xn > and a sequence or tuple s of ring or algebra elements of length n, return the value of f at s, that is, the value obtained by substituting xi=s[i]. This behaves in the same way as the hom constructor above.If the elements of s lie in a ring and can be lifted into the coefficient ring R, then the result will be an element of R. If the elements of s cannot be lifted to the coefficient ring, then an attempt is made to do a generic evaluation of f at s. In this case, the result will be of the same type as the elements of s.
> K := RationalField(); > F<x,y,z> := FreeAlgebra(K, 3); > g := x*y + y*z; > g; x*y + y*z > Evaluate(g, [1,2,3]); 8 > Parent($1); Rational Field > Evaluate(g, [y,x,z]); x*z + y*x > Parent($1); Finitely presented algebra of rank 3 over Rational Field Non-commutative Graded Lexicographical Order Variables: x, y, z