2 0 3&p. is a quadratic polynomial with two roots.  The multivalued
inverse won't work as a j obverse.  The wikipedia "square root" entry
justifies the j definition of %: which returns 1 value, "Although the
principal square root of a positive number is only one of its two square
roots, the designation "the square root" is often used to refer to the
principal square root."

   square =: 0 0 1&p.
   
   (*: -: square) ((%~ i.) , ?~)8
1

   square b. _1  NB. just right
|domain error
|       square b._1
   
   *: b. _1      NB. just right
%:

   %: *: _1      NB. obverse is not inverse
1


> From: "Linda Alvord" <[email protected]>
> To: <[email protected]>
> Subject: Re: [Jprogramming] Basic Mystery
> Message-ID: <000701ce0907$458e0740$d0aa15c0$@net>
> Content-Type: text/plain; charset=US-ASCII
> 
>  Although  g  and  h  both produce  y  correctly,  h  can't be used
> with  b.
> and ^:_1
> 
>     g=: 2+3**:
>    ]y=: g 5
> 77
>    h=: 13 : '2 0 3  p. 


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

Reply via email to