Hi Stephen

On 2014-05-29, Stephen Kauffman <strangerl...@gmail.com> wrote:
> Specifically I have a polynomial such as mypoly = X*Y + 1 in 
> BooleanPoynomialRing() and str(mypoly) converts it to the string 'X*Y + 1' 
> then I do some stuff with re pattern matching to construct the string '1 - 
> x*y' which I now want to convert to a polynomial in 'x' and 'y' in QQ. Are 
> there any built in functions or methods to do that?

Generally, if you have an algebraic structure Y (often called "parent") in
Sage, and have some element x of some other algebraic structure x, then
Y(x) tries to convert x into an element of Y. The same holds for
conversion of a string.

Note, however, that a conversion is not necessarily making mathematical
sense, if the structures X and Y are too different (i.e., there may be
no homomorphism from X to Y). So, use conversions only if you know what
you are doing.

What you describe would be as follows:
  sage: P.<x,y> = BooleanPolynomialRing()
  sage: mypoly = x*y+1
  sage: R = QQ['x','y']
  sage: R(mypoly)
  x*y + 1
  sage: R('1-x*y')  # replacing + by - in str(mypoly)
  x*y - 1

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to