Karim Belabas on Tue, 10 Jul 2018 11:56:38 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Mysterious type t_RFRAC and denominator function |
* Bill Allombert [2018-07-10 11:08]: > On Mon, Jul 09, 2018 at 08:58:25PM +0000, Jacques Gélinas wrote: >> # type(a/b) >> %1 = "t_POL" >> # type(b/a) >> %2 = "t_RFRAC" >> # denominator(a/b) >> %3 = 1 >> # denominator(b/a) >> %4 = a >> >> Can one conclude that the symbol "a' is treated differently than the symbol "b" ? > > No. Variables have priorities, which depends in which order they are > created by GP. > In your example a is introduced before b so has higher priority. > so you are computing in Q(b)(a) and not Q(a)(b). > So a/b is a polynomial in a while b/a is a rational function in a. > It follows that the denominators are 1 and a respectively. > > This is documented in > ??"Variable priorities, multivariate objects"@2 Because of this, the denominator() function (and similarly numerator(), content(), divrem()...) is highly sensitive to the input internal structure, which is very hard to control. For one thing, the variable ordering depends on the order of commands in the session history (which can be upset by reading in GP files). And then, the objects structure is easily wrecked by functions like simplify() or the 'simplify' default which can cause intended polynomials (of degree 0) to become scalars. Assuming 'simplify' is still at his [unfortunate] default value '1', compare ? a = Pol(1/2,'x) %1 = 1/2 ? denominator(a) \\ in Q(x) !!! %2 = 1 ? denominator(%1) \\ in Q because %1 = simplify(a) is now a scalar :-( %3 = 2 >From version 2.10.1 on, you can use an optional second parameter to explicitly specify the base field and not rely on fragile guesses. [ Leaving it out is acceptable for integers or rational numbers, but not recommended whenever polynomials are expected. ] ? denominator(a, 'x) \\ in Q(x) %4 = 1 ? denominator(%1, 'x) \\ still in Q(x) %5 = 1 ? denominator(a, 1) \\ now wrt. Q structure %6 = 2 ? denominator(%1, 1) \\ still good %7 = 2 Cheers, K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite de Bordeaux Fax: (+33) (0)5 40 00 21 23 351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] `