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
q=.<.r0%r1
r2=.r0-r1*q
while. r2~:0 do.
   'r0 r1'=.r1,r2
   q=.<.r0%r1
   r2=.r0-r1*q
end.
r1
)
    21 (+.,gcd) 70
7 7
    1r4 (+.,gcd) 3r4
1r4 1r4
    1p1 (+.,gcd) 1r4p1
0.785398 0.785398
    1r4p1
0.785398
    1p1 (+.,gcd) 1x1
5.3868e_13 4.44089e_16
    ]ct=:9!:18''
5.68434e_14


On 7/24/2011 6:27 PM, Boyko Bantchev wrote:
> The +. verb computes the `GCD' of all kinds of numbers known to
> J, but the corresponding page of the DoJ does not say what exactly
> +.  produces.  As there is no standard definition of GCD for
> floating-point or complex numbers in mathematics, +. seems to be
> underspecified.  Moreover, the text
>
>      `The greatest common divisor divides both of its arguments x
>      and y to produce results that have no common factor, that is,
>      the GCD of the quotients is 1.  Moreover, these quotients
>      represent the fraction x%y in lowest form.'
>
> seems to suggest only integer arguments.  For example,
>      `the GCD of the quotients is 1'
> apparently does not hold for many reals.
>
> So, what does +. compute?
> (I can imagine several definitions, but I am curious what the actual one is.)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>

-- 
Clifford A. Reiter
Lafayette College, Easton, PA 18042
http://webbox.lafayette.edu/~reiterc/

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

Reply via email to