up previous next
RingElem

convert an expression into a RINGELEM

Syntax
RingElem(R: RING, E: STRING): RINGELEM
RingElem(R: RING, E: RINGELEM): RINGELEM
RingElem(R: RING, E: INT): RINGELEM
RingElem(R: RING, E: RAT): RINGELEM
RingElem(R: RING, E:[STRING, INT, .., INT]): RINGELEM

Description
This function converts the expression E into a RINGELEM in R , if possible. Useful for operating with different rings.

If E is a STRING it reads E in R , (with no need for use R ). The expression E may contain operations and parentheses, but no programming variables nor function calls. New from version 5.2.0; was previously called ReadExpr .

If E is a RINGELEM it is equivalent to applying the CanonicalHom from RingOf(E) to R (for other homomorphisms see RINGHOM ).

Example
/**/  P ::= QQ[x,y];  S ::= QQ[x,y,z[1..4,3..7]];  K := NewFractionField(P);
/**/  QR := NewQuotientRing(P, ideal(RingElem(P,"x^2-3"), RingElem(P,"y^2-5")));

/**/  -- STRING
/**/  7*RingElem(P, "x");  --> x as an element of P
2*x
/**/  7*RingElem(S, "x");  --> x as an element of S
7*x
/**/  RingElem(S, "((7/3)*z[2,5] - 1)^2" ); -- expr without function calls
49*z[2,5]^2 -14*z[2,5] +1
/**/  RingElem(K, "(x^2-x*y)/(x*y-y^2)");
x/y
/**/ f := RingElem(S, "(x+y)^3");  f;
x^3 +3*x^2*y +3*x*y^2 +y^3
/**/ RingElem(QR, sprint(f));
(18*x +14*y)
/**/ RingElem(NewPolyRing(NewRingFp(3), "x,y"), sprint(f));
x^3 +y^3

/**/  -- RINGELEM (via CanonicalHom)
/**/  use P;
/**/  f := 2*x-3;
-- /**/  f/LC(f); -- !!! ERROR !!! as expected: LC(F) in CoeffRing(P)
/**/  f/RingElem(P,LC(f));
x +1
-- /**/  1/f; -- !!! ERROR !!! as expected: f in P is not invertible
/**/  1/RingElem(K, f); -- f in K is invertible
1/x

/**/  Use P ::= ZZ/(5)[x,y,z];
/**/  -- INT and RAT
/**/  RingElem(P, 7);
2
/**/  RingElem(P, 3/2);
-1

/**/  -- LIST
/**/  i:=2; j:=5;  7*RingElem(S, ["z",i,j]); 
7*z[2,5]

See Also