On Feb 14, 9:54 am, tvn <nguyenthanh...@gmail.com> wrote:
> sage: R.<x,y,z,A,B,k,i,j,m>=QQ[]
This is a shorthand notation that assigns to x, ..., m the polynomial
variables generating QQ[x,y,z,...,m]
> sage: J=I.elimination_ideal([k,i,j,m,A,B])
This routine expects a list of polynomial variables as argument

> Version 2:
> sage: vs = var('x,y,z,A,B,k,i,j,m')
This is the special "top level" var, that also binds x,...,m to the
*symbolic variables* x,...,m

> sage: R = PolynomialRing(QQ,vs)
This creates the right polynomial ring because it can figure out what
to do with the symbolic variables given as an argument. However, the
identifiers x,...,m still refer to the symbolic variables with the
same print names.
> sage: I = R*invs
Your "invs" consists of symbolic expressions. However, they only
contain variable names whose print names match the generating
polynomial variables for R, so sage can figure out how to map over
these symbolic expressions to R and generate the right ideal there.
See "coercion framework" for the tricks employed for that.
> sage: J=I.elimination_ideal([k,i,j,m,A,B])
You are calling this routine with a list of *symbolic variables*. This
routine does not try to use the coercion framework (perhaps it
should), so when you give it a list of symbolic variables it doesn't
know what to do. If you explicitly convert the symbolic variables to
polynomial ones, it does work:

sage: I.elimination_ideal( list(R(v) for v in [k,i,j,m,A,B]) )

Example:

sage: x_symbolic=SR.var('x')
sage: x_polynomial=QQ['x','y'].0
sage: L=[x_polynomial, x_symbolic]
sage: L
[x, x]
sage: [type(a) for a in L]
[<type
'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'>,
<type 'sage.symbolic.expression.Expression'>]

The problem is that there can be a lot of "x"s: There is x the python/
sage variable, which is bound to some object. Then there are several
objects: a "symbolic expression" that happens to print as "x" and an
element of a polynomial ring that happens to print as "x".
Some shorthands in sage try to hide the difference between the python
variable and the object it is bound to, by implicitly making that
binding. This is convenient for casual use. However, when you mix
polynomial rings and symbolic expressions there is not a clear choice
anymore and you are better off ensuring you preserve the distinction
between python variables and mathematical objects that happen to be
called (symbolic or polynomial) variables.

sage: x=x_symbolic
sage: parent(x)
Symbolic Ring
sage: x=x_polynomial
sage: parent(x)
Multivariate Polynomial Ring in x, y over Rational Field

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to