John Cremona on Tue, 20 Jan 2015 14:32:32 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Mixing variables in Mod expressions


On 20 January 2015 at 10:51, Karim Belabas
<Karim.Belabas@math.u-bordeaux.fr> wrote:
> * Pascal Molin [2015-01-20 11:39]:
>> What suprises me is that the moduli is removed in the result.
>>
>> Over Z I run through this issue every year with students and they
>> understood well that
>> the result is the only sensible one (2+3\Z) + (5+2\Z) = \Z
>> and gp gives Mod(2,3) + Mod(5,2) = Mod(0,1)
>
> The moduli is not removed, but indeed not printed:
>
> (11:42) gp > Mod(0,x)
> %1 = 0
> (11:43) gp > dbg_x(%)  \\ clearly a t_POLMOD
> [&=0000000000b7cb00] POLMOD(lg=3,CLONE):1300000000000003 0000000000b7cb50 0000000000b7cb18
>   mod = [&=0000000000b7cb50] POL(lg=4):1400000000000004 (+,varn=0):4000000000000000 0000000000b7cb40 0000000000b7cb28
>     coef of degree 0 = [&=0000000000b7cb40] INT(lg=2):0200000000000002 (0,lgefint=2):0000000000000002
>     coef of degree 1 = [&=0000000000b7cb28] INT(lg=3):0200000000000003 (+,lgefint=3):4000000000000003 0000000000000001
>   pol = [&=0000000000b7cb18] INT(lg=2):0200000000000002 (0,lgefint=2):0000000000000002
>
> A 0 t_POLMOD is printed as 0 and omitted in polynomial coefficients.
> For t_INTMOD, 0 is still explicitly written as Mod(0, N) [ but still omitted
> when a polynomial coefficient ]
>
> I don't see any rationale for this. I can fix the discrepancy, and
> explicitly write Mod(0, x) above instead of 0.

I think it has been true for ever that gp display just 0 for any exact
0 of any type.  Usually that is fine;  here is can cause confusion, at
least for beginners.

I would be happy with Mod(0,x) displaying as such for any x, as long
as something like

? (1+x^100) * Mod(1,19)
%3 = Mod(1, 19)*x^100 + Mod(1, 19)

does not display all the terms with coefficient Mod(0,19)!

John

>
> 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 69 50
> 351, cours de la Liberation    http://www.math.u-bordeaux1.fr/~kbelabas/
> F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]
> `
>