Re: [Jprogramming] Replace Items

2016-03-09 Thread Ben Gorte - CITG
I'm afraid I don't know how do this tacitly ...

   ritem =: 1 : (':' ; 'x (I.m-:"_1 _ y) } m')

   (2 4$0) (i.3 2 4) ritem 16+i.2 4
   'a' 'P&' ritem '&'

... but m is in its place and it doesn't box.
 
Ben

From: Programming [programming-boun...@forums.jsoftware.com] on behalf of 
Pascal Jasmin [godspiral2...@yahoo.ca]
Sent: Thursday, March 10, 2016 00:57
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Replace Items

moving around the m term to be the "searched".  There's probably a better 
version that doesn't box.


ritem =: 1 : '(m -:"_ _1 ]) >@:({"0 1)  (,&<~"_ _1)'
(2 4 $ 0) (16+i.2 4) ritem i. 3 2 4



- Original Message -
From: Kip Murray 
To: "programm...@jsoftware.com" 
Sent: Wednesday, March 9, 2016 5:26 PM
Subject: [Jprogramming] Replace Items

Adverb  ritem  creates a verb which replaces by  x  items in array  m  that
match  y

Below are examples.  How would you write the adverb?  --Kip Murray


C
0 1 2 3
4 5 6 7
0 1 2 3
0 0 0 0 C ritem 0 1 2 3
0 0 0 0
4 5 6 7
0 0 0 0
A
  0  1  2  3
  4  5  6  7

  8  9 10 11
12 13 14 15

16 17 18 19
20 21 22 23
(2 4 $ 0) A ritem 16+i.2 4
  0  1  2  3
  4  5  6  7

  8  9 10 11
12 13 14 15

  0  0  0  0
  0  0  0  0




--
Sent from Gmail Mobile
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] ipad j: html

2016-03-09 Thread Brian Schott
Ok, I suspect there is no way to do that cgi form on the iPad,
but while playing with my iPad I discovered the following phrase will produce 
the standard box characters: ┌┬┐├┼┤└┴┘│─
This at least makes boxed results look nicer.

9!:7]11 {. 16}. 2 u: a.

---
(B=)

> On Mar 8, 2016, at 11:48 PM, Brian Schott  wrote:
> 
> The ipad version of J has some nice examples using the verb jh, which embeds 
> the verb jy, of producing html output in its html window. Does anyone know 
> how to put a simple  in that window (with buttons and menus, for 
> example), that will send info to the J session?
> 
> Thanks,
> 
> -- 
> (B=)
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] A plane rotation

2016-03-09 Thread Kip Murray
Verbs ff , gg , and (gg mab) below represent straight lines.  If one of
them is evaluated at a real number t the result is a point on the
represented line.  I calculated three points on each represented line as a
kind of substitute for graphing the line, and to let you see how the
y-coordinates (imaginary parts) were related to the x-coordinates (real
parts).  For me the "results" are the verbs themselves, not the points
calculated from them!  Here is another example

hh =: _1j0 1j1 line   NB. line with start _1j0 , direction 1j1
hh"0 [ 0 1 2   NB. three points on the line
 _1j0 0j1 1j2
jj =: hh rot 1r4p1 _1j1  NB. rotate line 1r4p1 radians about _1j1
jj"0 [ _1 0 1  NB.  three points show result is vertical line x = _1 +
%: 0.5
 _0.2928932188j_1.121320344 _0.2928932188j0.2928932188
_0.2928932188j1.707106781

--Kip Murray

On Wednesday, March 9, 2016, Don Kelly  wrote:

> A question- you give you define the line and the center of rotation but
> the results are 3 points on the line. shouldn't the results be shown in
> terms of 2 points on the rotated line?  While usually the line is expressed
> as y=a+bx (a and b real)  which is easy if the the rotation center is on
> the line at x =0.
> new end =. (r.theta) +end  as start is not changed.
> A bigger challenge is to have a rotation center that is not on the
> original line and given points that do not fit the typical y=a+bx
> Example: line ends at  2j3j5 and 3j4  to be rotated about 1j2
> this involves a rotation  of two vectors (1j1 and3j4 )  as seen from 1j2
> about "0"  and then a translation of 1j2
>
> rotheta=:[: +. ([: r. [) * [: +.^:_1 ]
>
> 1j2+ (_1r4p1) rotheta 1j1 2j2
>
> 2.41421j2 3.82843j2 which is the location of the
> points after rotation
> This can then be put into a y=a+bx form with a =2 and b=1.414..
>
>
> Don
>
>
> On 2/20/2016 2:14 PM, Kip Murray wrote:
>
>> Here after a struggle are my linrot results.
>>
>> NB. rotate a line in the plane about a point in the plane
>>
>> NB. here points are complex numbers
>>
>> NB. below start and direction are complex numbers, could be vectors
>>
>> NB. (start,direction) line t  is  start + t * direction
>>
>> line =: 1 : '({. m) + ({: m) * ]'
>>
>> mab =: 1 : '( (u 0) , (% 9) (u 1) - u 0 ) line' NB. point slope
>> version of u
>>
>> NB. below u rot (theta,center) rotates results of u by theta radians
>> about the center
>> NB. it is assumed the results of u and the center are complex numbers
>>
>> rot =: 2 : '[: r.&({. n)&.(({: n) -~ ]) u'
>>
>> ff =: 0j1 1j1 lineNB. line starts at 0j1 goes in direction of
>> 1j1
>>
>> ff"0 [ 0 1 2  NB. Notice y = x + 1
>> 0j1 1j2 2j3
>>
>> gg =: ff rot _1r4p1 0j1   NB. rotates ff results 45 degees clockwise
>> about 0j1
>>
>> gg"0 [ 0 1 2  NB. horizontal (y's are all 1)
>> 0j1 1.414213562j1 2.828427125j1
>>
>> (gg mab)"0 [ 0 1 2.   NB. results x j. y from point slope y = 1 +
>> 0*(x - 0)
>> 0j1 1j1 2j1
>>
>> --Kip
>>
>> On Thursday, February 18, 2016, Louis de Forcrand 
>> wrote:
>>
>> To continue with the rotation challenges, write a verb that rotates a
>>> linear
>>> polynomial (coeffs in x) by 0 {:: y with a centre of 1 {:: y:
>>>
>>> 1 2 linrot 1p1 ; 0 1
>>> 1 2
>>> 1 2 linrot 1r2p1 ; 0 1
>>> 1 _0.5
>>> 1 2 linrot 1p1;1 1
>>> _3 2
>>>
>>> My take:
>>> linrot=: ({: %. 1 ,. {.)@rotposmat
>>>   rotposmat=: centre + j./@posmat |:@:+.@:* r.@angle
>>>centre=: 1&({::)@]
>>>posmat=: (] ,: p.)&0 1@[ - centre
>>>angle=: 0&({::)@]
>>>
>>> It uses matrix division on a rotated set of two points from the original
>>> polynomial. Not very elegant, but I’m pretty sure it works.
>>>
>>> Best regards,
>>> Louis
>>>
>>> On 17 Feb 2016, at 06:40, Kip Murray >> > wrote:
>>>
 Not bad.  I didn't know about r.  .  For clean I use

 clean =: (* *!.1e_14@|)"0&.+.

 --Kip

 On Tuesday, February 16, 2016, Raul Miller >>  >> wrote:
>>>
 Well...
>
>rottheta=: (rot~ r.)~
>1r2p1 rottheta 3 4
> _4 3
>1r4p1 rottheta _1 1
> _1.41421 1.11022e_16
>
> I remember there being a concise phrase to clean irrelevant bits near
> zero in a complex number, but I can't remember what I need to search
> on to find it, and my foggy memory of how to write it is failing me at
> the moment.
>
> Still, this gets you close.
>
> --
> Raul
>
>
> On Tue, Feb 16, 2016 at 11:50 PM, Kip Murray 
 
>>>
 > wrote:
>
>> I'm retired with time to "fool around".  Finding an old rot90 verb
>> that
>> used multiplication by a 2 by 2 matrix, I sought a more direct way
>>
> using
>>>
 complex numbers and found one of 

Re: [Jprogramming] Replace Items

2016-03-09 Thread Kip Murray
This is much simpler than my version.  --Kip

On Wednesday, March 9, 2016, Pascal Jasmin  wrote:

> moving around the m term to be the "searched".  There's probably a better
> version that doesn't box.
>
>
> ritem =: 1 : '(m -:"_ _1 ]) >@:({"0 1)  (,&<~"_ _1)'
> (2 4 $ 0) (16+i.2 4) ritem i. 3 2 4
>
>
>
> - Original Message -
> From: Kip Murray >
> To: "programm...@jsoftware.com "  >
> Sent: Wednesday, March 9, 2016 5:26 PM
> Subject: [Jprogramming] Replace Items
>
> Adverb  ritem  creates a verb which replaces by  x  items in array  m  that
> match  y
>
> Below are examples.  How would you write the adverb?  --Kip Murray
>
>
> C
> 0 1 2 3
> 4 5 6 7
> 0 1 2 3
> 0 0 0 0 C ritem 0 1 2 3
> 0 0 0 0
> 4 5 6 7
> 0 0 0 0
> A
>   0  1  2  3
>   4  5  6  7
>
>   8  9 10 11
> 12 13 14 15
>
> 16 17 18 19
> 20 21 22 23
> (2 4 $ 0) A ritem 16+i.2 4
>   0  1  2  3
>   4  5  6  7
>
>   8  9 10 11
> 12 13 14 15
>
>   0  0  0  0
>   0  0  0  0
>
>
>
>
> --
> Sent from Gmail Mobile
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
Sent from Gmail Mobile
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] A plane rotation

2016-03-09 Thread Don Kelly
A question- you give you define the line and the center of rotation but 
the results are 3 points on the line. shouldn't the results be shown in 
terms of 2 points on the rotated line?  While usually the line is 
expressed as y=a+bx (a and b real)  which is easy if the the rotation 
center is on the line at x =0.

new end =. (r.theta) +end  as start is not changed.
A bigger challenge is to have a rotation center that is not on the 
original line and given points that do not fit the typical y=a+bx

Example: line ends at  2j3j5 and 3j4  to be rotated about 1j2
this involves a rotation  of two vectors (1j1 and3j4 )  as seen from 
1j2  about "0"  and then a translation of 1j2


rotheta=:[: +. ([: r. [) * [: +.^:_1 ]

1j2+ (_1r4p1) rotheta 1j1 2j2

2.41421j2 3.82843j2 which is the location of the 
points after rotation

This can then be put into a y=a+bx form with a =2 and b=1.414..


Don


On 2/20/2016 2:14 PM, Kip Murray wrote:

Here after a struggle are my linrot results.

NB. rotate a line in the plane about a point in the plane

NB. here points are complex numbers

NB. below start and direction are complex numbers, could be vectors

NB. (start,direction) line t  is  start + t * direction

line =: 1 : '({. m) + ({: m) * ]'

mab =: 1 : '( (u 0) , (% 9) (u 1) - u 0 ) line' NB. point slope
version of u

NB. below u rot (theta,center) rotates results of u by theta radians
about the center
NB. it is assumed the results of u and the center are complex numbers

rot =: 2 : '[: r.&({. n)&.(({: n) -~ ]) u'

ff =: 0j1 1j1 lineNB. line starts at 0j1 goes in direction of 1j1

ff"0 [ 0 1 2  NB. Notice y = x + 1
0j1 1j2 2j3

gg =: ff rot _1r4p1 0j1   NB. rotates ff results 45 degees clockwise
about 0j1

gg"0 [ 0 1 2  NB. horizontal (y's are all 1)
0j1 1.414213562j1 2.828427125j1

(gg mab)"0 [ 0 1 2.   NB. results x j. y from point slope y = 1 +
0*(x - 0)
0j1 1j1 2j1

--Kip

On Thursday, February 18, 2016, Louis de Forcrand  wrote:


To continue with the rotation challenges, write a verb that rotates a
linear
polynomial (coeffs in x) by 0 {:: y with a centre of 1 {:: y:

1 2 linrot 1p1 ; 0 1
1 2
1 2 linrot 1r2p1 ; 0 1
1 _0.5
1 2 linrot 1p1;1 1
_3 2

My take:
linrot=: ({: %. 1 ,. {.)@rotposmat
  rotposmat=: centre + j./@posmat |:@:+.@:* r.@angle
   centre=: 1&({::)@]
   posmat=: (] ,: p.)&0 1@[ - centre
   angle=: 0&({::)@]

It uses matrix division on a rotated set of two points from the original
polynomial. Not very elegant, but I’m pretty sure it works.

Best regards,
Louis


On 17 Feb 2016, at 06:40, Kip Murray > wrote:

Not bad.  I didn't know about r.  .  For clean I use

clean =: (* *!.1e_14@|)"0&.+.

--Kip

On Tuesday, February 16, 2016, Raul Miller  >> wrote:

Well...

   rottheta=: (rot~ r.)~
   1r2p1 rottheta 3 4
_4 3
   1r4p1 rottheta _1 1
_1.41421 1.11022e_16

I remember there being a concise phrase to clean irrelevant bits near
zero in a complex number, but I can't remember what I need to search
on to find it, and my foggy memory of how to write it is failing me at
the moment.

Still, this gets you close.

--
Raul


On Tue, Feb 16, 2016 at 11:50 PM, Kip Murray 

> wrote:

I'm retired with time to "fool around".  Finding an old rot90 verb that
used multiplication by a 2 by 2 matrix, I sought a more direct way

using

complex numbers and found one of the solutions that was posted.  I also
learned a lot from the other solutions posted, thanks everyone!

New puzzle: find a complex analysis way to do a rotation given its

angle

in

radians, examples:

1r2p1 rottheta 3 4
_4 3

1r4p1 rottheta _1 1
_1.414213562 0

--Kip

I'm also a former math professor!

On Tuesday, February 16, 2016, David Lambert 

> wrote:

what's your agenda, are you writing a book? Isn't there a homogeneous
coordinate system/transformation lab?


On 02/16/2016 06:16 PM, programming-requ...@forums.jsoftware.com



 wrote:

Date: Tue, 16 Feb 2016 15:18:43 -0600
From: Kip Murray

>

To:"programm...@jsoftware.com  " <

programm...@jsoftware.com  >

Subject: [Jprogramming] A plane rotation
Message-ID:
<

caofworgvydb1nmjwxkb0wosyfnlubxcdz20sv11uksfcfay...@mail.gmail.com



>

Content-Type: text/plain; charset=UTF-8

Fairly easy: write a verb that rotates a point in the plane by the

angle

of
a given complex number.  For example

 1j1 rot 1 1  NB. Rotate 1 1 counterclockwise 45 degrees
  0 1.414213562

Background information:  when you multiply two complex numbers the
magnitudes are multiplied and the angles are 

Re: [Jprogramming] Replace Items

2016-03-09 Thread Pascal Jasmin
moving around the m term to be the "searched".  There's probably a better 
version that doesn't box.


ritem =: 1 : '(m -:"_ _1 ]) >@:({"0 1)  (,&<~"_ _1)'
(2 4 $ 0) (16+i.2 4) ritem i. 3 2 4



- Original Message -
From: Kip Murray 
To: "programm...@jsoftware.com" 
Sent: Wednesday, March 9, 2016 5:26 PM
Subject: [Jprogramming] Replace Items

Adverb  ritem  creates a verb which replaces by  x  items in array  m  that
match  y

Below are examples.  How would you write the adverb?  --Kip Murray


C
0 1 2 3
4 5 6 7
0 1 2 3
0 0 0 0 C ritem 0 1 2 3
0 0 0 0
4 5 6 7
0 0 0 0
A
  0  1  2  3
  4  5  6  7

  8  9 10 11
12 13 14 15

16 17 18 19
20 21 22 23
(2 4 $ 0) A ritem 16+i.2 4
  0  1  2  3
  4  5  6  7

  8  9 10 11
12 13 14 15

  0  0  0  0
  0  0  0  0




-- 
Sent from Gmail Mobile
--
For information about J forums see http://www.jsoftware.com/forums.htm 
--
For information about J forums see http://www.jsoftware.com/forums.htm

[Jprogramming] New Video Lab viewer for jqt

2016-03-09 Thread robert therriault
Hey everybody,

For the last couple of months I have been working on creating a video version 
for J labs within the jqt environment. 

As a preview of coming attractions, I have made a video run through of the lab 
and you can watch it here. https://youtu.be/vJ1i-XzU56E  Make sure you watch it 
in the HD version as standard definition does not do justice to text videos. 

The addon for videolabs 1.0.0 itself is now available for downloading through 
Package Manager under the category of media/videolabs. It requires you to be 
running j804 on the jqt platform in 64 bit mode. Joe Bogner has run it on 
Windows and I have run it on the Mac and while I know that video is not 
supported for Android in jqt, other platforms should be fine.

When downloaded you should see a new lab entered in the 'Addons' category of 
labs entitled 'Video Introduction to Labs'. Selecting that lab should result in 
a message box display letting you know that the first time you look at this lab 
that you will need to be connected to the internet for about an 8 Mb download 
of video resources. These files will be stored in the 
~user/videolabs/Video_Introduction_to_Labs folder (don't worry the download 
creates that folder) and should take less than a minute with a decent internet 
connection. If you choose not to download, another message box coms up letting 
you know that that lab will not run reliably without the videos so that you 
should select a different lab. This process was done so that large numbers of 
video files are not downloaded during the original creation of a lab, but only 
if the viewer wishes to see a particular lab. 

Once you have completed the download the first page of the lab will appear with 
the video viewer minimized in the upper left corner. Advancing the lab is all 
that you need to do to go through the videos for each section and they should 
play automatically. The videos are in .mp4 format and so should play on a 
variety of machines. If the videos do not playback for you, let me know the 
JVERSION you are working with and the type of machine you are using and I will 
work on some fixes. Fingers crossed that this will work for you.

Many thanks to Chris Burke and Bill Lam for walking me through the (slight) 
challenges that I faced in making my first addon. 

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

[Jprogramming] Replace Items

2016-03-09 Thread Kip Murray
Adverb  ritem  creates a verb which replaces by  x  items in array  m  that
match  y

Below are examples.  How would you write the adverb?  --Kip Murray


C
 0 1 2 3
 4 5 6 7
 0 1 2 3
0 0 0 0 C ritem 0 1 2 3
 0 0 0 0
 4 5 6 7
 0 0 0 0
A
  0  1  2  3
  4  5  6  7

  8  9 10 11
 12 13 14 15

 16 17 18 19
 20 21 22 23
(2 4 $ 0) A ritem 16+i.2 4
  0  1  2  3
  4  5  6  7

  8  9 10 11
 12 13 14 15

  0  0  0  0
  0  0  0  0




-- 
Sent from Gmail Mobile
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Numerator and Denominator

2016-03-09 Thread Marshall Lochbaum
The best rational approximations to a number can be obtained from its
continued fraction representation. Simply truncating the continued
fraction gives a smaller list of approximants which are accurate
relative to the size of their denominators, and truncating and possibly
reducing the last number in the continued fraction gives a longer list
of continued fractions which are the best in a looser sense.

http://code.jsoftware.com/wiki/Essays/Continued_Fractions
https://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations

Here are the first few terms in π's continued fraction representation:
   (<.,[:%1|{:)^:10 ]1p1
3 7 15 1 292 1 1 1 2 1 3.93464

The first six approximants:
   ]a =: (+%)/\ x:<. (<.,[:%1|{:)^:5 ]1p1
3 22r7 333r106 355r113 103993r33102 104348r33215

Numerator, denominator, and absolute error:
   (2: ,. -&1p1) a
 3 1_0.141593
22 7   0.00126449
   333   106  _8.32196e_5
   355   113   2.66764e_7
103993 33102 _5.77891e_10
104348 33215  3.31628e_10

Marshall

On Wed, Mar 09, 2016 at 02:44:28PM -0700, Don Guinn wrote:
> Rational numbers have always fascinated me. I wanted to build a gear train
> for a science fair where the gears form a loop where the gear train does
> not mesh. But only after many thousands of revolutions. Then a sign on the
> front asking people to break the gears by turning the crank.
> 
> Long ago the Hammond organ used a gear train to approximate the twelfth
> root of two and powers of it to build the notes in the octave. Now
> electronics do that more effectively.
> 
> The ratio Roger showed in a previous post are too large to be pleasing.
> Smaller numbers in the ratio could still be useful and still be accurate
> enough  for some purposes.
> 
> I realize that this request is a little vague, but this is just an
> extention to the original challenge.
> On Mar 9, 2016 9:38 AM, "Raul Miller"  wrote:
> 
> > That seems a bit underspecified, or open-ended, at the moment.
> >
> > For example, pi could be 1p1 (or o.1) or pi could be any of a number
> > of algorithms: https://en.wikipedia.org/wiki/Category:Pi_algorithms
> >
> > Meanwhile, there's also the precision aspect - that could also be
> > specified in a variety of ways.
> >
> > In other words, you might be asking for something like this:
> >7%~x:<.0.5+7*1p1
> > 22r7
> >
> > Or you might have something different in mind, like perhaps this:
> >~.@(#~ (= <./)@:|@:-&1p1),%/~i.100x
> > 22r7
> >
> > Or, significantly slower, but almost tolerable:
> >~.@(#~ (= <./)@:|@:-&1p1),%/~i.1000x
> > 355r113
> >
> > Or, ... any of a variety of other mechanisms... (and even brute force
> > search techniques could be made to be significantly more efficient - a
> > moment's thought would show that incorporating the rounding technique,
> > for example, could have increased the speed of that last search by
> > something near a factor of 1000).
> >
> > Anyways, if you can say a bit more about what you were aiming for,
> > maybe we could do a better job of getting there?
> >
> > Thanks,
> >
> > --
> > Raul
> >
> > On Wed, Mar 9, 2016 at 11:18 AM, Don Guinn  wrote:
> > > How about rounding to a rational of some precision like pi rounded to
> > 22r7 ?
> > > On Mar 9, 2016 8:52 AM, "Kip Murray"  wrote:
> > >
> > >> Thanks, Roger and Raul.  Not understanding  GCD +.  I had a Rube
> > Goldberg
> > >> solution involving  Format ":  and  Do ".   --Kip
> > >>
> > >> On Wednesday, March 9, 2016, Roger Hui 
> > wrote:
> > >>
> > >> > den and num illustrate different ways of computing the same thing,
> > >> > hopefully in so doing improves understanding.  If you want speed 2:
> > is
> > >> > going to be faster.
> > >> >
> > >> > Also, watch this:
> > >> >
> > >> >2 x: o. 1
> > >> > 1285290289249 409120605684
> > >> >x: o. 1
> > >> > 1285290289249r409120605684
> > >> >
> > >> >2 x:!.0 o. 1
> > >> > 884279719003555 281474976710656
> > >> >x:!.0 o. 1
> > >> > 884279719003555r281474976710656
> > >> >
> > >> >
> > >> >
> > >> >
> > >> > On Wed, Mar 9, 2016 at 7:20 AM, Mike Day  > >> > > wrote:
> > >> >
> > >> > > Roger, are these (among) recommended and preferred methods for
> > >> > > recovering num & den,  or do they just show an elegant way of
> > >> > > avoiding 2 x: ?
> > >> > >
> > >> > > Thanks,
> > >> > >
> > >> > > Mike
> > >> > >
> > >> > >
> > >> > > On 09/03/2016 04:32, Roger Hui wrote:
> > >> > >
> > >> > >> x=: %/?2$10^8x
> > >> > >> x
> > >> > >> 69904549r40669028
> > >> > >>
> > >> > >> den=: [: % 1 +. ]
> > >> > >> num=: * den
> > >> > >>
> > >> > >> den x
> > >> > >> 40669028
> > >> > >> num x
> > >> > >> 69904549
> > >> > >>
> > >> > >>
> > >> > >>
> > >> > >>
> > >> > >> On Tue, Mar 8, 2016 at 7:28 PM, Kip Murray  > >> > >
> > >> > >> wrote:
> > >> > >>
> > >> > >> That's great!  

Re: [Jprogramming] Numerator and Denominator

2016-03-09 Thread Don Guinn
Rational numbers have always fascinated me. I wanted to build a gear train
for a science fair where the gears form a loop where the gear train does
not mesh. But only after many thousands of revolutions. Then a sign on the
front asking people to break the gears by turning the crank.

Long ago the Hammond organ used a gear train to approximate the twelfth
root of two and powers of it to build the notes in the octave. Now
electronics do that more effectively.

The ratio Roger showed in a previous post are too large to be pleasing.
Smaller numbers in the ratio could still be useful and still be accurate
enough  for some purposes.

I realize that this request is a little vague, but this is just an
extention to the original challenge.
On Mar 9, 2016 9:38 AM, "Raul Miller"  wrote:

> That seems a bit underspecified, or open-ended, at the moment.
>
> For example, pi could be 1p1 (or o.1) or pi could be any of a number
> of algorithms: https://en.wikipedia.org/wiki/Category:Pi_algorithms
>
> Meanwhile, there's also the precision aspect - that could also be
> specified in a variety of ways.
>
> In other words, you might be asking for something like this:
>7%~x:<.0.5+7*1p1
> 22r7
>
> Or you might have something different in mind, like perhaps this:
>~.@(#~ (= <./)@:|@:-&1p1),%/~i.100x
> 22r7
>
> Or, significantly slower, but almost tolerable:
>~.@(#~ (= <./)@:|@:-&1p1),%/~i.1000x
> 355r113
>
> Or, ... any of a variety of other mechanisms... (and even brute force
> search techniques could be made to be significantly more efficient - a
> moment's thought would show that incorporating the rounding technique,
> for example, could have increased the speed of that last search by
> something near a factor of 1000).
>
> Anyways, if you can say a bit more about what you were aiming for,
> maybe we could do a better job of getting there?
>
> Thanks,
>
> --
> Raul
>
> On Wed, Mar 9, 2016 at 11:18 AM, Don Guinn  wrote:
> > How about rounding to a rational of some precision like pi rounded to
> 22r7 ?
> > On Mar 9, 2016 8:52 AM, "Kip Murray"  wrote:
> >
> >> Thanks, Roger and Raul.  Not understanding  GCD +.  I had a Rube
> Goldberg
> >> solution involving  Format ":  and  Do ".   --Kip
> >>
> >> On Wednesday, March 9, 2016, Roger Hui 
> wrote:
> >>
> >> > den and num illustrate different ways of computing the same thing,
> >> > hopefully in so doing improves understanding.  If you want speed 2:
> is
> >> > going to be faster.
> >> >
> >> > Also, watch this:
> >> >
> >> >2 x: o. 1
> >> > 1285290289249 409120605684
> >> >x: o. 1
> >> > 1285290289249r409120605684
> >> >
> >> >2 x:!.0 o. 1
> >> > 884279719003555 281474976710656
> >> >x:!.0 o. 1
> >> > 884279719003555r281474976710656
> >> >
> >> >
> >> >
> >> >
> >> > On Wed, Mar 9, 2016 at 7:20 AM, Mike Day  >> > > wrote:
> >> >
> >> > > Roger, are these (among) recommended and preferred methods for
> >> > > recovering num & den,  or do they just show an elegant way of
> >> > > avoiding 2 x: ?
> >> > >
> >> > > Thanks,
> >> > >
> >> > > Mike
> >> > >
> >> > >
> >> > > On 09/03/2016 04:32, Roger Hui wrote:
> >> > >
> >> > >> x=: %/?2$10^8x
> >> > >> x
> >> > >> 69904549r40669028
> >> > >>
> >> > >> den=: [: % 1 +. ]
> >> > >> num=: * den
> >> > >>
> >> > >> den x
> >> > >> 40669028
> >> > >> num x
> >> > >> 69904549
> >> > >>
> >> > >>
> >> > >>
> >> > >>
> >> > >> On Tue, Mar 8, 2016 at 7:28 PM, Kip Murray  >> > >
> >> > >> wrote:
> >> > >>
> >> > >> That's great!  It's still a nice puzzle to write your own.  --Kip
> >> > >>>
> >> > >>> On Tuesday, March 8, 2016, Raul Miller  >> > > wrote:
> >> > >>>
> >> > >>> 2 x: 6r4
> >> >  3 2
> >> > 
> >> >  --
> >> >  Raul
> >> > 
> >> > 
> >> >  On Tue, Mar 8, 2016 at 10:04 PM, Kip Murray <
> thekipmur...@gmail.com
> >> > 
> >> >  > wrote:
> >> > 
> >> > > How do you find the numerator and denominator in lowest terms
> of a
> >> > >
> >> >  rational
> >> > 
> >> > > fraction?  For example,
> >> > >
> >> > >  nd 6r4
> >> > >   3 2
> >> > >
> >> > > --Kip Murray
> >> > >
> >> > >
> >> > >
> >> > > --
> >> > > Sent from Gmail Mobile
> >> > >
> >> > --
> >> > > For information about J forums see
> >> > http://www.jsoftware.com/forums.htm
> >> > >
> >> > 
> >> --
> >> >  For information about J forums see
> >> > http://www.jsoftware.com/forums.htm
> >> > 
> >> > >>>
> >> > >>>
> >> > >>> --
> >> > >>> Sent from Gmail Mobile
> >> > >>>
> >> 

Re: [Jprogramming] Numerator and Denominator

2016-03-09 Thread Raul Miller
That seems a bit underspecified, or open-ended, at the moment.

For example, pi could be 1p1 (or o.1) or pi could be any of a number
of algorithms: https://en.wikipedia.org/wiki/Category:Pi_algorithms

Meanwhile, there's also the precision aspect - that could also be
specified in a variety of ways.

In other words, you might be asking for something like this:
   7%~x:<.0.5+7*1p1
22r7

Or you might have something different in mind, like perhaps this:
   ~.@(#~ (= <./)@:|@:-&1p1),%/~i.100x
22r7

Or, significantly slower, but almost tolerable:
   ~.@(#~ (= <./)@:|@:-&1p1),%/~i.1000x
355r113

Or, ... any of a variety of other mechanisms... (and even brute force
search techniques could be made to be significantly more efficient - a
moment's thought would show that incorporating the rounding technique,
for example, could have increased the speed of that last search by
something near a factor of 1000).

Anyways, if you can say a bit more about what you were aiming for,
maybe we could do a better job of getting there?

Thanks,

-- 
Raul

On Wed, Mar 9, 2016 at 11:18 AM, Don Guinn  wrote:
> How about rounding to a rational of some precision like pi rounded to 22r7 ?
> On Mar 9, 2016 8:52 AM, "Kip Murray"  wrote:
>
>> Thanks, Roger and Raul.  Not understanding  GCD +.  I had a Rube Goldberg
>> solution involving  Format ":  and  Do ".   --Kip
>>
>> On Wednesday, March 9, 2016, Roger Hui  wrote:
>>
>> > den and num illustrate different ways of computing the same thing,
>> > hopefully in so doing improves understanding.  If you want speed 2: is
>> > going to be faster.
>> >
>> > Also, watch this:
>> >
>> >2 x: o. 1
>> > 1285290289249 409120605684
>> >x: o. 1
>> > 1285290289249r409120605684
>> >
>> >2 x:!.0 o. 1
>> > 884279719003555 281474976710656
>> >x:!.0 o. 1
>> > 884279719003555r281474976710656
>> >
>> >
>> >
>> >
>> > On Wed, Mar 9, 2016 at 7:20 AM, Mike Day > > > wrote:
>> >
>> > > Roger, are these (among) recommended and preferred methods for
>> > > recovering num & den,  or do they just show an elegant way of
>> > > avoiding 2 x: ?
>> > >
>> > > Thanks,
>> > >
>> > > Mike
>> > >
>> > >
>> > > On 09/03/2016 04:32, Roger Hui wrote:
>> > >
>> > >> x=: %/?2$10^8x
>> > >> x
>> > >> 69904549r40669028
>> > >>
>> > >> den=: [: % 1 +. ]
>> > >> num=: * den
>> > >>
>> > >> den x
>> > >> 40669028
>> > >> num x
>> > >> 69904549
>> > >>
>> > >>
>> > >>
>> > >>
>> > >> On Tue, Mar 8, 2016 at 7:28 PM, Kip Murray > > >
>> > >> wrote:
>> > >>
>> > >> That's great!  It's still a nice puzzle to write your own.  --Kip
>> > >>>
>> > >>> On Tuesday, March 8, 2016, Raul Miller > > > wrote:
>> > >>>
>> > >>> 2 x: 6r4
>> >  3 2
>> > 
>> >  --
>> >  Raul
>> > 
>> > 
>> >  On Tue, Mar 8, 2016 at 10:04 PM, Kip Murray > > 
>> >  > wrote:
>> > 
>> > > How do you find the numerator and denominator in lowest terms of a
>> > >
>> >  rational
>> > 
>> > > fraction?  For example,
>> > >
>> > >  nd 6r4
>> > >   3 2
>> > >
>> > > --Kip Murray
>> > >
>> > >
>> > >
>> > > --
>> > > Sent from Gmail Mobile
>> > >
>> > --
>> > > For information about J forums see
>> > http://www.jsoftware.com/forums.htm
>> > >
>> > 
>> --
>> >  For information about J forums see
>> > http://www.jsoftware.com/forums.htm
>> > 
>> > >>>
>> > >>>
>> > >>> --
>> > >>> Sent from Gmail Mobile
>> > >>>
>> --
>> > >>> For information about J forums see
>> http://www.jsoftware.com/forums.htm
>> > >>>
>> > >>>
>> --
>> > >> For information about J forums see
>> http://www.jsoftware.com/forums.htm
>> > >>
>> > >
>> > >
>> > > ---
>> > > This email has been checked for viruses by Avast antivirus software.
>> > > https://www.avast.com/antivirus
>> > >
>> > > --
>> > > For information about J forums see http://www.jsoftware.com/forums.htm
>> > --
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
>>
>> --
>> Sent from Gmail Mobile
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Numerator and Denominator

2016-03-09 Thread Don Guinn
How about rounding to a rational of some precision like pi rounded to 22r7 ?
On Mar 9, 2016 8:52 AM, "Kip Murray"  wrote:

> Thanks, Roger and Raul.  Not understanding  GCD +.  I had a Rube Goldberg
> solution involving  Format ":  and  Do ".   --Kip
>
> On Wednesday, March 9, 2016, Roger Hui  wrote:
>
> > den and num illustrate different ways of computing the same thing,
> > hopefully in so doing improves understanding.  If you want speed 2: is
> > going to be faster.
> >
> > Also, watch this:
> >
> >2 x: o. 1
> > 1285290289249 409120605684
> >x: o. 1
> > 1285290289249r409120605684
> >
> >2 x:!.0 o. 1
> > 884279719003555 281474976710656
> >x:!.0 o. 1
> > 884279719003555r281474976710656
> >
> >
> >
> >
> > On Wed, Mar 9, 2016 at 7:20 AM, Mike Day  > > wrote:
> >
> > > Roger, are these (among) recommended and preferred methods for
> > > recovering num & den,  or do they just show an elegant way of
> > > avoiding 2 x: ?
> > >
> > > Thanks,
> > >
> > > Mike
> > >
> > >
> > > On 09/03/2016 04:32, Roger Hui wrote:
> > >
> > >> x=: %/?2$10^8x
> > >> x
> > >> 69904549r40669028
> > >>
> > >> den=: [: % 1 +. ]
> > >> num=: * den
> > >>
> > >> den x
> > >> 40669028
> > >> num x
> > >> 69904549
> > >>
> > >>
> > >>
> > >>
> > >> On Tue, Mar 8, 2016 at 7:28 PM, Kip Murray  > >
> > >> wrote:
> > >>
> > >> That's great!  It's still a nice puzzle to write your own.  --Kip
> > >>>
> > >>> On Tuesday, March 8, 2016, Raul Miller  > > wrote:
> > >>>
> > >>> 2 x: 6r4
> >  3 2
> > 
> >  --
> >  Raul
> > 
> > 
> >  On Tue, Mar 8, 2016 at 10:04 PM, Kip Murray  > 
> >  > wrote:
> > 
> > > How do you find the numerator and denominator in lowest terms of a
> > >
> >  rational
> > 
> > > fraction?  For example,
> > >
> > >  nd 6r4
> > >   3 2
> > >
> > > --Kip Murray
> > >
> > >
> > >
> > > --
> > > Sent from Gmail Mobile
> > >
> > --
> > > For information about J forums see
> > http://www.jsoftware.com/forums.htm
> > >
> > 
> --
> >  For information about J forums see
> > http://www.jsoftware.com/forums.htm
> > 
> > >>>
> > >>>
> > >>> --
> > >>> Sent from Gmail Mobile
> > >>>
> --
> > >>> For information about J forums see
> http://www.jsoftware.com/forums.htm
> > >>>
> > >>>
> --
> > >> For information about J forums see
> http://www.jsoftware.com/forums.htm
> > >>
> > >
> > >
> > > ---
> > > This email has been checked for viruses by Avast antivirus software.
> > > https://www.avast.com/antivirus
> > >
> > > --
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > --
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
> --
> Sent from Gmail Mobile
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Numerator and Denominator

2016-03-09 Thread Kip Murray
Thanks, Roger and Raul.  Not understanding  GCD +.  I had a Rube Goldberg
solution involving  Format ":  and  Do ".   --Kip

On Wednesday, March 9, 2016, Roger Hui  wrote:

> den and num illustrate different ways of computing the same thing,
> hopefully in so doing improves understanding.  If you want speed 2: is
> going to be faster.
>
> Also, watch this:
>
>2 x: o. 1
> 1285290289249 409120605684
>x: o. 1
> 1285290289249r409120605684
>
>2 x:!.0 o. 1
> 884279719003555 281474976710656
>x:!.0 o. 1
> 884279719003555r281474976710656
>
>
>
>
> On Wed, Mar 9, 2016 at 7:20 AM, Mike Day  > wrote:
>
> > Roger, are these (among) recommended and preferred methods for
> > recovering num & den,  or do they just show an elegant way of
> > avoiding 2 x: ?
> >
> > Thanks,
> >
> > Mike
> >
> >
> > On 09/03/2016 04:32, Roger Hui wrote:
> >
> >> x=: %/?2$10^8x
> >> x
> >> 69904549r40669028
> >>
> >> den=: [: % 1 +. ]
> >> num=: * den
> >>
> >> den x
> >> 40669028
> >> num x
> >> 69904549
> >>
> >>
> >>
> >>
> >> On Tue, Mar 8, 2016 at 7:28 PM, Kip Murray  >
> >> wrote:
> >>
> >> That's great!  It's still a nice puzzle to write your own.  --Kip
> >>>
> >>> On Tuesday, March 8, 2016, Raul Miller  > wrote:
> >>>
> >>> 2 x: 6r4
>  3 2
> 
>  --
>  Raul
> 
> 
>  On Tue, Mar 8, 2016 at 10:04 PM, Kip Murray  
>  > wrote:
> 
> > How do you find the numerator and denominator in lowest terms of a
> >
>  rational
> 
> > fraction?  For example,
> >
> >  nd 6r4
> >   3 2
> >
> > --Kip Murray
> >
> >
> >
> > --
> > Sent from Gmail Mobile
> >
> --
> > For information about J forums see
> http://www.jsoftware.com/forums.htm
> >
>  --
>  For information about J forums see
> http://www.jsoftware.com/forums.htm
> 
> >>>
> >>>
> >>> --
> >>> Sent from Gmail Mobile
> >>> --
> >>> For information about J forums see http://www.jsoftware.com/forums.htm
> >>>
> >>> --
> >> For information about J forums see http://www.jsoftware.com/forums.htm
> >>
> >
> >
> > ---
> > This email has been checked for viruses by Avast antivirus software.
> > https://www.avast.com/antivirus
> >
> > --
> > For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
Sent from Gmail Mobile
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Numerator and Denominator

2016-03-09 Thread Roger Hui
den and num illustrate different ways of computing the same thing,
hopefully in so doing improves understanding.  If you want speed 2: is
going to be faster.

Also, watch this:

   2 x: o. 1
1285290289249 409120605684
   x: o. 1
1285290289249r409120605684

   2 x:!.0 o. 1
884279719003555 281474976710656
   x:!.0 o. 1
884279719003555r281474976710656




On Wed, Mar 9, 2016 at 7:20 AM, Mike Day  wrote:

> Roger, are these (among) recommended and preferred methods for
> recovering num & den,  or do they just show an elegant way of
> avoiding 2 x: ?
>
> Thanks,
>
> Mike
>
>
> On 09/03/2016 04:32, Roger Hui wrote:
>
>> x=: %/?2$10^8x
>> x
>> 69904549r40669028
>>
>> den=: [: % 1 +. ]
>> num=: * den
>>
>> den x
>> 40669028
>> num x
>> 69904549
>>
>>
>>
>>
>> On Tue, Mar 8, 2016 at 7:28 PM, Kip Murray 
>> wrote:
>>
>> That's great!  It's still a nice puzzle to write your own.  --Kip
>>>
>>> On Tuesday, March 8, 2016, Raul Miller  wrote:
>>>
>>> 2 x: 6r4
 3 2

 --
 Raul


 On Tue, Mar 8, 2016 at 10:04 PM, Kip Murray > wrote:

> How do you find the numerator and denominator in lowest terms of a
>
 rational

> fraction?  For example,
>
>  nd 6r4
>   3 2
>
> --Kip Murray
>
>
>
> --
> Sent from Gmail Mobile
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>
 --
 For information about J forums see http://www.jsoftware.com/forums.htm

>>>
>>>
>>> --
>>> Sent from Gmail Mobile
>>> --
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Numerator and Denominator

2016-03-09 Thread Mike Day

Roger, are these (among) recommended and preferred methods for
recovering num & den,  or do they just show an elegant way of
avoiding 2 x: ?

Thanks,

Mike


On 09/03/2016 04:32, Roger Hui wrote:

x=: %/?2$10^8x
x
69904549r40669028

den=: [: % 1 +. ]
num=: * den

den x
40669028
num x
69904549




On Tue, Mar 8, 2016 at 7:28 PM, Kip Murray  wrote:


That's great!  It's still a nice puzzle to write your own.  --Kip

On Tuesday, March 8, 2016, Raul Miller  wrote:


2 x: 6r4
3 2

--
Raul


On Tue, Mar 8, 2016 at 10:04 PM, Kip Murray > wrote:

How do you find the numerator and denominator in lowest terms of a

rational

fraction?  For example,

 nd 6r4
  3 2

--Kip Murray



--
Sent from Gmail Mobile
--
For information about J forums see http://www.jsoftware.com/forums.htm

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



--
Sent from Gmail Mobile
--
For information about J forums see http://www.jsoftware.com/forums.htm


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



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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

Re: [Jprogramming] Unbox request for requests

2016-03-09 Thread Joe Bogner
Some wishlist ideas (some are likely controversial):

1. Optimized CSV/TSV loading and writing
2. JSON support
3. Parallel processing (big topic, but maybe something bite-sized for
now - just to show some progress)
4. Sockets built-in (comparing to k/kona's simple way of retrieving
web data or ipc)
5. More interop: .NET/Java

And then maybe a bit more tactical:
1. Method of getting memory address of current J instance:
http://www.jsoftware.com/pipermail/source/2014-May/000581.html
2. Method of cleaning up instance memory on linux:
http://www.jsoftware.com/pipermail/source/2015-February/000663.html


On Tue, Mar 8, 2016 at 7:32 AM, Thomas Costigliola  wrote:
>
>
> So far Unbox has a couple of bug fixes and build system changes not in the 
> standard source release. I have begun working on a re-implementation of 
> gerunds that should fix some bugs and allow some new features. This is 
> working out to be a somewhat long term project and I'd like to keep things 
> fresh and exciting in the meantime.
> Please post your top BUG and/or FEATURE wishlists.
>
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm