Dan Bron wrote:
> Can you now explain why I was taught, in elementary math, to express
> %:4  as  (+,-)2  instead of just  2  ?

You were being taught about the relationship between the set 2 _2,
the concept of "square root" and the number 4.

J's %: is a function, it's not the concept "square root".

Of course, if you want both of the values which are valid square
roots, J allows you to express this unambiguously:
  (,-)@%: 4

But note that (+,-)%: is not quite right.  Consider
   *:(+,-)%:1j1
1j_1 1j1

Then again, in most contexts it's far more useful to have
a result with exactly the same shape as the argument than it
is to have two values (one of which is trivially derived from
the other) mixed together.

> If I have to write  (%:4) = (+,-)2   why do I not have to write
>   (^._1) = 0 j. 1p1 * 1 + 2 * i: _  ?  Is it because  the former
> has only 2 elements, but the latter infinitely many? 

I do not understand the above question.  In my opinion, you do
not have to write (%:4) = (+,-)2 so the rest of the question
makes no sense to me.

> By the way, I'm pretty sure  0 j. 1p1 * 1 + 2 * i: N 
> (scalar positive integer  N )  is the right expression for
> generating for the logs of  _1  but J doesn't agree:

   ^0 j. 1p1*1+2*i:3
_1 _1 _1 _1 _1 _1 _1

Looks right to me.

Of course, for large values of N, you start running into the
limits of precision expressible using floating point numbers,
so you get numbers which are "nearly 1, but not quite".

-- 
Raul

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

Reply via email to