Thanks. Roger is correct, and generous, in describing the original as an easter egg. Among the numerous ways I tried to make APL convenient for humans at the expense of computer effort, 3 %: _8 was my favorite. I think it was an article in the IBM systems journal, "Algorithm for a gear-train problem" by H. G. ApSimon, that introduced me to the delight of using continued fractions to generate best rational approximations. As a longtime fan of looking at fields of orchard stakes from a speeding car, I couldn't rest until I'd made some use of the technique.
Larry At 09:12 -0700 2009/06/24, Joey K Tuttle wrote: >Larry, > > Thought you might find it interesting since you are mentioned. > >- joey > >>Date: Wed, 24 Jun 2009 07:46:13 -0700 >>From: Roger Hui <[email protected]> >>To: Programming forum <[email protected]> >>Subject: Re: [Jprogramming] Which branch of the root? >> >>Quite right (what Cliff says). The root produced >>by the interpreter is per the branch cut and is >>the "principal root". An additional property >>preserved by giving the principal root is >>(x %: y) = ^ x%~^.y , and in general >>(x ^ y) = ^ y*^.x >> >> 3 %: _8 >>1j1.73205 >> ^ 3 %~ ^. _8 >>1j1.73205 >> >>Historically, _8^%3 in APL gives _2 as the answer. >>But is this in violation of the 2001 ISO Standard >>on Extended APL. I consider the _2 answer as >>an "Easter egg" tour de force by the original >>implementers (principally Larry Breed): >>For x^y where x is negative, assume y is >>positive. (For negative y, replace x by %x >>and y by -y.) The system computes a rational >>approximation of y of integers m and n with >>1=gcd(m,n) . If n is even, signal domain error; >>if n is odd, x^y is the real number (x^m)^%n . >> >> >> >>----- Original Message ----- >>From: Cliff Reiter <[email protected]> >>Date: Wednesday, June 24, 2009 5:28 >>Subject: Re: [Jprogramming] Which branch of the root? >>To: Programming forum <[email protected]> >> >>> NB. all roots >>> p. 8 0 0 1 >>> +-+-----------------------+ >>> |1|1j1.73205 1j_1.73205 _2| >>> +-+-----------------------+ >>> >>> NB. Branch cut along neg real axis is standard I think >>> NB. discontinuous near neg real axis >>> 3 %: _8+j.1e_12 >>> 1j1.73205 >>> 3 %: _8-j.1e_12 >>> 1j_1.73205 >>> >>> NB. Continuous on positive real >>> 3 %: 8+j.1e_12 >>> 2j8.33333e_14 >>> 3 %: 8-j.1e_12 >>> 2j_8.33333e_14 >>> >>> NB. probably better (no different) to think about exponential >>> _8^1r3 >>> 1j1.73205 >>> >>> Ed Keith wrote: >>> > I type "3 %: _8" into J and was surprised when I got >>> "1j1.73205". I realize this is technically correct, but when I >>> type "3 %: 8" I get "2", not "_1j1.73205". >>> > >>> > How does J decide which branch of the root to give? Is there >>> away to influence its decision? Is there a way to generate all roots? >>> > >>> > -EdK >>---------------------------------------------------------------------- >>For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
