On 1 mar, 20:46, Pierre <pierre.guil...@gmail.com> wrote:
> oooh wait wait wait. I've said something totally confusing.
>
> My previous two posts apply to rational fractions... for which indeed,
> the numerator method gives the 'correct' answer ! The issue I raised
> in my original post is the 'funny' behaviour when you ask for the
> numerator of something in QQ[x] -- which, come to think of it, is
> mathematically a little unsound. I just totally assumed this should
> give the same answer as coercing into the field of rational fractions
> and then applying numerator(), but it doesn't. You (Robert) assumed
> something absolutely different.
>
> (Now i still think it would be less surprising is sage acted as i
> suggested, but i don't have strong feelings about it anymore :) )
>
> so in any case, having realized this, i have found an ugly fix :
>
> sage: N= P.parent().fraction_field()(P).numerator()   # gives what i
> want !! always work !

Yes, this is intentional, I think that it is used somewhere for number
theory. As pointed out, there is no good definition for numerator of
an element in QQ[x].

The current implementation for polynomial rings K[x1,..,xn] is as
following:

-For the denominator: if there is a denominator function for the
coefficients and these denominators have a lcm function, then return
the lcm of the coefficients. This is an element of K, not K[x1,...,xn]
-If the previous computation fails, then return K(1) not K[x1,...,xn]
(1)

The numerator is the original polynomial times its denominator. This
is always in K[x1,..,xn]

It has its drawbacks, as you have found. In particular, the numerator
of an element in QQ[x] is not necessarily the same as the numerator of
the same element in QQ(x).

It has its advantages though. If you try this:

sage: K=QQ['x']
sage: L=K.fraction_field()['y']
sage: f=L.random_element()
sage: f.numerator()
sage: QQ['x','y'](f.numerator())

f lives in Q(x)[y], but its numerator can be coerced to Q[x,y] wich is
nice for some computations. So, in fact, it depends much on what are
you computing.

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