Michael Somos on Tue, 4 Sep 2001 17:06:56 -0400


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

addfrac() + Karatsuba = bug


The following indicates a problem with 'addfrac()' which interacts
badly with the Karatsuba multiplication in the kernel. It only acts
up when the numbers get big enough for Karatsuba to kick in. It is
there in CVS 2.2.1 a few weeks ago. I suggest making the Karatsuba
threshold a 'default()' settable parameter for user convenience.

parisize = 4000000, primelimit = 500000
? add(v1,v2)=[v1[1]*v2[2]+v1[2]*v2[1],v1[2]*v2[2]]
? equ(v1,v2)=v1[1]*v2[2]==v1[2]*v2[1]
? frv(x)=[numerator(x),denominator(x)]
? tst(x1,x2)=equ(frv(x1+x2),add(frv(x1),frv(x2)))
? rn()=random(N)
? doit(x,n)=
{
N=x;for(i=1,n,
n0=1+rn;n1=rn;n2=(1+rn)*n0;n3=rn;n4=(1+rn)*n0;print1(tst(n1/n2,n3/n4)))
}
? doit(10^241,10)
1011101101
? \v
                  GP/PARI CALCULATOR Version 2.1.0 (released)
                i686 running linux (ix86 kernel) 32-bit version
                (readline v2.2 enabled, extended help available)

Shalom, Michael