## com.perisic.ring Class UniversalPolynomialRing

```java.lang.Object
com.perisic.ring.Ring
com.perisic.ring.UniversalRing
com.perisic.ring.UniversalPolynomialRing
```

`public class UniversalPolynomialRingextends UniversalRing`

The field of polynomials over all allowed variable names as variables. That is, say in this ring you can add a polynomial a^2 + b of Z[a][b] with b - c of Z[b][c] and get as result a polynomial of the ring Z[a][b][c] (the order of the variables is undefined and may vary).

• Generated January 16, 2003.
• Last Change: April 18, 2003: Exception list of variables.
• Last Change: 13.12.2003: GPL MC.
• Last Change: 01.05.2011: Added methods evaluatePolynomial
• Copyright:(c) Marc Conrad, 2002, 2003,2011
• Email: ring@perisic.com. Please let me know if you use this software.
• WWW: www.ring.perisic.com
• The com.perisic.ring library is distributed under the terms of the GNU Lesser General Public License (LGPL).
• If you require the package under a different licence please contact me.
• disclaimer: The classes are provided "as is". There is no warranty implied by using the com.perisic.ring package.
Example:
```public static void main(String [] args) {
// Define a polynomial ring over R
UniversalPolynomialRing U = new UniversalPolynomialRing(Ring.R);
RingElt poly1 = U.map("0.5 * ((x1 - x2)^2 - a * (x1 + x2)^2)");
System.out.println("poly1="+poly1+" of "+poly1.getRing());

// 1st Example to substitute variables:
String [] variables = { "x1", "x2" };
RingElt [] values = { Ring.R.map(2.3), Ring.R.map(1.7) };
RingElt poly2 = U.evaluatePolynomial(poly1, variables, values);
System.out.println("Example1: poly2="+poly2+" of "+poly2.getRing());

//      2nd Example to substitute variables:
RingElt poly3 = U.evaluatePolynomial(poly1, "a", Ring.R.map(-1));
System.out.println("Example2: poly3="+poly3+" of "+poly3.getRing());

//      3rd Example to substitute variables:
RingElt poly4 = U.evaluatePolynomial(poly3, variables, values);
System.out.println("Example3: poly4="+poly4+" of "+poly4.getRing());
}
```
Produces the following output:
```poly1=(0.5 + -0.5*a)*x2^2 + ((-1.0 + -1.0*a)*x2)*x1 + (0.5 + -0.5*a)*x1^2 of R[a][x2][x1]
Example1: poly2=0.18000000000000016 + -7.999999999999999*a of R[a]
Example2: poly3=1.0*x2^2 + 1.0*x1^2 of R[x2][x1]
Example3: poly4=8.18 of R
```

Version:
0.4
Author:
Marc Conrad

Field Summary

Fields inherited from class com.perisic.ring.Ring
`C, F2, Q, R, Z`

Constructor Summary
`UniversalPolynomialRing(Ring coefficientRing)`
Construct the universal polynomial field by the ring of coefficients.

Method Summary
` RingElt` ```evaluatePolynomial(RingElt p, java.lang.String[] var, RingElt[] b)```
Evaluates the polynomial p at the variables var[i] with the values b[i].
` RingElt` ```evaluatePolynomial(RingElt p, java.lang.String var, RingElt b)```
Evaluates the Polynomial p (which may be defined over more than one variable) at b for the variable var.
` Ring` `findRing()`
A suitable ring able to map 0 (and 1).
` Ring` `findRing(RingElt a)`
The ring over the coefficient ring with the variables of a.getRing().
` Ring` ```findRing(RingElt a, RingElt b)```
The result is the coefficient ring over the variables of a.getRing() and the variables of b.getRing().
` boolean` `isUFD()`
true if the coefficient ring and therefore also the polynomial ring is an uniqe factorization domain.
`static void` `main(java.lang.String[] args)`
Simple test method.
` RingElt` `map(java.lang.String str)`
All Java identifiers are allowed as variables.
` RingElt` `reduceVariables(RingElt p)`
Reduces the polynomial into a polynomial of the polynomial ring with the fewest variables.
` java.lang.String` `toString()`

Methods inherited from class com.perisic.ring.UniversalRing
`add, ediv, equalZero, gcd, inv, map, mod, mult, neg, one, tdiv, zero`

Methods inherited from class com.perisic.ring.Ring
`div, eltToString, equal, evaluatePolynomial, isEuclidian, isField, map, map, map, pow, pow, sub`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### UniversalPolynomialRing

`public UniversalPolynomialRing(Ring coefficientRing)`
Construct the universal polynomial field by the ring of coefficients.

Method Detail

### toString

`public java.lang.String toString()`
Overrides:
`toString` in class `UniversalRing`
Returns:
"R[...]" where R is the coefficient ring.

### isUFD

`public boolean isUFD()`
true if the coefficient ring and therefore also the polynomial ring is an uniqe factorization domain. False otherwise.

Overrides:
`isUFD` in class `Ring`
Returns:
true if the polynomial ring is an UFD

### map

`public RingElt map(java.lang.String str)`
All Java identifiers are allowed as variables. That means the first character is true with java.lang.Character.isJavaIdentifierStart(), the following chracters return true with Character.isJavaIdentifierPart()

Overrides:
`map` in class `UniversalRing`

### findRing

`public Ring findRing()`
Description copied from class: `UniversalRing`
A suitable ring able to map 0 (and 1).

Specified by:
`findRing` in class `UniversalRing`
Returns:
the ring of coefficients.

### findRing

`public Ring findRing(RingElt a)`
The ring over the coefficient ring with the variables of a.getRing().

Specified by:
`findRing` in class `UniversalRing`

### findRing

```public Ring findRing(RingElt a,
RingElt b)```
The result is the coefficient ring over the variables of a.getRing() and the variables of b.getRing().

Specified by:
`findRing` in class `UniversalRing`

### reduceVariables

`public RingElt reduceVariables(RingElt p)`
Reduces the polynomial into a polynomial of the polynomial ring with the fewest variables. For instance if p = a^2 + b^2 is an element of Z[x][a][y][b][c] then reduceVariables(p) = a^2 + b^2 in Z[a][b].

### evaluatePolynomial

```public RingElt evaluatePolynomial(RingElt p,
java.lang.String[] var,
RingElt[] b)```
Evaluates the polynomial p at the variables var[i] with the values b[i]. The lengths of var and b must be the same and is not checked.

### evaluatePolynomial

```public RingElt evaluatePolynomial(RingElt p,
java.lang.String var,
RingElt b)```
Evaluates the Polynomial p (which may be defined over more than one variable) at b for the variable var. If p is not a polynomial or if p (as a polynomial) does not contain the variable var the polynomial p is returned (p is the considered a constant in respect to var).

### main

`public static void main(java.lang.String[] args)`
Simple test method.

Parameters:
`args` -