Dear I. Berna,
as your output shows,
Code:
out of memory in vector::SetLength()
Singular : signal 6 (v: 3040/2007112211):
Segment fault/Bus error occurred at 83f8da1 because of 0 (r:1274263428)
please inform the authors
you are using an old version Singular 3-0-4 dating from 2007.
So upgrade to Singular-3-1-1; it you are working with LINUX go there:
http://www.mathematik.uni-kl.de/ftp/pub ... ular/UNIX/The crash, which you report here, does not occur in Singular 3-1-1,
so I will not trace the bug.
But with your code there is the problem that it may run into an infinite loop
if one is calling it with coprime multivariate polynomials.
Code:
ring R=(0,s), (a,r,u(1..4)), dp;
poly pr1=r3-2r2+r-1; // univariate in r
poly qr1 =diff(pr1,r);
poly pr2=48r3-84r2+42r-(36+s); // univariate in r, with parameter s
poly qr2 =diff(pr2,r);
poly pr3=-r^3+r^2-s*r+u(1)*s+u(2); // mulivar. variables r, u(1),u(2), param. s
poly qr3 =diff(pr3,r);
proc bergcd(poly divisor,poly resto)
{
poly dividendo, mcd;
poly pr,qr = divisor,resto; // store the input
while (resto<>0)
{
dividendo=divisor;
divisor=resto;
resto=reduce(dividendo,std(divisor));
"resto =",resto;
"deg(resto)= ", deg(resto);
"------------------";
division(dividendo,divisor);
read("");
}
mcd=divisor;
"Entrega el mcd entre", pr, "y", qr ," es ", mcd;
return(mcd);
}
Press continously RETURN, and finally press CTRL-C in the third example.
Code:
> bergcd(pr1,qr1);
Entrega el mcd entre r^3-2*r^2+r-1 y 3*r^2-4*r+1 es 207/4
> bergcd(pr2,qr2);
Entrega el mcd entre 48*r^3-84*r^2+42*r+(-s-36) y 144*r^2-168*r+42 es (324/49*s^2+19800/49*s+302157/49)
> bergcd(pr3,qr3);
// ..... periodic loop of length 2.
// CTR-C a (abort)
For the polynomials pr3,qr3, the rest is again a polynomial in the
variables u(1),u(2). So degree does not drop and the loop does not termiante.
See also
Code:
> ring rxy =0,(x,y),dp;
> poly f = (x+y+1)^2*(x2-y2);
> gcd(f,x+y);
x+y
> bergcd(f,x+y); // OK
x+y
> gcd(f,x+y+1);
x+y+1
> bergcd(f,x+y+1); // OK
x+y+1
// But for coprime multivariate, there is a difference.
> gcd(f,x+y+2);
1
> bergcd(f,x+y+2); // does not terminate
........
Summary:
Use Singular's
gcd, if you want to compute the gcd of multivariate polynomials,
and instead
reduce you may call
divsion ---
Christian Gorzel