Raul Miller <rauldmil...@gmail.com> wrote: > > Residue gives the same. > > > > ? 5#:0j1+i.9 > > 0j1 1j1 2j1 _2j1 _1j1 0j1 1j1 2j1 _2j1 > > And that is probably what is going on here. > > Residue is defined to be using floor: > > The definition y-x*<. y % x+0=x extends the residue... > > http://www.jsoftware.com/help/dictionary/d230.htm > > And complex floor is the root issue here.
It shouldn't really, as the floor returns consistently nonnegative results: <. 0j1+i.9 0j1 1j1 2j1 3j1 4j1 5j1 6j1 7j1 8j1 Even so, I get three different behaviors, depending on which residue algorithm is involved: 9!:14'' j602/2008-03-03/16:45 J interpreter: 5 | 0j1+i.9 0j1 1j1 2j1 _2j1 _1j1 0j1 1j1 2j1 _2j1 Dictionary definition of residue Note that while dictionary gives this algorithm to extend residue to negative and fractional finite arguments, it does not say this applies to complex ones: res =: 4 : 'y-x*<. y % x+0=x' 5 res 0j1+i.9 0j1 1j1 2j1 3j1 _1j1 0j1 1j1 2j1 3j1 Residue model from Roger Hui in forum email dated Mon, 18 Apr 2005, commenting on a reported bug in complex residue, explaining that the model (residue=: dyad :'y. - x.*<.y.%x.'"0) is incorrect: rem=: 4 : 0 " 0 if. 0=x do. y return. end. q=. y%x s=. >. q t=. <. q (s~:t)*y-x*t ) 5 rem 0j1+i.9 0j1 1j1 2j1 3j1 0 0j1 1j1 2j1 3j1 (I recall that in later years, Roger gave another more compact model for residue; unfortunately, I can't remember when it was posted, but it seemed to produce the same results as the one above.) >From same email, Roger's proof that his algorithm was the same as residue: (|/~ -: rem/~) j./~i.4 1 But now it produces 0. I also tried this on several earlier versions. The interpreter produces two negative results in 6.02, but all nonnegative in 6.01c, 5.04b and 4.06d (like rem). However, all four interpreters produce identical results for <. rem and res. So something changed in the interpreter implementation of residue between 6.01c and 6.02. -- Mark D. Niemiec <mniem...@gmail.com> ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm