On Thu, May 22, 2008 at 4:43 AM, Marc Roeder <[EMAIL PROTECTED]> wrote:
>
> Dear sage community,
>
> I am new to sage, so please forgive me if I am reporting well-known
> behaviour here.
> When generating multivariate polynomial rings, some (seemingly) odd
> things can happen:
>
> 1. Sage seems to guess the meaning of 'x' in some cases:
>
> sage: QX=MPolynomialRing(QQ,2,'xy'); QX
> Multivariate Polynomial Ring in x, y over Rational Field
> sage: x in QX     # no variables assinged to indeterminates yet...
> False

That is the predefined symbolic x that is defined at startup
before you do anything.   Unless you explicitly assign the
gens of QX to variables (or set auto injection on),
they won't be bound to variables.

sage: type(x)
<class 'sage.calculus.calculus.SymbolicVariable'>
sage: QX=MPolynomialRing(QQ,2,'xy')
sage: type(x)
<class 'sage.calculus.calculus.SymbolicVariable'>
sage: QX.gens()
(x, y)
sage: type(QX.gens()[0])
<type 
'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>

You might like the inject_on() mode:

sage: inject_on()
Redefining: Frac FreeMonoid GF FractionField FiniteField
PolynomialRing quotient NumberField LaurentSeriesRing quo
sage: QX=PolynomialRing(QQ,2,'xy')
Defining x, y
sage: type(x)
<type 
'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
sage: type(y)
<type 
'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>


WARNING: inject_on only works with the PolynomialRing command, not the
MPolynomialRing command.   Either the latter should be supported, or
the command should be removed entirely.   We are tracking this issue here:
  http://trac.sagemath.org/sage_trac/ticket/3271


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

"foo in bar" means that foo compares to be equal (under natural
coercions) to bar.  E.g., the rational number 3/1 is equal to the
integer 3, so

sage: 3/1 in [3, 5]
True

even though the types are different.  The same happens above
in your example.

>
> 2. indeterminates are sometimes shared between rings:
> sage: R.<x,y>=QQ[];R
> Multivariate Polynomial Ring in x, y over Rational Field
> sage: R2=MPolynomialRing(QQ,2,'xy')
> sage: R==R2
> True
> sage: R2=MPolynomialRing(QQ,1,'x')
> sage: x in R2
> False

See above.    There is *no* canonial inclusion map
from the second ring to the first in Sage.

This is different than the following example:

sage: QX=PolynomialRing(QQ,2,'xy')
sage: x in [ QX.0]   # here x is he default symbolic var
True

Here the "in" is true since there is a canonical ceorcion
map from QX into the ring of all symbolic expressions.

>
> This looks inconsistent. Shouldn't R2 have it's own set of
> indeterminates?

It does.

> If the user wants to have the same display names for
> indeterminates of different rings that shouldn't be sage's problem.

It isn't.

>
> Thanks very much,
> marc
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
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