infinite loop on gcd()



I pretty much got used to switching gcd to spmod for large calculations.
I've been meaning to ask, why does gcd default to subres (with all the bugs)
instead of the apparently far more reliable spmod algorithm?


Viktor


 

-----Original Message-----
From: maxima-admin@math.utexas.edu [mailto:maxima-admin at math] On
Behalf Of Barton Willis
Sent: Tuesday, May 10, 2005 4:42 PM
To: laurent couraud
Cc: maxima@math.utexas.edu
Subject: Re: [Maxima] infinite loop on gcd()

The default gcd algorithm  is known to have bugs.  Re do your
calculation with gcd : 'spmod.   When I tried this, gcd returned 1 
almost immediately.

(%i27) fullratsimp(f2*f3*f4*f5);
(%O27) 
(W1^3*W2^2-W1^5)*W5^4+((W1^4*W2-2*W1^2*W2^3)*W4+(W1*W2^4-4*W1^3*W2^2+4*W1^5)
*W3)*W5^3+
((W1*W2^4+W1^3*W2^2)*W4^2+(-W2^5+5*W1^2*W2^3-5*W1^4*W2)*W3*W4+(-W1*W2^4+3*W1
^3*W2^2-3*W1^5)*W3^2)*W5^2+
(-W1^2*W2^3*W4^3-W1*W2^4*W3*W4^2+(2*W2^5-7*W1^2*W2^3+8*W1^4*W2)*W3^2*W4+(-W1
*W2^4+4*W1^3*W2^2-4*W1^5)*W3^3)*W5
+W1^2*W2^3*W3*W4^3-W1^3*W2^2*W3^2*W4^2+(-W2^5+4*W1^2*W2^3-4*W1^4*W2)*W3^3*W4
+(W1*W2^4-4*W1^3*W2^2+4*W1^5)*W3^4
(%i28) gcd : 'spmod;
(%O28) SPMOD
(%i29) gcd(g1,fullratsimp(f2*f3*f4*f5));
(%O29) 1

Barton

maxima-admin@math.utexas.edu wrote on 05/10/2005 03:18:22 PM:

> Hello all,
> 
> Sorry, but this is the smallest expression that I found actually on 
which
> Maxima gcd() function have infinite loop.
> 
> To find it I wrote this batch file:
> 
> ttyoff:true;
> f1:w1;
> 
> f2:w5-w3;
> 
> f3:w1*w5-w2*w4+w1*w3;
> 
> f4:w1^2*w5-w1*w2*w4+w2^2*w3-2*w1^2*w3;
> 
> f5:w2^2*w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1,fullratsimp(f1*f2));
> gcd(g1,fullratsimp(f1*f3));
> gcd(g1,fullratsimp(f1*f4));
> gcd(g1,fullratsimp(f1*f5));
> gcd(g1,fullratsimp(f2*f3));
> gcd(g1,fullratsimp(f2*f4));
> gcd(g1,fullratsimp(f2*f5));
> gcd(g1,fullratsimp(f3*f4));
> gcd(g1,fullratsimp(f3*f5));
> gcd(g1,fullratsimp(f4*f5));
> gcd(g1,fullratsimp(f1*f2*f3));
> gcd(g1,fullratsimp(f1*f2*f4));
> gcd(g1,fullratsimp(f1*f2*f5));
> gcd(g1,fullratsimp(f1*f3*f4));
> gcd(g1,fullratsimp(f1*f3*f5));
> gcd(g1,fullratsimp(f1*f4*f5));
> gcd(g1,fullratsimp(f2*f3*f4));
> gcd(g1,fullratsimp(f2*f3*f5));
> gcd(g1,fullratsimp(f2*f4*f5));
> gcd(g1,fullratsimp(f3*f4*f5));
> gcd(g1,fullratsimp(f1*f2*f3*f4));
> gcd(g1,fullratsimp(f1*f2*f3*f5));
> gcd(g1,fullratsimp(f1*f2*f4*f5));
> gcd(g1,fullratsimp(f1*f3*f4*f5));
> gcd(g1,fullratsimp(f2*f3*f4*f5));
> :lisp (room)
> 
> The last gcd call has an infinite loop.
> 
> I will tries to find a smaller g1 expression if I can in the first step.
> If I can't, maybe I will write a "random polynomials generator"
> 
> Laurent
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima

_______________________________________________
Maxima mailing list
Maxima@www.math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima