On Fri, 03 Nov 2006 06:37:28 -0800, Bill Page <[EMAIL PROTECTED]> wrote: > On November 2, 2006 11:47 PM Robert Bradshaw wrote: >> On Nov 2, 2006, at 8:28 PM, David Harvey wrote: >> > On Nov 2, 2006, at 11:11 PM, Robert Bradshaw wrote: > sage: x = axiom('x::MPOLY([x],INT)') > sage: x.type() > MultivariatePolynomial([x],Integer) > sage: y = axiom('y::MPOLY([y],INT)') > sage: y.type() > MultivariatePolynomial([y],Integer) > sage: z = x*y > sage: z > y x > sage: z.type() > MultivariatePolynomial([x],MultivariatePolynomial([y],Integer)) > sage: w = axiom('(x*y)::MPOLY([x,y],INT)') > sage: w > y x > sage: w.type() > MultivariatePolynomial([x,y],Integer) > > ------ > > Notice in particular the type of z. Since y is from the Ring > MPOLY([y],INT), Axiom constructs the result as a polynomial > in x over the ring of polynomials in y. Is that crazy or is > that just being rigourously correct? ;) Perhaps Axiom's result > is more "minimal" then what you proposed. > > But the result w shows that it is possible to specify a > coercion that does yield the result you expect. > > I mention Axiom not because the way it works there is > necessarily the best, but rather because I think Axiom > illustrates fairly well what can happen when you attempt > to produce a general system of coercions. Sometimes the > results are not what you expect.
This is precisely why I'm becoming convinced that SAGE shouldn't have coercions when the result isn't in the parent of either of the operands. With the current SAGE coercion rules that we came up with at SAGE days, you always (mostly) know precisely what will happen, or you get an error: * if there are no canonical coercions of both elements into one parent, an error. * if there is exactly one canonical coercion, use it. * if there are two canonical coercions, the parents are canonically isomorphic, so we choose the left one (since it doesn't matter as the parents are canonically isomorphic). -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@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-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---