Re: Re: [Maxima] gcd(m,n) for integer



hi Richard

thank you for your comments.

> 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.

I agree this. It seems good that gcd is the gcd and an integerGCD.
But there are many problems in mathematics which we can write 
with some rules insted of using a function.such as functor at category. I add tama1 ,tama2,so on to My peculiar tama.
that is my intention.

(%i15) defrule(tama1,sgcd(m,n),if is(n=m) then print(n) else sgcd(m,n))$
(%i16) defrule(tama2,sgcd(m,n),if is(1=n) or is(1=m) then print(1) else sgcd(m,n))$ 
(%i20) apply1(sgcd(x,x),tama,tama1,tama2);
x 
(%o20)                                 x
(%i21) apply1(sgcd(x,1),tama,tama1,tama2);
1 
(%o21)                                 1

With this style we can write rule based math beyond
the problem of verb or noun.
I think that We need to use a peculiar style  that caused  the infinit evaluation for the purpse of overcomming the problem of
verb or noun.


> 
> 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).

this function is fine but to add integerGCD(n,n)--->n is 
difficult for me.

gosei

> 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
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>