# Difference between revisions of "ApCoCoA-1:NC.Add"

Line 2: | Line 2: | ||

<title>NC.Add</title> | <title>NC.Add</title> | ||

<short_description> | <short_description> | ||

− | Addition of two polynomials over a free | + | Addition of two polynomials over a free monoid ring. |

</short_description> | </short_description> | ||

<syntax> | <syntax> | ||

Line 10: | Line 10: | ||

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

<par/> | <par/> | ||

− | Please set ring environment coefficient field <tt>K</tt>, alphabet (or indeterminates) <tt>X</tt> and ordering | + | Please set ring environment <em>coefficient field</em> <tt>K</tt>, <em>alphabet</em> (or set of indeterminates) <tt>X</tt> and <em>ordering</em> via the functions <ref>NC.SetFp</ref>, <ref>NC.SetX</ref> and <ref>NC.SetOrdering</ref>, respectively, before calling the function. Default coefficient field is <tt>Q</tt>. Default ordering is length-lexicographic ordering (<quotes>LLEX</quotes>). For more information, please check the relevant functions. |

<itemize> | <itemize> | ||

− | <item>@param <em>F1, F2:</em> two polynomials in <tt>K<X></tt>, which are left and right operands of addition respectively. Each polynomial is represented as a LIST of | + | <item>@param <em>F1, F2:</em> two polynomials in <tt>K<X></tt>, which are left and right operands of addition respectively. Each polynomial is represented as a LIST of monomials, which are pairs of the form [C, W] where W is a word in <tt><X></tt> and C is the coefficient of W. For example, the polynomial <tt>F=xy-y+1</tt> is represented as F:=[[1,<quotes>xy</quotes>], [-1, <quotes>y</quotes>], [1,<quotes></quotes>]]. The zero polynomial <tt>0</tt> is represented as an empty LIST [].</item> |

− | <item>@return: a LIST which represents | + | <item>@return: a LIST which represents the polynomial equal to <tt>F1+F2</tt>.</item> |

</itemize> | </itemize> | ||

<example> | <example> | ||

Line 23: | Line 23: | ||

Ordering : ELIM | Ordering : ELIM | ||

− | ------------------------------- | + | ------------------------------- |

+ | |||

F1 := [[1,<quotes>a</quotes>],[1,<quotes></quotes>]]; | F1 := [[1,<quotes>a</quotes>],[1,<quotes></quotes>]]; | ||

F2 := [[1,<quotes>b</quotes>],[1,<quotes>ba</quotes>]]; | F2 := [[1,<quotes>b</quotes>],[1,<quotes>ba</quotes>]]; | ||

Line 29: | Line 30: | ||

[[1, <quotes>ba</quotes>], [1, <quotes>a</quotes>], [1, <quotes>b</quotes>], [1, <quotes></quotes>]] | [[1, <quotes>ba</quotes>], [1, <quotes>a</quotes>], [1, <quotes>b</quotes>], [1, <quotes></quotes>]] | ||

------------------------------- | ------------------------------- | ||

+ | |||

NC.SetFp(); -- set default Fp = F2 | NC.SetFp(); -- set default Fp = F2 | ||

NC.RingEnv(); | NC.RingEnv(); | ||

Line 36: | Line 38: | ||

------------------------------- | ------------------------------- | ||

+ | |||

NC.Add(F1,F2); -- over F2 | NC.Add(F1,F2); -- over F2 | ||

[[1, <quotes>ba</quotes>], [1, <quotes>a</quotes>], [1, <quotes>b</quotes>], [1, <quotes></quotes>]] | [[1, <quotes>ba</quotes>], [1, <quotes>a</quotes>], [1, <quotes>b</quotes>], [1, <quotes></quotes>]] | ||

------------------------------- | ------------------------------- | ||

+ | |||

NC.Add(F1,F1); -- over F2 | NC.Add(F1,F1); -- over F2 | ||

[ ] | [ ] |

## Revision as of 11:21, 7 June 2012

## NC.Add

Addition of two polynomials over a free monoid ring.

### Syntax

NC.Add(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 ring environment *coefficient field* `K`, *alphabet* (or set of indeterminates) `X` and *ordering* via the functions NC.SetFp, NC.SetX and NC.SetOrdering, respectively, before calling the function. Default coefficient field is `Q`. Default ordering is length-lexicographic ordering ("LLEX"). For more information, please check the relevant functions.

@param

*F1, F2:*two polynomials in`K<X>`, which are left and right operands of addition 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 an empty LIST [].@return: a LIST which represents the polynomial equal to

`F1+F2`.

#### Example

NC.SetX(<quotes>abc</quotes>); NC.SetOrdering(<quotes>ELIM</quotes>); NC.RingEnv(); Coefficient ring : Q Alphabet : abc Ordering : ELIM ------------------------------- F1 := [[1,<quotes>a</quotes>],[1,<quotes></quotes>]]; F2 := [[1,<quotes>b</quotes>],[1,<quotes>ba</quotes>]]; NC.Add(F1,F2); -- over Q [[1, <quotes>ba</quotes>], [1, <quotes>a</quotes>], [1, <quotes>b</quotes>], [1, <quotes></quotes>]] ------------------------------- NC.SetFp(); -- set default Fp = F2 NC.RingEnv(); Coefficient ring : Fp = Z/(2) Alphabet : abc Ordering : ELIM ------------------------------- NC.Add(F1,F2); -- over F2 [[1, <quotes>ba</quotes>], [1, <quotes>a</quotes>], [1, <quotes>b</quotes>], [1, <quotes></quotes>]] ------------------------------- NC.Add(F1,F1); -- over F2 [ ] -------------------------------

### See also