Karim BELABAS on Tue, 4 Feb 2003 23:12:38 +0100 (MET) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Wrong (negative) degree returned by poldegree. |
On Wed, 29 Jan 2003, Alexander Shumakovitch wrote: > I've recently came across the following problem with Pari 2.2.4: > (13:16) gp > p1 = t^2 / q^4 > %1 = 1/q^4*t^2 > (13:16) gp > poldegree(p1, q) > %2 = -1 > > On the other hand, > (13:16) gp > p2 = p1 / t^7 > %3 = 1/(q^4*t^5) > (13:17) gp > poldegree(p2, q) > %4 = -4 > > poldegree obviously assumes that all exponents in a polynomial are positive > (it takes a maximum with -1 (basemath/gen3.c: 215), if one asks for a degree > with respect to a secondary variable. But this is not the case for p1: > (13:17) gp > Vec(p1) > %5 = [1/q^4, 0, 0] > > Does the problem lie with the internal simplifications of (Laurent) > polynomials in Pari? The easiest solution would be to define poldegree(0) as > -VERYBIGINT (one can't have _that_ many monomials anyway). The the code would > work as it is. To keep the old convention intact, one could rename poldegree > to, say, poldegree0 (since it's recursive) and define poldegree as > poldegree0 == -VERYBIGINT ? -1 : poldegree0 The old convention didn't make much sense, since -1 is a perfectly legitimate result. I _think_ it was only chosen because internally the degree of a non-zero polynomial x is lgef(x) - 3, which gives -1 when x is a zero polynomial, so a uniform formula could be used... -VERYBIGINT is a good approximation to -oo, and consistent with valuation(0, p) [ = VERYBIGINT ], and a few other functions needing to represent infinity (padicprec, newtonpoly). I've committed the corresponding patch [ and fixed the docs ]. Thanks, Karim. -- Karim Belabas Tel: (+33) (0)1 69 15 57 48 Dép. de Mathématiques, Bât. 425 Fax: (+33) (0)1 69 15 60 19 Université Paris-Sud Email: Karim.Belabas@math.u-psud.fr F-91405 Orsay (France) http://www.math.u-psud.fr/~belabas/ -- PARI/GP Home Page: http://www.parigp-home.de/