# ApCoCoA-1:NCo.MRSubtract

This article is about a function from ApCoCoA-1. |

## NCo.MRSubtract

Subtraction of two polynomials in a finitely presented monoid ring.

### Syntax

NCo.MRSubtract(X:STRING, Ordering:STRING, Relations:LIST, F1:LIST, F2:LIST):LIST

### Description

*Please note:* The function(s) explained on this page is/are using the *ApCoCoAServer*. You will have to start the ApCoCoAServer in order to use it/them.

Please set coefficient field via the function NCo.SetFp (or NCo.UnsetFp) before calling this function. The default coefficient field is the field of rational numbers, i.e. RAT in CoCoAL. For more information, please check the relevant functions.

@param

*X:*a finite alphabet (or set of indeterminates). It is of STRING type. Note that every letter in X MUST appear only once.The order of letters in X induces word orderings.@param

*Ordering:*a word ordering induced by the order of letters in X. It is a STRING, which is a shortened-form of the name of corresponding word ordering. Note that "LLEX" (the length-lexicographic ordering), "ELIM" (an elimination ordering) and "LRLEX" (the length-reverse-lexicographic ordering) are supported currently. See NCo.SetOrdering for more details.@param

*Relations:*a finite set of relations. It is of LIST type. Each element in Relations is of the form [W1, W2], where W1 and W2 are words in`<X>`. Each word is represented as a STRING. For example, the word`xy^2x`is represented as "xyyx", and the identity is represented as the empty string "". Thus, the relation`(yx, xy)`is represented as ["yx", "xy"], and the set of relations`{(yx, xy),(zx,xz),(zy,yz)}`is represented as [["yx", "xy"],["zx", "xz"],["zy", "yz"]].@param

*F1, F2:*two polynomials, which are left and right operands of subtraction respectively. Each polynomial is represented as a LIST of monomials, which are pairs of the form [C, W] where W is a word in`<X>`and C is the coefficient of W. For example, the polynomial`f=xy-y+1`is represented as F:=[[1,"xy"], [-1, "y"], [1,""]]. The zero polynomial`0`is represented as the empty LIST [].@return: a LIST which represents the polynomial equal to F1-F2.

#### Example

X := "abc"; Ordering := "LLEX"; Relations := [["aa",""], ["bb",""], ["ab","c"], ["ac", "b"], ["cb", "a"]]; F1 := [[1,"a"],[1,"ac"]]; -- F1=a+ac=a+b F2 := [[1,"b"],[1,"ba"]]; -- F2=b+ba NCo.MRSubtract(X, Ordering, Relations, F1, F2); [[-1, "ba"], [1, "a"]] ------------------------------- X := "abc"; Ordering := "LLEX"; Relations := [["aa",""], ["bb",""], ["ab","c"], ["ac", "b"], ["cb", "a"]]; F1 := [[1,"a"],[1,""]]; -- F1=a+1 NCo.MRSubtract(X, Ordering, Relations, F1, F1); -- F1-F1 [ ] ------------------------------- X := "abc"; Ordering := "LLEX"; Relations := [["aa",""], ["bb",""], ["ab","c"], ["ac", "b"], ["cb", "a"]]; F1 := [[1,"a"],[1,""]]; -- F1=a+1 NCo.MRSubtract(X, Ordering, Relations, [], F1); -- 0-F1 [[-1, "a"], [-1, ""]] -------------------------------

### See also