gcd(m,n) for integer



go_furuya@infoseek.jp wrote:

> hi 
> Stavros and all
> 
> at 2003 jun,we discussed gcd(m,n) concerning about Z homology.
> Carl Mactague said
> 
>>in math'a [or Gcd(m,n) in yacas] and m and n aren't bound, then
>>GCD[m,n] simply remains unaltered wherever it appears.  But in Maxima
>>(and perhaps this is really just a poor implementation of GCD and not
>>a critique of the Maxima evaluation scheme in general) you get
>>GCD(m,n) => 1!  

Treated as polynomials in the indeterminates m,n  the gcd of the two
polynomials  m   and   n   is correctly 1.  That is, there is no
other polynomial other than 1  that exactly divides the polynomial n and
the polynomial m.


If you want to write a program with a different meaning, then I
suggest you change the name.  If I understand what you want, then
integerGCD(m,n):= if integerp(m) and integerp(n) then gcd(m,n) else 'gcd(m,n).

or some such thing.  Do you always print something? The rule tama looks
peculiar.


These sorts of barbs seem to arise quite often when I
>>use Maxima and they mess up all kinds of boundary conditions.
> 
> 
> What do you think this way?
> I use a rule evaled infinitly,but controled by maxapplydepth.
>  
> (%i2) matchdeclare([m,n],true)$
> (%i13) defrule(tama,sgcd(m,n),if integerp(m) and integerp(n) then
> print(gcd(m,n)) else sgcd(m,n))$
> (%i4) maxapplydepth:2;
> (%o4)                                  2
> (%i5) apply1(sgcd(2,4),tama);
> 2 
> (%o5)                                 2
> (%i6) apply1(sgcd(n1,n2),tama);
> (%o6)                           sgcd(n1, n2)
> (%i7) apply1(sin(sgcd(2,4)),tama);
> 2 
> (%o7)                              SIN(2)
> (%i8) tgcd(_m,_n):=apply1(sgcd(_m,_n),tama)$ 
> (%i9) sin(tgcd(x,y));
> (%o9)                          SIN(sgcd(x, y))
> (%i10) sin(tgcd(5+3,6!));
> 8 
> (%o10)                 SIN(8)
> 
> I think that
> to control infinit loop with maxapplydepth makes us get ride 
> of the barbs which Carl said about Maxima.
> 
> gosei
> 
> 
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima