.. status: ok 9.90 XPolynomialRing -------------------- The XPolynomialRing domain constructor implements generalized polynomials with coefficients from an arbitrary Ring (not necessarily commutative) and whose exponents are words from an arbitrary OrderedMonoid (not necessarily commutative too). Thus these polynomials are (finite) linear combinations of words. This constructor takes two arguments. The first one is a Ring and the second is an OrderedMonoid. The abbreviation for XPolynomialRing is XPR. Other constructors like XPolynomial, XRecursivePolynomial XDistributedPolynomial, LiePolynomial and XPBWPolynomial implement multivariate polynomials in non-commutative variables. We illustrate now some of the facilities of the XPR domain constructor. Define the free ordered monoid generated by the symbols. .. spadInput :: Word := OrderedFreeMonoid(Symbol) .. spadMathAnswer .. spadMathOutput .. math:: +---------------------------+ | OrderedFreeMonoidSymbol | +---------------------------+ .. spadType :sub:`Type: Domain` Define the linear combinations of these words with integer coefficients. .. spadInput :: poly:= XPR(Integer,Word) .. spadMathAnswer .. spadMathOutput .. math:: +----------------------------------------------------+ | XPolynomialRing(Integer,OrderedFreeMonoidSymbol) | +----------------------------------------------------+ .. spadType :sub:`Type: Domain` Then we define a first element from poly. .. spadInput :: p:poly := 2 * x - 3 * y + 1 .. spadMathAnswer .. spadMathOutput .. math:: +-----------+ | 1+2x-3y | +-----------+ .. spadType :sub:`Type: XPolynomialRing(Integer,OrderedFreeMonoid Symbol)` And a second one. .. spadInput :: q:poly := 2 * x + 1 .. spadMathAnswer .. spadMathOutput .. math:: +--------+ | 1+2x | +--------+ .. spadType :sub:`Type: XPolynomialRing(Integer,OrderedFreeMonoid Symbol)` We compute their sum, .. spadInput :: p + q .. spadMathAnswer .. spadMathOutput .. math:: +-----------+ | 2+4x-3y | +-----------+ .. spadType :sub:`Type: XPolynomialRing(Integer,OrderedFreeMonoid Symbol)` their product, .. spadInput :: p * q .. spadMathAnswer .. spadMathOutput .. math:: +-------------------+ | 1+4x-3y+4x2-6yx | +-------------------+ .. spadType :sub:`Type: XPolynomialRing(Integer,OrderedFreeMonoid Symbol)` and see that variables do not commute. .. spadInput :: (p+q)^2-p^2-q^2-2*p*q .. spadMathAnswer .. spadMathOutput .. math:: +------------+ | -6xy+6yx | +------------+ .. spadType :sub:`Type: XPolynomialRing(Integer,OrderedFreeMonoid Symbol)` Now we define a ring of square matrices, .. spadInput :: M := SquareMatrix(2,Fraction Integer) .. spadMathAnswer .. spadMathOutput .. math:: +-----------------------------------+ | SquareMatrix(2,FractionInteger) | +-----------------------------------+ .. spadType :sub:`Type: Domain` and the linear combinations of words with these matrices as coefficients. .. spadInput :: poly1:= XPR(M,Word) .. spadMathAnswer .. spadMathOutput .. math:: +------------------------------------------------------------------------------+ | XPolynomialRing(SquareMatrix(2,FractionInteger),  OrderedFreeMonoidSymbol) | +------------------------------------------------------------------------------+ .. spadType :sub:`Type: Domain` Define a first matrix, .. spadInput :: m1:M := matrix [ [i*j^2 for i in 1..2] for j in 1..2] .. spadMathAnswer .. spadMathOutput .. math:: +----------+ | [1248] | +----------+ .. spadType :sub:`Type: SquareMatrix(2,Fraction Integer)` a second one, .. spadInput :: m2:M := m1 - 5/4 .. spadMathAnswer .. spadMathOutput .. math:: +--------------+ | [-1424274] | +--------------+ .. spadType :sub:`Type: SquareMatrix(2,Fraction Integer)` and a third one. .. spadInput :: m3: M := m2^2 .. spadMathAnswer .. spadMathOutput .. math:: +--------------------+ | [12916132685716] | +--------------------+ .. spadType :sub:`Type: SquareMatrix(2,Fraction Integer)` Define a polynomial, .. spadInput :: pm:poly1 := m1*x + m2*y + m3*z - 2/3 .. spadMathAnswer .. spadMathOutput .. math:: +----------------------------------------------------+ | [-2300-23]+[1248]x+[-1424274]y+[12916132685716]z | +----------------------------------------------------+ .. spadType :sub:`Type: XPolynomialRing( SquareMatrix(2,Fraction Integer),` OrderedFreeMonoid Symbol) a second one, .. spadInput :: qm:poly1 := pm - m1*x .. spadMathAnswer .. spadMathOutput .. math:: +--------------------------------------------+ | [-2300-23]+[-1424274]y+[12916132685716]z | +--------------------------------------------+ .. spadType :sub:`Type: XPolynomialRing( SquareMatrix(2,Fraction Integer),` OrderedFreeMonoid Symbol) and the following power. .. spadInput :: qm^3 .. spadMathAnswer .. spadMathOutput .. math:: +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | [-82700-827]+[-13831639]y+[434523104385712]z+[-1298-26-52-8578]y2+[-319932-8314-8312-2646732]yz+[-319932-8314-8312-2646732]zy+[-103169128-64094-64092-820977128]z2+[319964831883142646764]y3+[1031692566409864094820977256]y2z+[1031692566409864094820977256]yzy+[3178239102479534112879534164254477871024]yz2+[1031692566409864094820977256]zy2+[3178239102479534112879534164254477871024]zyz+[3178239102479534112879534164254477871024]z2y+[98625409409612326223256123262231287888938974096]z3 | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. spadType :sub:`Type: XPolynomialRing(SquareMatrix(2,Fraction Integer),OrderedFreeMonoid` Symbol)