Dear Marc,

let me try some explanations.

On May 22, 1:43 pm, Marc Roeder <[EMAIL PROTECTED]> wrote:
> sage: QX=MPolynomialRing(QQ,2,'xy')
> sage: x in QX     # no variables assinged to indeterminates yet...
> False

If you start Sage, x is already defined:
sage: type(x)
<class 'sage.calculus.calculus.SymbolicVariable'>

The apparent reason is that 'x' is a typical name for a symbolic
variable. However, when one isn't aware that x is pre-defined, strange
things may happen.

Now, defining
  sage: QX=MPolynomialRing(QQ,2,'xy')
does *not* change x!

Sage makes a clear distinction between the default symbolic variable
with identifier 'x' and the ring variable with the name 'x'. The ring
variable can be accessed with
sage: QX.gen(0)
x
sage: x is QX.gen(0)
False

> sage: indets=QX.objgens()[1];indets
> (x, y)
> sage: x in indets
> True
> But x and indets[0] have different types.

You are right:
sage: type(QX.objgens()[1][0])
<type
'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
sage: type(x)
<class 'sage.calculus.calculus.SymbolicVariable'>
sage: x in QX.objgens()[1]
True

I think this is a confusing behaviour that probably has the following
reason:
sage: x==QX.gen(0)
x == x

This is a symbolic equation (since x is symbolic) that evaluates to
True, and consequently you get the wrong answer that the symbolic
variable x belongs to indets.

In x==QX.gen(0) apparently the two *different* objects with coinciding
names got mixed up. Do the more experienced Sage users agree with me
that this is not nice (or a bug)?

> 2. indeterminates are sometimes shared between rings:
> sage: R.<x,y>=QQ[];R

By the way, if you use that syntax, the symbolic variable x is
overwritten, and now x is known to Sage as a ring generator:
sage: R.<x,y>=QQ[]
sage: type(x)
<type
'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>

> sage: R2=MPolynomialRing(QQ,2,'xy')
> sage: R==R2
> True

Yes, they are the same, in the sense that they have the same base ring
and the same variable names in the same *order*.
Compare
sage: R3=MPolynomialRing(QQ,2,'yx')
sage: R==R3
False

Even more, R and R2 are not only the same but *identical*:
sage: R is R2
True

Therefore, x (which is now defined as a generator of R) is also
generator of R2 (since R2 is identical with R2), but it is not a
generator of R3:
sage: x in R3
False

> sage: R2=MPolynomialRing(QQ,1,'x')
> sage: x in R2
> False

Yes, in this example R2 is not identical with R, and by consequence x
does not belong to R2.

In conclusion, i believe that
1) pre-defining x may be confusing, but this is Sage tradition
2) sage: bool(var('x')=='x')
   True
   is a bug, IMO.
3) your observations concerning generators of R,R2 can be explained by
the distinction between "the same" and "identical".

Yours
      Simon

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to