On 10/12/07, Joel B. Mohler <[EMAIL PROTECTED]> wrote:
>
> Sorry for the continued barrage of silly questions.  It's my day to go through
> sage gotcha's I'd accumulated.

Excellent!!

> Why doesn't this next substitution result in 5/y?
>
> sage: P.<x,y>=ZZ[]
> sage: (x/y).subs({x:5})  # this should be 5/y
> x/y
> sage: {x:5}.has_key(FractionField(P).gen(0))
> False

Note that

   sage: f = x/y
   sage: f(x=5)

works fine.   So the bug is in subs calling f.__call__ incorrectly.
Thus the problem is in subs in element.pyx.  Fix that.
Here's a good hint as to why this is broken, by the way:

sage: P.<x,y>=ZZ[]
sage: f = x/y
sage: f.subs({f.parent().gen(0):5})
5/y

The problem is that subs is not textually comparing variables
but actually comparing objects -- f.parent().gen(0) prints as
"x", but it is *not* the x of f.parent().  You need to maybe do
a coercion or something instead of just comparing objects.

Got to go.


> Ok, the last False gives me a clue (after looking at the source for subs).
> So, it seems fair that the generators aren't shared between the poly ring and
> it's fraction field.
> sage: {x:5}.has_key(P.gen(0))
> True
>
> So, then I branch out a bit.  Why does the following work as I think it
> should?  I was going to fix the bug in the above, but I can't figure out what
> to fix because it works with the QQ ring.
>
> sage: P.<x,y>=QQ[]  # NOTE:  QQ not ZZ
> sage: (x/y).subs({x:5})
> 5/y
> sage: {x:5}.has_key(FractionField(P).gen(0))
> True
>
> Would someone be willing to look at the subs code and cast a vote about what
> precisely to fix?
>
> --
> Joel
>
> >
>


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

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

Reply via email to