Comparisons with 0 are exact and can lead to undesirable results
(your version of gcd):

   0.07 gcd"0 ] 10^i.6
0.01 5.55112e_17 5.55112e_17 1.72085e_15 5.55112e_17 5.55112e_17

Ameliorated through the use of exact numbers:

   7r100 gcd"0 ] 10x^i.6
1r100 1r100 1r100 1r100 1r100 1r100



----- Original Message -----
From: Boyko Bantchev <[email protected]>
Date: Tuesday, July 26, 2011 15:12
Subject: Re: [Jprogramming] definition of +.
To: Programming forum <[email protected]>

> On 26 July 2011 15:00, Cliff Reiter <[email protected]> wrote:
> > Consider the Euclidean model for gcd. It appears to model +.
> > reasonably for (positive) nice numbers. It nears comparison 
> tolerance> for naughty numbers.
> > Best, Cliff
> >
> >    gcd=:4 : 0
> > r0=.x
> > r1=.y
> > ......................
> 
> As the use of <. is incorporated in | (residue), a somewhat 
> simpler definition
> of the Euclidean gcd suffices:
> 
> gcd=. 4 : 0
>   while. 0~:y do.  'x y'=. y,y|x end.
>   x
> )
> 
> However, there are more interesting points to consider.
> 
> -- What is the meaning (in GCD) of the word `greatest' when the
>    arguments are complex numbers? (Perhaps `greatest' 
> then is
>    related to the magnitude of the complex number, but 
> then there
>    may not be a unique `greatest' number.)
> 
> -- Is the above model of GCD the one implemented in +.?  Is this
>    the only reasonable model?  In particular, 
> what if the notions of
>    `integer quotient' and `residue' -- and therefore 
> of GCD -- are
>    based not on <. but something else?
> 
> -- What properties does +. exhibit for complex (even integer or 
> rational)   and floating-point arguments? (And through 
> this, what are the valuable
>    uses of GCD with such arguments?)
> 
> The article of Eugene McDonnell that Roger referred to only considers
> part of these questions.  A more detailed study of the 
> field is:
> 
> http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.47.1389

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to