Michael Stoll on Sun, 26 Apr 1998 22:19:10 +0200


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

issquare


More strange behaviour:

gp (22:07)> issquare(x^2)
  ***   division by zero in gdiv, gdivgs or ginv
gp (22:07)> issquarefree(x^2)
%111 = 0
gp (22:09)> issquare(x^2+1)
%112 = 0
gp (22:09)> issquare(x^2+x)
  ***   division by zero in gdiv, gdivgs or ginv

Line 537-545 in arith2.c:

    case t_POL:
      if (!signe(x)) return gun;
      l=lgef(x)-3; if (l&1) return gzero;
      av=avma; p2=(GEN)x[2];
      if (!signe(gcarreparfait(p2))) return gzero;
      p1 = gdiv(gadd(x,ggrando(polx[varn(x)],l+1)),p2);  // <--- here !
      p1 = gtrunc(gsqrt(p1,DEFAULTPREC));
      v=gegal(gmul(p2,gsqr(p1)), x); avma=av; return v?gun:gzero;

Here a check if the constant term is zero should be inserted. More
precisely, if it is zero, check if the first non-zero term occurs
with even exponent, if so, divide by this term, etc.

Michael