On Sun, Aug 24, 2014 at 6:43 AM, [email protected] <[email protected]> wrote: > I continue to be puzzled by the poor performance of something > like add32/\ compared to +/\ .
The answer, here, can be explained in terms of an issue which I remember being taught in gradeschool - "the associative law". (Of course, most gradeschool students are not sufficiently terrified or interested or whatever it takes, to retain an interest in such things.) u/\ 1 2 3 4 is 1, (1 u 2), (1 u (2 u 3)), (1 u (2 u (3 u 4))) + is known to be associative, so +/\ rearranges the order of computation, and instead computes this sequence: 1, (1+2), ((1+2)+3), (((1+2)+3)+4) Note also that with floating point numbers addition is in some cases just an approximation, so it's possible to construct a sequence of numbers which reveals this issue. Thanks, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
