Ewan Delanoy on Mon, 24 Sep 2012 15:45:22 +0200

 How to overcome limitations on variable names in PARI-GP

Hello all,

I found some functions in GP work fine when x is the variable, go berserk when a is used instead of x, and provide a shorter (but still incorrect) output when I try to fix this by using the subset function.
I believe the code below is self-explanatory, any help appreciated.

Ewan

GP/PARI CALCULATOR Version 2.5.2 (released)
i386 running darwin (x86-64/GMP-5.0.4 kernel) 64-bit version
compiled: Sep 18 2012, gcc-4.5.4 (MacPorts gcc45 4.5.4_5)
(readline v6.2 enabled, extended help enabled)

Copyright (C) 2000-2011 The PARI Group

PARI/GP is free software, covered by the GNU General Public License, and comes WITHOUT ANY WARRANTY WHATSOEVER.

Type ? for help, \q to quit.
Type ?12 for how to get moral (and possibly technical) support.

parisize = 8000000, primelimit = 500509
?
? polinv(pol1,pol2,var)=(bezout(pol1,pol2)[1])*polresultant(pol1,pol2,var)
%1 = (pol1,pol2,var)->(bezout(pol1,pol2)[1])*polresultant(pol1,pol2,var)
?
? proposer=(-282*a^3 - 280*a)*x + (285*a^4 - 85*a^2 - 300)
%2 = (-282*a^3 - 280*a)*x + (285*a^4 - 85*a^2 - 300)
?
? modulus=x^2 - 6*a*x + (5*a^2 - 5)
%3 = x^2 - 6*a*x + (5*a^2 - 5)
?
? trial1=polinv(proposer,modulus,x)
%4 = (282*a^3 + 280*a)*x + (-1407*a^4 - 1765*a^2 - 300)
?
? /*the result above is correct. Now see what happens when we replace x with a : */
?
? proposer=(-282*a^3 - 280*a)*b + (285*a^4 - 85*a^2 - 300)
%5 = 285*a^4 - 282*b*a^3 - 85*a^2 - 280*b*a - 300
?
? modulus=b^2 - 6*a*b + (5*a^2 - 5)
%6 = 5*a^2 - 6*b*a + (b^2 - 5)
?
? trial2=polinv(proposer,modulus,b)
%7 = ((101250*b^3 + 337500*b)/(-27*b^8 - 450*b^6 - 1275*b^4 + 11000*b^2 + 50000))*a^9 + ((-70875*b^2 - 337500)/(-27*b^6 - 585*b^4 - 4200*b^2 - 10000))*a^8 + ((-256500*b^3 - 855000*b)/(-27*b^8 - 450*b^6 - 1275*b^4 + 11000*b^2 + 50000))*a^7 + ((179550*b^2 + 855000)/(-27*b^6 - 585*b^4 - 4200*b^2 - 10000))*a^6 + ((-2670750*b^3 - 8902500*b)/(-27*b^8 - 450*b^6 - 1275*b^4 + 11000*b^2 + 50000))*a^5 + ((1869525*b^2 + 8902500)/(-27*b^6 - 585*b^4 - 4200*b^2 - 10000))*a^4 + ((-4890000*b^3 - 16300000*b)/(-27*b^8 - 450*b^6 - 1275*b^4 + 11000*b^2 + 50000))*a^3 + ((3423000*b^2 + 16300000)/(-27*b^6 - 585*b^4 - 4200*b^2 - 10000))*a^2 + ((-2700000*b^3 - 9000000*b)/(-27*b^8 - 450*b^6 - 1275*b^4 + 11000*b^2 + 50000))*a + ((1890000*b^2 + 9000000)/(-27*b^6 - 585*b^4 - 4200*b^2 - 10000))
?
? /* Quite ugly, huh ? Perhaps we can improve the function*/
?
?
? polinv_again(paul1,paul2,var)=
{
bowl1=subst(paul1,var,x);
bowl2=subst(paul2,var,x);