Re: [Jprogramming] avx problem with 904

2023-04-16 Thread Don Kelly
Thanks- that is what I saw before and feared,  but the instructions for 
loading J904 are those for earlier versions-hence the confusion.


For what I want to do, I will stay with 903 as that is more than 
adequate. I like to deal with power system and machine analysis, and 
using  J is fun ( as well as some frustration that is self generated) . 
Maybe my computer will end life before me- that is a race -I'm  91+ and 
my brain  needs exercise.


Don Kelly

On 2023-04-15 4:51 p.m., bill lam wrote:

The following is written in Eric's email announcement of j9.4.2 . It looks
like your cpu is avx but not avx2 capable. If your cpu actually supports
avx2 then you can download and use the appropriate J binary manually.

Previous releases had versions: j64, j64avx, and j64avx2. Machines limited
to avx are less and less common and no longer warrant the support effort.
Install or upgrade will provide the version appropriate for your hardware.
If you are running j64 and are concerned with performance you will at some
point need to upgrade your hardware.

On Sun, 16 Apr 2023 at 7:34 AM Don Kelly  wrote:


I have installed J904  and  it runs well except that avx  is not
available , so 903 is faster. Is it that the present 904 does not
recognize the older version -even though the information  includes it.
Is there a way to deal with this?

Don Kelly

--
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


[Jprogramming] avx problem with 904

2023-04-15 Thread Don Kelly
I have installed J904  and  it runs well except that avx  is not 
available , so 903 is faster. Is it that the present 904 does not 
recognize the older version -even though the information  includes it. 
Is there a way to deal with this?


Don Kelly

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


Re: [Jprogramming] J on the web

2023-02-02 Thread Don Kelly
Do do a multi-line verb you have to define as a verb, (monad or dyad 
define is a good starter (there is a numeric call for this that is 
shorter. Then put in your multiline text, line at a time and finally use 
a right parenthese


Here is an example

Bunrad=: dyad define

'rc, rb'=. > x NB.conductor and bundle radii

(# %: */)rc, rb*|1-r. (o. 2%y)*1+i.y-1 NB.y is number of 
conductors


)


This is a 1  case but using a numeric call  using 4: rather than  dyad 
define or verb define otherwise any changes in the term requires a 
complete rewrite--painful.


NB. conductor spacing brad number of conductors

brad=: 4 : 'x% 2* 1 o. (o.%y) '


If you want to edit your verb, copy to an ijs script- and do the editing 
there -such a script can be used to hold multiple items that are 
related-you can thenrun it as required (usually load t



Don Kelly -still a learner


On 2023-02-01 12:13 p.m., More Rice wrote:

It is totally awesome.

When I went through the “Learning J” using it, I noticed the “Term” pane
doesn’t do everything our app can do. For example, multi-line input like
verb (explicitly) define does not work. I had to use the “Edit” pane for
that.

Is there a page that documents the limitations/differences?

Thank you for the tool.


Maurice

On Wed, Feb 1, 2023 at 1:07 PM Björn Helgason  wrote:


I was using a machine that did not have J installed.

I needed to do a little bit of calculations that would be easy in J.

I was thinking about downloading J to be able to do what I wanted.

Then I saw I could use J directly on the web without doing download.

https://jsoftware.github.io/j-playground/bin/html2/#

That was very convenient and solved my needs.
--
For information about J forums seehttp://www.jsoftware.com/forums.htm


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


Re: [Jprogramming] [Jbeta] New error Polynomial Representation (padding regime)

2023-01-09 Thread Don Kelly
My apology,  Devon has pointed out that the operator can change the 
tolerance from the default value.


Don

On 2023-01-06 11:00 p.m., Ak O wrote:

Correct.  Which is a property of the Operator.


Ak

On Fri., Jan. 6, 2023, 23:47 Devon McCormick,  wrote:


They are the same under tolerance:
https://code.jsoftware.com/wiki/Help/Primer/Tolerance.

On Sat, Jan 7, 2023 at 12:48 AM Ak O  wrote:


This is strictly based on the tolerance properties of the Operator not

the

Type of the Operands (Iyiabo's Prime Theorem).


(Integer) ,(Integer) NB. The question we are asking is, are these
Terms the same?
  (17) -: (17)
1

(Floating) ,(Integer)  NB. So also we are asking, are these Terms the
same?
  (17.0)-:(17)
1


Ak







On Fri., Jan. 6, 2023, 20:29 Don Kelly,  wrote:


J has it right.

(17+45+65+71+5) -: (17+45+65+71+5) is the match between two integer
sums-each of which gives the integer result as they have the same

boolean

representation and are equal-giving a "1" result

(17.36+45.24+65.87+71.20+5.00) -: (17+45+65+71+5) is an attempt to

compare

a floating point number with an integer-the result is floating point

and

a

"0" result

   +/ 17.36  45.24  65.87 71.20 5.00

204.67

(+/17+45+65+71+5)

203


   Don Kelly



On 2023-01-05 4:06 a.m., Ak O wrote:

These are both certainly Terms of Degree 2.
They are not equalities. They are not the same Term.

The point I mean to highlight is the represention (for the purpose of
calculation).


16/32 is not 15/30 is not 8/16. An equivalence is 1/2. It should

never

be

mistaken for Expression Linear /Logarithmic.

The problem is in cases where you apply an equivalence simplification
improperly sequence wise.
You loss coherence of the expression, (which often leads to settling

on

on

approximation  where resolution can be achieved).

This is what we think we are saying.
   (17+45+65+71+5) -: (17+45+65+71+5)
1
This is what we are actually saying.
   (17.36+45.24+65.87+71.20+5.00) -: (17+45+65+71+5)
0
Or worse
   (17.99+45.99+65.99+71.99+5.99 ) -: (17+45+65+71+5)
0

In part, this is why the full representation should be favoured.

Particularly for unknown cases where it is common to reach for

Infinities.

I am rambling now. Let me know if this is not clear.


Ak


On Wed., Jan. 4, 2023, 22:18 Raul Miller,

wrote:

On Wed, Jan 4, 2023 at 10:24 PM Ak O  wrote:

   File -> Wed Jan 4 03:40:07UTC 2023
The statement:
   So, there's no difference in Degree 1 2 1 0 0 0 and 1 2 1...

This is not correct. These should not be seen as equalities.

That's an interesting perspective.

It seems to me that both of these are polynomials of degree 2.  If
they should have different degrees, what degrees should they have?

And

how would this be consistent with the opening sentence at
https://en.wikipedia.org/wiki/Degree_of_a_polynomial#:

"In mathematics, the degree of a polynomial is the highest of the
degrees of the polynomial's monomials (individual terms) with

non-zero

coefficients."

Thanks,

--
Raul


--

For information about J forums seehttp://

www.jsoftware.com/forums.htm
--

For information about J forums seehttp://

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



--

Devon McCormick, CFA

Quantitative Consultant
--
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] [Jbeta] New error Polynomial Representation (padding regime)

2023-01-08 Thread Don Kelly
You are using "Match " Either items match or they don't   17and 18 don't 
match, 17 1nd 17 are identical simply treats a float number which is as 
close to an integer that the difference is meaningless. J also has 
extended numbers if you want oodles of digits,The references  mentioned 
are quite clear.


a=. 16r32

a

1r2

 Mathematically equivalent (agreed 16 apples in a box of 32 apples is 
not the same as 1 apple in a box of 2)



Don


integer, integer --> possibly
17 -: 17
1
17-:18
0
floating,integer --> possibly
17.001-:17
1

18.001-:17
0

TermA,TermB --> The possibilities are
1 or 0 only, yes or no.

It is not how. It is why.

Whatever the basis is what it is.


Ak




On Sat., Jan. 7, 2023, 21:12 Don Kelly,  wrote:


integer, integer -- Yes




floating,integer, maybe..

In this case J converts the floating number to an integer(why not have a
computer language that doesn't require that a number must e defined as
integer vs floating point where the computer. can do it? Where it
matters, J provides  ways to extend "precision"  You reccognise that
"precision" is not necessarily exact.   A value for pi  is a useful
approximation ( but counting living people in your house should be exact.

   Significant figures, taught , at least  back before the 1950's in
Physics,Mathematics, and Engineering (hammered home to me in 1950) .

17.0001-:17 oops- 1 in

0

17.001-:17

1

-

The tolerance limits in the above cases is not set by the operator but
by the number of bytes available in the machine memory.the display is
rounded off by the  number of digits set by the operator.


Look at NuVoc   Vocabulary/NumericPrecisionsalso
Vocabulary/AccurateSummation



On 2023-01-06 9:48 p.m., Ak O wrote:

This is strictly based on the tolerance properties of the Operator not

the

Type of the Operands (Iyiabo's Prime Theorem).


(Integer) ,(Integer) NB. The question we are asking is, are these
Terms the same?
   (17) -: (17)
1

(Floating) ,(Integer)  NB. So also we are asking, are these Terms the
same?
   (17.0)-:(17)
1


Ak







On Fri., Jan. 6, 2023, 20:29 Don Kelly,   wrote:


J has it right.

(17+45+65+71+5) -: (17+45+65+71+5) is the match between two integer
sums-each of which gives the integer result as they have the same

boolean

representation and are equal-giving a "1" result

(17.36+45.24+65.87+71.20+5.00) -: (17+45+65+71+5) is an attempt to

compare

a floating point number with an integer-the result is floating point

and a

"0" result

+/ 17.36  45.24  65.87 71.20 5.00

204.67

(+/17+45+65+71+5)

203


Don Kelly



On 2023-01-05 4:06 a.m., Ak O wrote:

These are both certainly Terms of Degree 2.
They are not equalities. They are not the same Term.

The point I mean to highlight is the represention (for the purpose of
calculation).


16/32 is not 15/30 is not 8/16. An equivalence is 1/2. It should never

be

mistaken for Expression Linear /Logarithmic.

The problem is in cases where you apply an equivalence simplification
improperly sequence wise.
You loss coherence of the expression, (which often leads to settling on

on

approximation  where resolution can be achieved).

This is what we think we are saying.
(17+45+65+71+5) -: (17+45+65+71+5)
1
This is what we are actually saying.
(17.36+45.24+65.87+71.20+5.00) -: (17+45+65+71+5)
0
Or worse
(17.99+45.99+65.99+71.99+5.99 ) -: (17+45+65+71+5)
0

In part, this is why the full representation should be favoured.

Particularly for unknown cases where it is common to reach for

Infinities.

I am rambling now. Let me know if this is not clear.


Ak


On Wed., Jan. 4, 2023, 22:18 Raul Miller,

  wrote:

On Wed, Jan 4, 2023 at 10:24 PM Ak Owrote:

File -> Wed Jan 4 03:40:07UTC 2023
The statement:
So, there's no difference in Degree 1 2 1 0 0 0 and 1 2 1...

This is not correct. These should not be seen as equalities.

That's an interesting perspective.

It seems to me that both of these are polynomials of degree 2.  If
they should have different degrees, what degrees should they have? And
how would this be consistent with the opening sentence at
https://en.wikipedia.org/wiki/Degree_of_a_polynomial#:

"In mathematics, the degree of a polynomial is the highest of the
degrees of the polynomial's monomials (individual terms) with non-zero
coefficients."

Thanks,

--
Raul
--
For information about J forums seehttp://www.jsoftware.com/forums.htm


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

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



Re: [Jprogramming] [Jbeta] New error Polynomial Representation (padding regime)

2023-01-07 Thread Don Kelly

integer, integer -- Yes

floating,integer, maybe..

In this case J converts the floating number to an integer(why not have a 
computer language that doesn't require that a number must e defined as 
integer vs floating point where the computer. can do it? Where it 
matters, J provides  ways to extend "precision"  You reccognise that 
"precision" is not necessarily exact.   A value for pi  is a useful 
approximation ( but counting living people in your house should be exact.


 Significant figures, taught , at least  back before the 1950's in  
Physics,Mathematics, and Engineering (hammered home to me in 1950) .


17.0001-:17 oops- 1 in

0

17.001-:17

1

-

The tolerance limits in the above cases is not set by the operator but 
by the number of bytes available in the machine memory.the display is 
rounded off by the  number of digits set by the operator.



Look at NuVoc   Vocabulary/NumericPrecisions    also 
Vocabulary/AccurateSummation




On 2023-01-06 9:48 p.m., Ak O wrote:

This is strictly based on the tolerance properties of the Operator not the
Type of the Operands (Iyiabo's Prime Theorem).


(Integer) ,(Integer) NB. The question we are asking is, are these
Terms the same?
  (17) -: (17)
1

(Floating) ,(Integer)  NB. So also we are asking, are these Terms the
same?
  (17.0)-:(17)
1


Ak







On Fri., Jan. 6, 2023, 20:29 Don Kelly,  wrote:


J has it right.

(17+45+65+71+5) -: (17+45+65+71+5) is the match between two integer
sums-each of which gives the integer result as they have the same boolean
representation and are equal-giving a "1" result

(17.36+45.24+65.87+71.20+5.00) -: (17+45+65+71+5) is an attempt to compare
a floating point number with an integer-the result is floating point and a
"0" result

   +/ 17.36  45.24  65.87 71.20 5.00

204.67

(+/17+45+65+71+5)

203


   Don Kelly



On 2023-01-05 4:06 a.m., Ak O wrote:

These are both certainly Terms of Degree 2.
They are not equalities. They are not the same Term.

The point I mean to highlight is the represention (for the purpose of
calculation).


16/32 is not 15/30 is not 8/16. An equivalence is 1/2. It should never be
mistaken for Expression Linear /Logarithmic.

The problem is in cases where you apply an equivalence simplification
improperly sequence wise.
You loss coherence of the expression, (which often leads to settling on

on

approximation  where resolution can be achieved).

This is what we think we are saying.
   (17+45+65+71+5) -: (17+45+65+71+5)
1
This is what we are actually saying.
   (17.36+45.24+65.87+71.20+5.00) -: (17+45+65+71+5)
0
Or worse
   (17.99+45.99+65.99+71.99+5.99 ) -: (17+45+65+71+5)
0

In part, this is why the full representation should be favoured.

Particularly for unknown cases where it is common to reach for

Infinities.

I am rambling now. Let me know if this is not clear.


Ak


On Wed., Jan. 4, 2023, 22:18 Raul Miller,   wrote:


On Wed, Jan 4, 2023 at 10:24 PM Ak O   wrote:

   File -> Wed Jan 4 03:40:07UTC 2023
The statement:
   So, there's no difference in Degree 1 2 1 0 0 0 and 1 2 1...

This is not correct. These should not be seen as equalities.

That's an interesting perspective.

It seems to me that both of these are polynomials of degree 2.  If
they should have different degrees, what degrees should they have? And
how would this be consistent with the opening sentence at
https://en.wikipedia.org/wiki/Degree_of_a_polynomial#:

"In mathematics, the degree of a polynomial is the highest of the
degrees of the polynomial's monomials (individual terms) with non-zero
coefficients."

Thanks,

--
Raul
--
For information about J forums seehttp://www.jsoftware.com/forums.htm


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

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


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

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


Re: [Jprogramming] [Jbeta] New error Polynomial Representation (padding regime)

2023-01-06 Thread Don Kelly

J has it right.

(17+45+65+71+5) -: (17+45+65+71+5) is the match between two integer sums-each of which 
gives the integer result as they have the same boolean representation and are 
equal-giving a "1" result

(17.36+45.24+65.87+71.20+5.00) -: (17+45+65+71+5) is an attempt to compare a floating 
point number with an integer-the result is floating point and a "0" result

 +/ 17.36  45.24  65.87 71.20 5.00

204.67

(+/17+45+65+71+5)

203


 Don Kelly



On 2023-01-05 4:06 a.m., Ak O wrote:

These are both certainly Terms of Degree 2.
They are not equalities. They are not the same Term.

The point I mean to highlight is the represention (for the purpose of
calculation).


16/32 is not 15/30 is not 8/16. An equivalence is 1/2. It should never be
mistaken for Expression Linear /Logarithmic.

The problem is in cases where you apply an equivalence simplification
improperly sequence wise.
You loss coherence of the expression, (which often leads to settling on on
approximation  where resolution can be achieved).

This is what we think we are saying.
  (17+45+65+71+5) -: (17+45+65+71+5)
1
This is what we are actually saying.
  (17.36+45.24+65.87+71.20+5.00) -: (17+45+65+71+5)
0
Or worse
  (17.99+45.99+65.99+71.99+5.99 ) -: (17+45+65+71+5)
0

In part, this is why the full representation should be favoured.

Particularly for unknown cases where it is common to reach for Infinities.

I am rambling now. Let me know if this is not clear.


Ak


On Wed., Jan. 4, 2023, 22:18 Raul Miller,  wrote:


On Wed, Jan 4, 2023 at 10:24 PM Ak O  wrote:

  File -> Wed Jan 4 03:40:07UTC 2023
The statement:
  So, there's no difference in Degree 1 2 1 0 0 0 and 1 2 1...

This is not correct. These should not be seen as equalities.

That's an interesting perspective.

It seems to me that both of these are polynomials of degree 2.  If
they should have different degrees, what degrees should they have? And
how would this be consistent with the opening sentence at
https://en.wikipedia.org/wiki/Degree_of_a_polynomial#:

"In mathematics, the degree of a polynomial is the highest of the
degrees of the polynomial's monomials (individual terms) with non-zero
coefficients."

Thanks,

--
Raul
--
For information about J forums seehttp://www.jsoftware.com/forums.htm


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

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


Re: [Jprogramming] Beginner: Where to start?

2022-12-31 Thread Don Kelly
As told, load  the J addons  -it will help. Also it may be beneficial, 
when learning, to run  in J directly rather than through babel. Your 
sample below wraps the actual program inside another layer. I am not an 
expert in J but, for my interests, it is excellent.  If you don't have 
the"plot' addon -you will be a' not found' .


#+begin_src J

load 'plot'

plot 1 o. 0.1 * i.200

#+end_src

However the begin and end lines are not needed,  and once plot is loaded 
you  can use it for many things. For simple things so viewmat may not be 
needed.




On 2022-12-28 3:15 p.m., Joe Bogner wrote:

You may also consider the J Playground,
https://code2.jsoftware.com/wiki/Main_Page/JPlayground, which runs in your
browser. It is an easy way to get started and later move to emacs or jqt

There are examples and labs that can be run from the J Playground

On Wed, Dec 28, 2022, 5:08 PM Galaxy Being  wrote:


Yes, thanks so far for the advice. One problem I'm having with "performing
experiments" is issues with libraries and packages. I'm using Emacs org
mode babel (see here
) and
it's going surprisingly well -- as in it just seems to work after
installing the j-mode and adding J to the org-mode Babel world. (I'm a
literate programming die-hard.) Unfortunately, I'm seeing examples where
the file structure of my J903 and the support files don't coincide. For
example, this code  isn't
working.

#+begin_src J :exports both :session *j-org*
require 'viewmat'
hp=: 3 : '(|.,]) 1 (0 _2 _2 ,&.> _2 _1 0 + #y) } (,.|:) y'
MG=: 256 #. 128 0 128,:0 192 0
viewrgb 2 ([ # #"1) MG {~ hp ^:6 [ 0, 0 1 0 ,: 0
#+end_src

#+RESULTS:
: not found: /home/galaxybeing/opt/j903/addons/graphics/viewmat/viewmat.ijs
: |file name error: script
: |   0!:0 y[4!:55<'y'
:
: |value error: viewrgb
: |   viewrgb 2([##"1)MG{~hp^:6[0,0 1 0,:0

...and no, there is no viewmat.ijs. Likewise, the example

#+begin_src J
load 'plot'
plot 1 o. 0.1 * i.200
#+end_src

#+RESULTS:
: not found: /home/galaxybeing/opt/j903/addons/graphics/plot/plot.ijs
: |file name error: script
: |   0!:0 y[4!:55<'y'
:
: |value error: plot
: |   plot 1 o.0.1*i.200

...isn't finding plot. Please advise. So what is the best, preferred IDE
for J? Does J need the whole keyboard of strange symbols like APL and BQN?

On Wed, Dec 28, 2022 at 3:49 PM Raul Miller  wrote:


(So it's both an array language and a functional programming language,
at least approximately speaking...)

Anyways, my advice for learning (if you learn the way I learn): try
and schedule half an hour a day on learning J and try to spend at
least some of that time forming and performing experiments in the
language. (Ideally, also, take notes of things which bother you and
see if you can find out how to resolve those issues on future days.)

I hope this helps,

--
Raul

On Wed, Dec 28, 2022 at 4:39 PM 'Pascal Jasmin' via Programming
  wrote:

J is an "array programming language," which is what exactly?

J is a functional programming language where every function is an

operator with 1 or 2 arguments.

An array language is one where arrays are easy to input, and functions

"automatically" extend to full arrays with implied map/zip functionality.




On Wednesday, December 28, 2022 at 01:13:31 p.m. EST, Galaxy Being <

borg...@gmail.com> wrote:





Hello,

I would like to learn J programming paradigm. I have a standard

programming

background (C/C++, Java) along with some basic math, as well as some
functional programming exposure. I understand, however, that J is an

"array

programming language," which is what exactly? I've heard it is based on

SKI

combinator math. Is this true? So my question is, What background
materials, texts, etc. should I study to get a theoretical

understanding

of

the J world? I watched this  and a few

Tracy

Harms videos, so yes, where does a beginner get started -- especially

with

the theory behind it all?

Thank you.
⨽
Lawrence Bottorff
Grand Marais, MN, USA
borg...@gmail.com
--
For information about J forums seehttp://www.jsoftware.com/forums.htm
--
For information about J forums seehttp://www.jsoftware.com/forums.htm

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



--
⨽
Lawrence Bottorff
Grand Marais, MN, USA
borg...@gmail.com
--
For information about J forums seehttp://www.jsoftware.com/forums.htm


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

--
For information about J 

Re: [Jprogramming] Hilbert Curve error

2022-08-01 Thread Don Kelly
I have run  into this problem,  defining multiple lines and failing  or 
entering them awkwardly where I really do not want to do it all  in the 
editor- NOW I know how to handle this. It makes a difference i my 
frustration level


Thanks to you all ,

Don Kelly

iter=: (, 1 , +@|.) @: (,~ 0j_1 ,~ 0j_1*|.)

hilbert=: {{0j1+(%{:) +/\0,iter ^: y ''}}

require 'plot'

plot hilbert 5


On 2022-07-31 12:34 p.m., Henry Rich wrote:
He must have pasted the two lines for iter and hilbert lines together. 
Then he loaded plot and ran hilbert, with iter undefined.


Never mind this example: beginners encounter this often, and it's very 
nonintuitive, because you can see the lines in the term window with no 
indication that some of them were not executed.  I saw it a lot in my 
classes.


I don't see any downside to executing multiple lines pasted into the 
last line.


Henry Rich

On 7/31/2022 2:14 PM, chris burke wrote:

Note that the error occurred in hilbert. So the OP had run that line
correctly. It was not that he had pasted the multiple lines and
pressed Enter expecting them all to run.

On Sun, Jul 31, 2022 at 8:50 AM Henry Rich  wrote:

I agree with you.  That would be a change and might discommode some
old-time users, but I bet few would notice.

We could say, pasting above the last line merely edits the log, while
pasting into the last line executes all sentences ended by LF.  That is
a very small change from the current behavior.

--
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] Question about complex arithmetic in J.

2021-05-09 Thread Don Kelly

Float is being used,

9!:11]16 sets 16 bit display


On 2021-05-04 11:22 p.m., Don Kelly wrote:+. 1 o. 1j1e_100
+. 1 o. 1j1e_11

0.8414709848078965 5.403023058681397e_12

+. 1 o. 1j1e_12

0.8414709848078965 5.403023058681398e_13

1 o. 1j1e_13

0.8414709848078965j5.403023058681398e_14

+. 1 o. 1j1e_14

0.8414709848078965 0    rounded off display and 1e_14 is close enough to 
0 to be shown as 0


however

1 o. 1j1e13

0.8414709848078965j5.403023058681398e_14

1 o. 1j1e_14

0.8414709848078965 drops the  0 as there is  only a single number as 1j0 
is 1


in other word with a 16 digit display the result is rounded off at 16 
digits even if the stored number  was 32 or 64  or whatever.


( Just my opinion)

Don



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


Re: [Jprogramming] Question about complex arithmetic in J.

2021-05-05 Thread Don Kelly
J default printout is 6 digits. This is easily changed. There is also a 
default tolerance level where, if a number is close enough to being an 
integer it will be treated as that integer.


In this case the print precision can be set to 16 by   9!:11 ]16

+. 1 o. 1j1e_100

0.8414709848078965 0

 This doesn't deal with the tolerance. someone else may be able to 
clarify this.



Don Kelly


On 2021-05-04 9:30 p.m., Imre Patyi wrote:

  +. 1 o. 1j1e_100

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


Re: [Jprogramming] (GUI) Select from a grid

2021-05-03 Thread Don Kelly

J guides- wiki shows examples (old  J602 ) which has codes for buttons.

Qtdemos has controls  (toucan picture) and buttons  "push me' and 
"cancel".The coding there may be helpful.


don kelly

On 2021-05-02 2:36 p.m., Michal Wallace wrote:

I made a video a while back about implementing a simple sprite editor using
the window driver:

https://www.youtube.com/watch?v=CzK2SazvCxM

(It uses two such clickable grids - one for a palette, and one for drawing
pixels in the sprite).



On Sun, May 2, 2021 at 4:47 PM Don Kelly  wrote:


minesweeper works on 903 (windows Qt) for me.  I think that it also
worked on 902

Don Kelly

On 2021-05-01 3:10 a.m., Ric Sherlock wrote:

Minesweeper appears to be working fine for me in J902 (Windows Qt) and on
Android.

Bill it looks like the dialogs with xywh commands were introduced to
support jnet? However they don't seem to interfere with the Windows Qt
version for me.

On Sat, May 1, 2021 at 1:40 PM Devon McCormick 

wrote:

Trying to run minesweeper in either J 9.02 or 9.03 (JQt version) gives

me

the following error:

run''

|xywh : command not found

: wd

| (LF,~wd ::(''"_)'qer') (13!:8)3



On Fri, Apr 30, 2021 at 9:04 PM Devon McCormick 
wrote:


Thanks - I should have thought of that.
The page I was looking at turns out to be less helpful than I thought

it

would be.  The "cardsgen.ijs" and "bridge.ijs" files appear to be

missing

from the J distribution.  It looks like this was an old page from Oleg
Kobchenko.  The code on the page does work as advertised but it's only
nicely displaying a selection of cards, not allowing interactive

selection

by clicking on the grid.

On Fri, Apr 30, 2021 at 8:39 PM bill lam  wrote:


You can take a look at the minesweeper game in addons.



On Sat, May 1, 2021, 8:25 AM Devon McCormick 

wrote:

Hi,
does anyone have a sample of code which puts up some kind of a grid -

like

a chessboard or tic-tac-toe game - to allow a user to select an

element

of

the grid by clicking on it?  Does anyone have a feeling whether this

would

be better handled with JHS or JQt?

Thanks,

Devon
--

Devon McCormick, CFA

Quantitative Consultant


--

For information about J forums see

http://www.jsoftware.com/forums.htm

--
For information about J forums see

http://www.jsoftware.com/forums.htm

--

Devon McCormick, CFA

Quantitative Consultant



--

Devon McCormick, CFA

Quantitative Consultant
--
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


--
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] (GUI) Select from a grid

2021-05-02 Thread Don Kelly
minesweeper works on 903 (windows Qt) for me.  I think that it also 
worked on 902


Don Kelly

On 2021-05-01 3:10 a.m., Ric Sherlock wrote:

Minesweeper appears to be working fine for me in J902 (Windows Qt) and on
Android.

Bill it looks like the dialogs with xywh commands were introduced to
support jnet? However they don't seem to interfere with the Windows Qt
version for me.

On Sat, May 1, 2021 at 1:40 PM Devon McCormick  wrote:


Trying to run minesweeper in either J 9.02 or 9.03 (JQt version) gives me
the following error:

run''

|xywh : command not found

: wd

| (LF,~wd ::(''"_)'qer') (13!:8)3



On Fri, Apr 30, 2021 at 9:04 PM Devon McCormick 
wrote:


Thanks - I should have thought of that.
The page I was looking at turns out to be less helpful than I thought it
would be.  The "cardsgen.ijs" and "bridge.ijs" files appear to be missing
from the J distribution.  It looks like this was an old page from Oleg
Kobchenko.  The code on the page does work as advertised but it's only
nicely displaying a selection of cards, not allowing interactive

selection

by clicking on the grid.

On Fri, Apr 30, 2021 at 8:39 PM bill lam  wrote:


You can take a look at the minesweeper game in addons.



On Sat, May 1, 2021, 8:25 AM Devon McCormick 

wrote:

Hi,
does anyone have a sample of code which puts up some kind of a grid -

like

a chessboard or tic-tac-toe game - to allow a user to select an

element

of

the grid by clicking on it?  Does anyone have a feeling whether this

would

be better handled with JHS or JQt?

Thanks,

Devon
--

Devon McCormick, CFA

Quantitative Consultant
--
For information about J forums see

http://www.jsoftware.com/forums.htm

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



--

Devon McCormick, CFA

Quantitative Consultant



--

Devon McCormick, CFA

Quantitative Consultant
--
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] Blocked html messages Re: Unboxing problem

2021-03-10 Thread Don Kelly

I saw this solution but I don't recall who sent it

On 2021-03-10 10:25 a.m., Tom Arneson wrote:

I sent this to programming earlier. It never came back to me, and I don't see 
that it ever got to programming.



On 03/10/2021 8:13 AM Tom Arneson  wrote:


]a=.1 3 8;6 9;2 4;5;0;7
.

Don Kelly

┌─┬───┬───┬─┬─┬─┐

│1 3 8│6 9│2 4│5│0│7│

└─┴───┴───┴─┴─┴─┘

;a

1 3 8 6 9 2 4 5 0 7




On 03/09/2021 10:51 PM Lippu Esa  wrote:


Hello everybody

Every now and then even after all these years I stumble into something that 
should be simple but I just don't get it. It must be due to my still so sadly 
shallow knowledge of J. Please excuse me. I don't post my current solution here 
- it has kludge written all over it.

So, I need a verb f that does the following:

]a=.1 3 8;6 9;2 4;5;0;7
┌─┬───┬───┬─┬─┬─┐
│1 3 8│6 9│2 4│5│0│7│
└─┴───┴───┴─┴─┴─┘
f a
1 3 8 6 9 2 4 5 0 7

Any help will be greatly appreciated.

Esa

Tämän viestin sisältö liitteineen on luottamuksellinen ja tarkoitettu vain sen 
vastaanottajalle. Jos et ole viestin tarkoitettu vastaanottaja, pyydämme sinua 
poistamaan viestin liitteineen ja sen jälkeen ilmoittamaan asiasta välittömästi 
viestin lähettäjälle. Viestin sisällön paljastaminen, kopioiminen tai muu 
käyttö on kielletty.

The contents of this message and any attachments are confidential and meant 
solely for the intended recipient. If you are not the intended recipient, we 
kindly ask that you delete the message and its attachments, and immediately 
notify the sender of the email. Disclosing, copying or using the contents of 
the message is strictly prohibited.
--
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] almost real numbers

2021-02-19 Thread Don Kelly

You have it right.

In cases like this does the smaller one being zero vs  non-zero matter?  
If it is carried along the effect is not a reduction of accuracy.


The  problem (if any) may bethe way that numbers are stored. Floats have 
basically 63bits including a sign bit and 11 bit exponent bits. The 
examples are well within these limits. Complex numbers, if I remember 
correctly involve 2  words plus some linkage which may involve saving a 
bit for indicating "real/imaginary " properties.


Don Kelly


But I don’t think anyone would want this
to happen in every calculation, in any
algorithm. It’s okay to have a function
you call every time you might actually
want to consider the smaller one 0 but
not with every intermediate result.

 From my point of view, there are use cases,
and they can be dealt with by users.
This one isn’t even worth a new primitive
in my opinion. I do think there are better
ways to bloat the language.

Am 19.02.21 um 21:50 schrieb Raul Miller:

So we
have to deal with epsilon issues.

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


Re: [Jprogramming] Apparent Error in NuVoc

2021-02-18 Thread Don Kelly
This is what I use for distances between conductors of a power line.  
Self distances will be 0 but if needed they can be added (in my case 
these would be conductor diameters)


'n,n array of distances between conductors '

' result =. dij (conductor positions as complex numbers )


dij=: |@ -/~


hope this is helpful

Don Kelly



On 2021-02-16 1:37 a.m., 'Michael Day' via Programming wrote:
In connection with the recent correspondence on the PAM algorithm for 
k-medoids,

I thought it _might_ be worth considering using complex coordinates,
eg
   cdata =: j./"1 data
so that distance between points is just the magnitude of the 
difference of their complex

representations.

Forgetting that magnitude was simply | ,  I found an apparent mistake 
in the NuVoc:

this appears near the bottom of
*https://code.jsoftware.com/wiki/Vocabulary/jdot#dyadic  :**
**
*

   *Related primitives**
   **Real/Imag (+. y), Signum (Unit Circle) (* y), Length/Angle (*. y),
   Magnitude (* y), .**
   *

*
**Clearly,  it should read "  Magnitude  (| y), ..."**
*
I've just seen there's a page for reporting issues,  but I don't think 
I have an account and
don't intend to make a habit of spotting errors there,  so I hope this 
is ok!


Cheers,

Mike



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


Re: [Jprogramming] 903-beta-d

2021-02-05 Thread Don Kelly

That works, thanks

Don

On 2021-02-04 7:31 a.m., Eric Iverson wrote:

Setting up a new win10 development/test machine led to an error in building
windows j903-beta-d. Some of the latest changes were not included.

The build has been redone and uploaded. The crash on the second load of
rubbish is fixed.

Get the latest with:

start J903
load'pacman'
'upgrade'jpkg'jengine'

***
Check JVERSION or 9!:14'' to verify that your windows j903-beta-d was built
on Feb 4 and not on Feb 3.


On Wed, Feb 3, 2021 at 6:33 PM 'Michael Day' via Programming <
programm...@jsoftware.com> wrote:


Thanks.

I've updated to beta-d.
Having had a bit of trouble with crashing on loading errors,  I find that

 load'noname'NB. just after firing up JQt

correctly reports 'not found: /noname' on the first attempt,

but crashes J903 beta-d on the second attempt.

OK in J902.

This is in Windows 10.

Cheers,

Mike


On 03/02/2021 22:34, Eric Iverson wrote:

903-beta-d is available for windows/linux/macos.

If you already run J903-beta, then upgrade is easy:
 load'pacman'
 'upgrade'jpkg'' NB. ensure base library and addons are current
 'upgrade'jpkg'jengine'

If you have not yet installed J903-beta, time to get started!
 https://code.jsoftware.com/wiki/System/Installation/J903

Release notes:
 https://code.jsoftware.com/wiki/System/ReleaseNotes/J903

Questions/bug reports/etc. should go to the beta forum.
--
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

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


Re: [Jprogramming] 903-beta-d

2021-02-03 Thread Don Kelly

I have the same problem but  it is listed as

beta-d commercial /2021-02-03T11:16:21

Don Kelly

On 2021-02-03 3:44 p.m., Julian Fondren wrote:

Are you sure you upgraded? I discovered that loading nonexistent
files breaks beta-c just minutes before the beta-d release (because
I wasn't subscribed to the beta list and missed the discussion),
so this is the first thing I checked after release. JVERSION
should include

Beta-d: commercial/2021-02-03T16:21:15

On 2021-02-03 17:33, 'Michael Day' via Programming wrote:

Thanks.

I've updated to beta-d.
Having had a bit of trouble with crashing on loading errors,  I find 
that


   load'noname'    NB. just after firing up JQt

correctly reports 'not found: /noname' on the first attempt,

but crashes J903 beta-d on the second attempt.

OK in J902.

This is in Windows 10.

Cheers,

Mike


On 03/02/2021 22:34, Eric Iverson wrote:

903-beta-d is available for windows/linux/macos.

If you already run J903-beta, then upgrade is easy:
    load'pacman'
    'upgrade'jpkg'' NB. ensure base library and addons are current
    'upgrade'jpkg'jengine'

If you have not yet installed J903-beta, time to get started!
    https://code.jsoftware.com/wiki/System/Installation/J903

Release notes:
    https://code.jsoftware.com/wiki/System/ReleaseNotes/J903

Questions/bug reports/etc. should go to the beta forum.
--
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] J and Spreadsheets

2021-01-06 Thread Don Kelly
check out 'Libre Office' which is free and from what i see, can run on 
Linux. I prefer it to Microsoft Office although I rarely use ther Excel 
equivalent.


Don Kelly

On 2021-01-05 7:40 a.m., Justin Paston-Cooper wrote:

Hello,

I don't know much Excel, and I know some J. The dataflow aspect of
Excel excites me, and I am averse to GUI programming.
https://code.jsoftware.com/wiki/Articles/JExcel details how to
integrate J with Excel. I don't know how up-to-date this is.

Because I run Linux, it would be difficult for me to run Excel. Are
there any interesting alternatives that would enable me to quickly
build interfaces involving dataflow? I couldn't find anything on using
Libreoffice Calc.

Thanks in advance,

Justin
--
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] All combinations from multiple different-length lists

2020-12-20 Thread Don Kelly

on the other hand, simply leave as boxed if that is convenient.
{x

┌─┬─┐

│1 2 3│1 2 4│

├─┼─┤

│3 2 3│3 2 4│

├─┼─┤

│5 2 3│5 2 4│

└─┴─┘


On 2020-12-20 10:51 a.m., Henry Rich wrote:


]x=.1 3 5;2;3 4

┌─┬─┬───┐ 

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


Re: [Jprogramming] Stop command when testing

2020-11-27 Thread Don Kelly

Thanks- will check it out.

Don

On 2020-11-27 7:54 a.m., Eric Iverson wrote:

Don,

start J:
break 0 NB. display break usage

Jqt program in a loop, start jconsole and enter: break''

Jconsole program in a loop, enter: ctrl+c

JHS program in a loop, enter: ctrl+c in the jconsole server  window.

Start jconsole

On Thu, Nov 26, 2020 at 10:05 PM Don Kelly  wrote:


that is fine-but when  a J  program is running  wild- how do I bring up
"break.bat"?  I would like to know how to do this, other than ctrl
alt-del  and then shut down J.

Don Kelly

On 2020-11-26 4:30 p.m., 'Pascal Jasmin' via Programming wrote:

there is also a "break" utility (break.bat in windows) which will stop a

"runaway" program/function when executed..






On Thursday, November 26, 2020, 06:10:10 p.m. EST, chris burke <

cbu...@jsoftware.com> wrote:





Use dbstopme to stop at a specific line, see the example below. A
non-empty argument is a test, so stop if true.

Caution: if using 902 beta, get the latest beta and qt addon, as there
have been recent updates to debug.

foo=: 4 : 0
a=. 2 + y
dbstopme''
b=. a * 5
x + b
)

dbg 1
2 foo 3

On Thu, Nov 26, 2020 at 2:20 PM HH PackRat  wrote:

I could have sworn that, a couple of months ago, someone posted some
code that included a "stop" command of some sort in explicit coding,
but I can't remember how it was done.  I cannot find such a command
anywhere in NuVoc.  Searching the wiki brought back the
"Vocabulary/JBreak" ancillary page, which referred only to the desktop
icon for basically stopping a "runaway" program.

What I'm looking for is a J command of some type (something like
"stop." or some synonym).  As I'm testing a program, I often want to
stop ever so often without executing the entire program.  "break." and
"end." obviously don't work, since J won't even load a program that
doesn't use those words correctly as part of a larger construction.

All I want to do is stop the program in the middle without using a
deliberate error (such as "13!:8 2") and without continuing to the end
of the program.  I would appreciate any help with this!

Harvey
--
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

--
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] Stop command when testing

2020-11-26 Thread Don Kelly
That is fine- it is something from "TEurbo Basic" and implemented in APL 
, in a way.and is very useful, but it only works if you detect, during 
coding, when to deal with a problem due, often, to coding errors. What  
is needed is an interrupt outside of J (as an interrupt optio may not be 
available-except through a command to windows to stop.(alt crtrl del).


I would like to know

Don


On 2020-11-26 8:54 p.m., HH PackRat wrote:

I figured out how to do what I wanted:
 . . .
 . . .
goto_stop.
 . . .
 . . .
label_stop.
)

The name "stop", of course, can be any label name you wish.  In
effect, this pattern can be used to "rem out" (remark out) any portion
of code that you don't want executed at a particular moment of
testing.  I presume, as well, that you could conceivably have more
than one of these pairs as long as the labels ("stop" in this case)
are different.  (However, I am by no means an expert in J concerning
the latter point.)

Harvey
--
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] Stop command when testing

2020-11-26 Thread Don Kelly
that is fine-but when  a J  program is running  wild- how do I bring up 
"break.bat"?  I would like to know how to do this, other than ctrl 
alt-del  and then shut down J.


Don Kelly

On 2020-11-26 4:30 p.m., 'Pascal Jasmin' via Programming wrote:

there is also a "break" utility (break.bat in windows) which will stop a 
"runaway" program/function when executed..






On Thursday, November 26, 2020, 06:10:10 p.m. EST, chris burke 
 wrote:





Use dbstopme to stop at a specific line, see the example below. A
non-empty argument is a test, so stop if true.

Caution: if using 902 beta, get the latest beta and qt addon, as there
have been recent updates to debug.

foo=: 4 : 0
a=. 2 + y
dbstopme''
b=. a * 5
x + b
)

dbg 1
2 foo 3

On Thu, Nov 26, 2020 at 2:20 PM HH PackRat  wrote:

I could have sworn that, a couple of months ago, someone posted some
code that included a "stop" command of some sort in explicit coding,
but I can't remember how it was done.  I cannot find such a command
anywhere in NuVoc.  Searching the wiki brought back the
"Vocabulary/JBreak" ancillary page, which referred only to the desktop
icon for basically stopping a "runaway" program.

What I'm looking for is a J command of some type (something like
"stop." or some synonym).  As I'm testing a program, I often want to
stop ever so often without executing the entire program.  "break." and
"end." obviously don't work, since J won't even load a program that
doesn't use those words correctly as part of a larger construction.

All I want to do is stop the program in the middle without using a
deliberate error (such as "13!:8 2") and without continuing to the end
of the program.  I would appreciate any help with this!

Harvey
--
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

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


Re: [Jprogramming] J902-beta-n

2020-11-21 Thread Don Kelly

I had no problem  win10-64  avx

Don Kelly


On 2020-11-21 11:45 a.m., Ian Clark wrote:

When I followed your instructions to upgrade my existing (working) j902
installation to beta-n
(using jqt, not jcon, but it has worked before)…

load'pacman'
'upgrade'jpkg'jengine'

…went through fine.

But when I re-started jqt I got the following message:

|nonce error: boot

|   bind=:2 :'x@(y"_)'

|[-199] /Applications/j902/system/main/stdlib.ijs

|value error: boxdraw_j_

|   0 0$boxdraw_j_ 0

No JVERSION -- it was not created.

jcon gave a similar message.

I'm running macOS Catalina (10.15.7) on the affected machine.

Might this be an oversight and easily fixed,
or was my existing j902 installation (beta-d, I think) just too old for a
simple upgrade of jengine to work?

Are other people getting a similar message, or is my installation broken in
a unique way?

Ian Clark

On Sat, 21 Nov 2020 at 18:13, Eric Iverson  wrote:


J902-beta-n available for windows/macos/linux.

We are nearing the end of the beta cycle. There are probably only 1 or 2
more betas. With luck we will release J902 before year end.

Now is the time to pile on and help ensure the J902 release is solid.

If you already run 902-beta, then upgrade is easy:
load'pacman'
'upgrade'jpkg'jengine'
--
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] Getting indices of matrix elements

2020-11-20 Thread Don Kelly

It appears to only work with integers.

Don Kelly

On 2020-11-15 10:23 a.m., Henry Rich wrote:

On reflection I am not going to implement (4 $. $.) in special code.

The fundamental operation is 'express the numbers in y, which are 
elements of (i. #@, x), as index lists into x'.  This is achieved by


   (#:~ $)~

y can have any shape.  (4 $. $.) works only on an argument that 
happens to have the shape of x.  I don't think that's a special case 
worth coding for.


Henry Rich

On 11/13/2020 10:54 PM, Roger Hui wrote:
Another candidate is >,{i.&.>$x .  (4 $. $.) has the "problem" that 
indices

corresponding to 0 elements are excluded.



On Fri, Nov 13, 2020 at 6:59 PM Henry Rich  wrote:


Ric Sherlock has suggested that (4 $. $.) would be an idiom worthy of
special code.  I agree & will do it sometime.



--
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] generate integers from a to be with a step

2020-04-06 Thread Don Kelly
Thanks, "range'  is neat. The added 1 in ...  3{.y,1 got me for a bit 
but I see that it allows range 5 13  as well as 5 13 1

I must open up more of the library even if it spoils my fun.

Don


On 2020-04-04 3:15 p.m., chris burke wrote:

numeric has both:

steps 5 13 4
5 7 9 11 13
range 5 13 2
5 7 9 11 13

On Sat, Apr 4, 2020 at 2:26 PM Don Kelly  wrote:

However, as Hauke Rehr has indicated, the step size is given in the
original problem while the method you suggest is given the number of
steps in the range. There is a big difference.

Don

On 2020-04-04 2:59 a.m., Mario C wrote:

I prefer
load 'numeric'
steps 5 9 8
etc.

The definitions of steps in 'stats/base' and 'numeric' are identical.

Mario
--
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

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


Re: [Jprogramming] generate integers from a to be with a step

2020-04-04 Thread Don Kelly
However, as Hauke Rehr has indicated, the step size is given in the 
original problem while the method you suggest is given the number of 
steps in the range. There is a big difference.


Don

On 2020-04-04 2:59 a.m., Mario C wrote:

I prefer
load 'numeric'
steps 5 9 8
etc.

The definitions of steps in 'stats/base' and 'numeric' are identical.

Mario
--
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] generate integers from a to be with a step

2020-04-01 Thread Don Kelly
I like this and find your approach to thru interesting  as it works both 
ways 5 thru 19 and 19 thru 5. A 'one way' approach could be this


thru2=. }. [:i.>:

5 thru2 19

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

some time difference but no space difference

(100)6!:2 '5 thru2 200'

1.117e_6

(100)6!:2 '5 thru 200'

1.44e_6


reverse

|. 5 thru2 19

19 18 17 16 15 14 13 12 11 10 9 8 7 6 5


Don


On 2020-03-29 7:34 a.m., Raul Miller wrote:

As your examples illustrate, this is something of an underspecified problem.

But let's try a few things...

First, there's your basic i. which gets us a sequence:
i.1+14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

And adding step 3 means taking fewer steps and making them longer
3*i.<.1+14%3
0 3 6 9 12

And we can of course add our starting point back in:
5+3*i.<.1+14%3
5 8 11 14 17

Meanwhile, without step, we can make a dyad to give us all integers in a range:
thru=: <. + i.@(+ *)@-~
5 thru 19
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
19 thru 5
19 18 17 16 15 14 13 12 11 10 9 8 7 6 5

With step, what would this look like?
(#~ 0= 3|]) 5 thru 19
6 9 12 15 18
(#~ 0= 3|5-~]) 5 thru 19
5 8 11 14 17
(#~ 0= 3|19-~]) 5 thru 19
7 10 13 16 19

Let's pick the second one (since it matches an example you gave) and
parameterize that. Specifically, let's declare our arguments like
this:
step stepThrough start,limit

('step', 'start' and 'limit' are all single integers here, and
'stepThrough' will be our verb)

I can't see any non-verbose ways of making this tacit, so:

stepThrough=:dyad define
   'start diff'=. -/\ y
   start-(*diff)*x*i.<.1+x%~|diff
)

3 stepThrough 5 19
5 8 11 14 17
3 stepThrough 19 5
19 16 13 10 7

Does the implementation seem a bit arbitrary? Well... it should. After
all, we arbitrarily picked from one of several possible mechanisms
which matched the description.

But I hope this helps. (And, I hope email transport doesn't reformat
what I've written.)

Thanks,


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


Re: [Jprogramming] Iteration

2020-03-24 Thread Don Kelly
I see your point.  actually x?y  (deal as in the vocabulary) doesn't 
allow repetitions. An analogy is dealing a hand of cards where you will 
never (legally) have 2 aces of spades . hence, with 2 cards 1 and 0, you 
can't get 1 1 . If you have 2 cards each having a 1  and 0 you can get  
your results but you will have to treat  it as a set of 4 numbers where 
odd numbers are equivalent to  0 and even are 1 .



1+(5#2)?4

2 4

1 4

3 1

1 4

4 1

these corresponds to 1 1, 0 1 , 0 0, 0 1 , 1 0


Don


On 2020-03-24 5:18 p.m., Julian Fondren wrote:

   5 6 ?@$ 55
52  3  9 16  4  3
26 30 24 34 30 50
46 51 16 19 26 26
20 46 12 50 39 27
 3 39 45 46 46 33

:)

This actually isn't the same result as your code, though.

   (4#2) ? 2
0 1
0 1
0 1
1 0
   1 1 i.~ (1e6#2) ? 2
100
   0 0 i.~ (1e6#2) ? 2
100

There are never any 1 1 or 0 0 results.

   4 2 ?@$ 2
0 0
0 1
1 0
0 0

There are such results.


On 2020-03-24 19:02, Don Kelly wrote:

(5#6)?55

42 16 14 29 38 25

14 37 22 4 54 6

47 51 35 32 26 45

13 53 10 29 3 15

21 8 20 45 30 52


Don Kelly


On 2020-03-23 5:47 p.m., 'Jim Russell' via Programming wrote:
Who do I thank tor this? It is a particularly clear and helpful 
exclamation.  Thank you!


On Mar 13, 2020, at 3:56 AM, ethiejiesa via Programming 
 wrote:


I'll contribute a little prose. Hopefully, it's helpful.

In this particular case, notice that > transforms your list of 
boxes into a 5x6

table:


(6?55);(6?55);(6?55);(6?55);(6?55)

    13 4 19 43 3 52
    10 1 4 46 52 11
    38 12 48 50 54 45
    36 54 39 35 53 50
    44 1 7 54 11 41

So, we should be able to easily "reverse" the above, meaning that 
dealing with
a 5x6 array is pretty much the same as dealing with 5 boxes of 
6-arrays. Let's
just keep this in mind for now, and first try to generate this 6x5 
table.


The key point of ? is that it's monadic and dyadic ranks are all 0, 
meaning
that it transforms an array of integers into a corresponding array 
of random

numbers:

    ? 50 6 $ 55
    ...

produces a random 50x6 array of integers each in the range i.55. 
This is not
quite what we want, but we first note that it can be more 
idiomatically

written:

    50 6 ?@$ 55

The utility of @ (and @:) become a lot more apparent when writing 
tacit
expressions. In general, x u@v y is equivalent to u (x v y), 
applying u "atop"
x v y, hence the mnemonic. (NB. The difference between u@v and u@:v 
is that

they produce verbs of different rank.)

The dyad n?m produces n random numbers without replacement. Your 
posed problem

is to generate 50 such lists, so conceptually we want to *reshape* the
arguments of ? into 50-lists:

    (50$6) ? (50$55)

but, better yet, as lots of verbs to ? will automatically reshape 
an atomic
argument to the shape of the other argument, so we can abbreviate 
the above in

one of two ways:

    6 ? (50$55) NB. or
    (50$6) ? 55

In the first case, the parentheses are not necessary due to J 
parsing rules, so

its more compact and idomatic to elide them

    6 ? 50$55

These three previous options should produce the desired random 
tables. Now,
putting things together, we just want to "redo" the boxing we did 
in the

beginning example:

    <"1 (6 ? 50$55)

Which should give the desired result. We need the
parenthesis to separate the 1 from the 6, otherwise J would 
interpret this as

<"1 6. Another way to break up the list lexing is like this:

    <"1 [ 6 ? 50 $ 55

Anyway, Hui's use of &. is even nicer. The key ideas is that u&.v 
first runs v
on u's aguments and then *undoes* v on the result. The really neat 
thing is

that > is a no-op on non-boxed atoms:


42

    42

So the idea is to let > be a no-op on our input array of integers, 
then let ?
do it's thing, and finally *undo* > on *each* result. And since 
undoing > is

simply doing <, we get what we want.

    6 ?&.> 50 $ 55

The "each result" part above is exactly why this form is slick. 
?&.> has the
rank of >, i.e. 0 0 0. This means that it will box each list 
produced by ? as
the integers are fed to it, which is exactly what we want in this 
case.


Very cool stuff. Rank!


Skip Cave  wrote:
Wow! Two completely different ways to generate multiple sets of 
random
integers. Roger used &. which I haven't really ever used or 
understood. I
will definitely need to understand &. for the future. Devon used 
@, which I
also haven't used very much. I need to find some practice and  
training

examples to work on both concepts.

Skip Cave
Cave Consulting LLC


On Fri, Mar 13, 2020 at 12:04 AM Devon McCormick 
 wrote:


   6 5?@$55
Will give you a 6x5 table that is 6 independent rows of 5?55.


On Fri, Mar 13, 2020 at 12:52 AM Roger Hui 


wrote:


   6 ?&.> 5 $ 55


┌┬─┬───┬───

Re: [Jprogramming] Iteration

2020-03-24 Thread Don Kelly

(5#6)?55

42 16 14 29 38 25

14 37 22 4 54 6

47 51 35 32 26 45

13 53 10 29 3 15

21 8 20 45 30 52


Don Kelly


On 2020-03-23 5:47 p.m., 'Jim Russell' via Programming wrote:

Who do I thank tor this? It is a particularly clear and helpful exclamation.  
Thank you!


On Mar 13, 2020, at 3:56 AM, ethiejiesa via Programming 
 wrote:

I'll contribute a little prose. Hopefully, it's helpful.

In this particular case, notice that > transforms your list of boxes into a 5x6
table:


(6?55);(6?55);(6?55);(6?55);(6?55)

13 4 19 43 3 52
10 1 4 46 52 11
38 12 48 50 54 45
36 54 39 35 53 50
44 1 7 54 11 41

So, we should be able to easily "reverse" the above, meaning that dealing with
a 5x6 array is pretty much the same as dealing with 5 boxes of 6-arrays. Let's
just keep this in mind for now, and first try to generate this 6x5 table.

The key point of ? is that it's monadic and dyadic ranks are all 0, meaning
that it transforms an array of integers into a corresponding array of random
numbers:

? 50 6 $ 55
...

produces a random 50x6 array of integers each in the range i.55. This is not
quite what we want, but we first note that it can be more idiomatically
written:

50 6 ?@$ 55

The utility of @ (and @:) become a lot more apparent when writing tacit
expressions. In general, x u@v y is equivalent to u (x v y), applying u "atop"
x v y, hence the mnemonic. (NB. The difference between u@v and u@:v is that
they produce verbs of different rank.)

The dyad n?m produces n random numbers without replacement. Your posed problem
is to generate 50 such lists, so conceptually we want to *reshape* the
arguments of ? into 50-lists:

(50$6) ? (50$55)

but, better yet, as lots of verbs to ? will automatically reshape an atomic
argument to the shape of the other argument, so we can abbreviate the above in
one of two ways:

6 ? (50$55) NB. or
(50$6) ? 55

In the first case, the parentheses are not necessary due to J parsing rules, so
its more compact and idomatic to elide them

6 ? 50$55

These three previous options should produce the desired random tables. Now,
putting things together, we just want to "redo" the boxing we did in the
beginning example:

<"1 (6 ? 50$55)

Which should give the desired result. We need the
parenthesis to separate the 1 from the 6, otherwise J would interpret this as
<"1 6. Another way to break up the list lexing is like this:

<"1 [ 6 ? 50 $ 55

Anyway, Hui's use of &. is even nicer. The key ideas is that u&.v first runs v

on u's aguments and then *undoes* v on the result. The really neat thing is
that > is a no-op on non-boxed atoms:


42

42

So the idea is to let > be a no-op on our input array of integers, then let ?
do it's thing, and finally *undo* > on *each* result. And since undoing > is
simply doing <, we get what we want.

6 ?&.> 50 $ 55

The "each result" part above is exactly why this form is slick. ?&.> has the
rank of >, i.e. 0 0 0. This means that it will box each list produced by ? as
the integers are fed to it, which is exactly what we want in this case.

Very cool stuff. Rank!


Skip Cave  wrote:
Wow! Two completely different ways to generate multiple sets of random
integers. Roger used &. which I haven't really ever used or understood. I
will definitely need to understand &. for the future. Devon used @, which I
also haven't used very much. I need to find some practice and  training
examples to work on both concepts.

Skip Cave
Cave Consulting LLC



On Fri, Mar 13, 2020 at 12:04 AM Devon McCormick  wrote:

   6 5?@$55
Will give you a 6x5 table that is 6 independent rows of 5?55.


On Fri, Mar 13, 2020 at 12:52 AM Roger Hui 
wrote:


   6 ?&.> 5 $ 55



┌┬─┬───┬─┬───┐

│47 28 45 25 8 36│22 40 23 20 11 49│15 16 42 38 4 5│50 45 38 37 13 28│42

4

36 7 23 49│



└┴─┴───┴─┴───┘

   6 ?&.> 50 $ 55
...


On Thu, Mar 12, 2020 at 9:49 PM Skip Cave 

wrote:

How can I generate the following result extended 50 times, without

explicit

looping?

(6?55);(6?55);(6?55);(6?55);(6?55)




┌───┬───┬─┬─┬───┐

│13 4 19 43 3 52│10 1 4 46 52 11│38 12 48 50 54 45│36 54 39 35 53 50│44

1 7

54 11 41│




└───┴───┴─┴─┴───┘



Skip Cave
Cave Consulting LLC
--
For information about J forums see http://www.jsoftware.com/forums.htm


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



--

Devon McCormick, CFA

Quantitative Consultant

Re: [Jprogramming] crash

2020-03-22 Thread Don Kelly
Thanks, now i know the sense of this. I have an old printout of plot 
which gives  xlog n  but not ylog. and there it  apparently is used with 
pd.   I get the straight line  with a logarithmic scale on the y axis 
but the x axis is strange.


Don

Optional left arguments specify various characteristics the user 
requires, but
I can never remember them,  and typically run the plot lap and crib 
the scripts

accompanying the various samplers.
Evidently,   'ylog 1' plot 1 2 4 shows a straight line through (0,log 
1) (1, log2)  (2, log4)
whereas    'ylog 2' plot 1 2 4 shows a straight line through (0,log 
10) (1, log100)  (2, log1)
and            'ylog 3' plot 1 2 4 shows a straight line through 
(0,log 1e10) (1, log 1e100)  (2,  unlabelled)
... presumably the unlabelled value would be 1e1,  but I don't 
understand the y scaling, without

looking it up,  and it's late!
Mike


On 22/03/2020 23:49, Don Kelly wrote:
what is ylog ?   'ylog 1' appears to be in the same class as 'hello 
world'



On 2020-03-22 4:14 p.m., 'Michael Day' via Programming wrote:

You probably know this,  but anyway:

It's OK - well,  fails gracefully - in JQt 807 under Windows 10.

the plot window opens,  but with an error box saying:
 [  J Plot   X ]
     [ (I) |NaN error: gettplog    ]
 [   [ OK ]    ]


while on my iPad,  iOS 12.4.5,  (typing what I see there)

    'ylog 1' plot 1 0 2

|NaN error: gettplog
|  pos=.min+step*i.>:>.(max-min) %step
'ylog 1' plot 1 0 2

Cheers,
Mike


On 22/03/2020 21:45, Rudolf Sykora wrote:

Dear list,


 load 'plot'
 'ylog 1' plot 1 0 2


leads to an immediate crash of the J session for me (now win 10,
jqt901). I know that log 0 is NaN, but still...


Thanks
Ruda
--
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] crash

2020-03-22 Thread Don Kelly

what is ylog ?   'ylog 1' appears to be in the same class as 'hello world'


On 2020-03-22 4:14 p.m., 'Michael Day' via Programming wrote:

You probably know this,  but anyway:

It's OK - well,  fails gracefully - in JQt 807 under Windows 10.

the plot window opens,  but with an error box saying:
 [  J Plot   X ]
     [ (I) |NaN error: gettplog    ]
 [   [ OK ]    ]


while on my iPad,  iOS 12.4.5,  (typing what I see there)

    'ylog 1' plot 1 0 2

|NaN error: gettplog
|  pos=.min+step*i.>:>.(max-min) %step
'ylog 1' plot 1 0 2

Cheers,
Mike


On 22/03/2020 21:45, Rudolf Sykora wrote:

Dear list,


 load 'plot'
 'ylog 1' plot 1 0 2


leads to an immediate crash of the J session for me (now win 10,
jqt901). I know that log 0 is NaN, but still...


Thanks
Ruda
--
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] Derivatives

2020-02-12 Thread Don Kelly
I think that indeterminate is slightly better and seems to be the word 
generally used for mathematics.


Don

On 2020-02-11 4:53 a.m., Raul Miller wrote:

On Mon, Feb 10, 2020 at 10:12 PM Don Kelly  wrote:

I also should have written "indeterminate"

This seems to be another example where one choice being valid does not
mean that a different choice is invalid. (A common issue when using
the english language -- or, more generally, any human language.)

http://definition.org/define/indeterminant/
http://definition.org/define/indeterminate/

That said, looking at the jsoftware.com content, the latter does seem
to be used far more frequently. The only use of "indeterminant" I
could find was Adin Falkoff:

https://www.jsoftware.com/papers/apl360history.htm

Thanks,


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


Re: [Jprogramming] Derivatives

2020-02-10 Thread Don Kelly

Thank you and

On 2020-02-09 7:10 a.m., Henry Rich wrote:

See https://arxiv.org/pdf/math/9205211.pdf esp. p. 6

Henry Rich

On 2/9/2020 12:29 AM, Don Kelly wrote:
Reading again, I apologize for mistaking x^x for x*x- and getting an 
easy to get polynomial with 2 roots . Your original x^x =2*x is not 
actually a normal polynomial.Newton could be used but  the derivative 
is  so messy that a cut and try approach seems easier.


When you do to get 0^x and get _ _ _ 1 0 0 0 what you should get is

_ _ _  HUH? 0 0 0  where i am using HUH? to indicate that  for x=0 
the result is indeterminant.  Creep up on 0   and no matter how close 
to 0  you get -the results are the same. Crossing 0 is a 
discontinuous jump directly from infinity to 0


0^ - 1e1000

_

0^ 1e1000

0

0^ 10^6

0 NB: the N^0 rule doesn't apply for N=0 but J isn't recognizing this

Now if you use (10^6)^0 the result is 1 as N^0 rule has a non zero 
value.**Don



On 2020-02-06 6:23 p.m., Skip Cave wrote:


]x=.i:3

_3 _2 _1 0 1 2 3

0^x

_ _ _ 1 0 0 0


x=.0

(x^x)=2*x

0 NB. Zero is not a root

(x^x)=2*x

0

x^x

1

2*x

0


So why does Newton Raphson show a zero root for (x^x)=2*x?

(^~ - +:) Newton 2

2

(^~ - +:) Newton 1

0 NB. Something wrong here!

(x^x)=2*x ?

Skip Cave
Cave Consulting LLC


On Thu, Feb 6, 2020 at 5:38 PM Don Kelly  wrote:


Bo is correct

There is a "zero rule"  so n^0 =1 if n is not equal to 0. Bo is 
correct


the only possible 0^0 is the same as 0*0

Possibly the coding for ^ should take this into account.



On 2020-02-05 10:14 p.m., Skip Cave wrote:

Bo,
The original equation is:
(x^x)=2*x
2 is clearly a root. 0 is clearly not, as 0^0 = 1


Skip Cave



On Wed, Feb 5, 2020 at 2:37 PM 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:

   Skip.  (x^x)-(2*x) = x*(x-2) is zero for x=0 and x=2. Two real 
roots.
Newton Raphson finds one of these depending on the value of the 
initial

guess.
Bo.
  Den onsdag den 5. februar 2020 19.08.23 CET skrev Henry Rich <
henryhr...@gmail.com>:

   Yeah, a rational y wouldn't ever quite satisfy 0 = _2 0 1 p. y

Henry Rich

On 2/5/2020 1:04 PM, Devon McCormick wrote:

You especially need guardrails if you try something like this:
 _2 0 1 Newton 1  NB. OK - square root of 2
1.41421
 _2 0 1 Newton 1x    NB. Try extended precision
 C-c C-c|break    NB. After waiting a while...
|  _2 0 1 1
 NB. Failure to terminate...


On Wed, Feb 5, 2020 at 7:34 AM Henry Rich 

wrote:

I misread your function.

   (^~ - +:) Newton 1.1
0.346323j1.2326e_32
   (^~ - +:) Newton 0.5
0.346323

Still need those guardrails!

Henry Rich

On 2/5/2020 2:21 AM, Skip Cave wrote:
In "Fifty Shades of J" chapter 23, the Newton Raphson 
algorithm is

described thusly:

Newton =: adverb : ']-u%(u D.1)'(^:_)("0)

How would that be defined using the new derivative verbs?

Also, what is the replacement for d.?

How would I find the roots of (x^x)=2*x using Newton Raphson?

Skip

Skip Cave
Cave Consulting LLC


--

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


-- 

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


--
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

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


Re: [Jprogramming] Derivatives

2020-02-10 Thread Don Kelly
Thank you for this.  I agree and my point is that n^0 is 1 if n is not 0 
but 0^n is another kettle of fish. However, in applying the mat to the 
real world, I cannot think of anything where such discontinuity actually 
exists-so it is a nice philosophical matter. I've looked at Knuth and am 
not sure, without a lot further study  which I am not going to do.


I also should have written "indeterminate"

Don

On 2020-02-09 10:26 a.m., Raul Miller wrote:

On Sun, Feb 9, 2020 at 12:29 AM Don Kelly  wrote:

_ _ _  HUH? 0 0 0  where i am using HUH? to indicate that  for x=0 the
result is indeterminant.  Creep up on 0   and no matter how close to 0
you get -the results are the same. Crossing 0  is a discontinuous jump
directly from infinity to 0

indeterminant is a good way of putting this.

On Sun, Feb 9, 2020 at 10:11 AM Henry Rich  wrote:

See https://arxiv.org/pdf/math/9205211.pdf esp. p. 6

I think you're referring to Knuth's allusions to Cauchy's treatment of
Principal Value?

I tried reading through Knuth's writeup there for his take on
https://en.wikipedia.org/wiki/Principal_value in this context. But it
felt like he only got close to that topic, without actually addressing
it.

Taking a few steps back, from my perspective (viewing mathematics as
approaches for dealing with systems of carefully chosen constraints),
An expression of the form:

x = y ^ 0

can be viewed as a constraint on the value of x, such that

y = y ^ 1

Or: x is a number which when multiplied by y gives a result of y. And,
for example, if y is 2 then x is 1.

But when y is 0, any number works for x. So, it's "indeterminant".
This doesn't mean that 1 is an incorrect answer, but it does mean that
it's not the only answer.

But this particular situation is not the only example where
mathematics allows for multiple answers. Square root is another
example.

In J, 1 = %: 1 even though 1 = _1 * _1

And functions like arcsin (_1) have a theoretical infinite number
of solutions, though it's common practice to neglect that issue when
performing calculations.

But the problem with 0^0 isn't so much that the result is unknown, but
that it's difficult to even talk about a number which would not work
in that context. And, that's dangerous ground for mathematical
discussion.

Anyways... in my opinion, this is definitely a "don't overthink it"
topic. (What some people might carelessly call "a waste of time").

Thanks,


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


Re: [Jprogramming] Derivatives

2020-02-08 Thread Don Kelly
Reading again, I apologize for mistaking x^x for x*x- and getting an 
easy to get polynomial with 2 roots . Your original x^x =2*x is not 
actually a normal polynomial.Newton could be used but  the derivative 
is  so messy that a cut and try approach seems easier.


When you do to get 0^x and get _ _ _ 1 0 0 0 what you should get is

_ _ _  HUH? 0 0 0  where i am using HUH? to indicate that  for x=0 the 
result is indeterminant.  Creep up on 0   and no matter how close to 0  
you get -the results are the same. Crossing 0  is a discontinuous jump 
directly from infinity to 0


0^ - 1e1000

_

0^ 1e1000

0

0^ 10^6

0 NB: the N^0 rule doesn't apply for N=0 but J isn't recognizing this

Now if you use (10^6)^0 the result is 1 as N^0 rule has a non zero value.**Don


On 2020-02-06 6:23 p.m., Skip Cave wrote:


]x=.i:3

_3 _2 _1 0 1 2 3

0^x

_ _ _ 1 0 0 0


x=.0

(x^x)=2*x

0 NB. Zero is not a root

(x^x)=2*x

0

x^x

1

2*x

0


So why does Newton Raphson show a zero root for (x^x)=2*x?

(^~ - +:) Newton 2

2

(^~ - +:) Newton 1

0 NB. Something wrong here!

(x^x)=2*x ?

Skip Cave
Cave Consulting LLC


On Thu, Feb 6, 2020 at 5:38 PM Don Kelly  wrote:


Bo is correct

There is a "zero rule"  so n^0 =1 if n is not equal to 0. Bo is correct

the only possible 0^0 is the same as 0*0

Possibly the coding for ^ should take this into account.



On 2020-02-05 10:14 p.m., Skip Cave wrote:

Bo,
The original equation is:
(x^x)=2*x
2 is clearly a root. 0 is clearly not, as 0^0 = 1


Skip Cave



On Wed, Feb 5, 2020 at 2:37 PM 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:


   Skip.  (x^x)-(2*x) = x*(x-2) is zero for x=0 and x=2. Two real roots.
Newton Raphson finds one of these depending on the value of the initial
guess.
Bo.
  Den onsdag den 5. februar 2020 19.08.23 CET skrev Henry Rich <
henryhr...@gmail.com>:

   Yeah, a rational y wouldn't ever quite satisfy 0 = _2 0 1 p. y

Henry Rich

On 2/5/2020 1:04 PM, Devon McCormick wrote:

You especially need guardrails if you try something like this:
 _2 0 1 Newton 1  NB. OK - square root of 2
1.41421
 _2 0 1 Newton 1xNB. Try extended precision
 C-c C-c|breakNB. After waiting a while...
|  _2 0 1 1
 NB. Failure to terminate...


On Wed, Feb 5, 2020 at 7:34 AM Henry Rich 

wrote:

I misread your function.

   (^~ - +:) Newton 1.1
0.346323j1.2326e_32
   (^~ - +:) Newton 0.5
0.346323

Still need those guardrails!

Henry Rich

On 2/5/2020 2:21 AM, Skip Cave wrote:

In "Fifty Shades of J" chapter 23, the Newton Raphson algorithm is
described thusly:

Newton =: adverb : ']-u%(u D.1)'(^:_)("0)

How would that be defined using the new derivative verbs?

Also, what is the replacement for d.?

How would I find the roots of (x^x)=2*x using Newton Raphson?

Skip

Skip Cave
Cave Consulting LLC


--

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

--
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


--
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] Derivatives

2020-02-06 Thread Don Kelly

Bo is correct

There is a "zero rule"  so n^0 =1 if n is not equal to 0. Bo is correct

the only possible 0^0 is the same as 0*0

Possibly the coding for ^ should take this into account.



On 2020-02-05 10:14 p.m., Skip Cave wrote:

Bo,
The original equation is:
(x^x)=2*x
2 is clearly a root. 0 is clearly not, as 0^0 = 1


Skip Cave



On Wed, Feb 5, 2020 at 2:37 PM 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:


  Skip.  (x^x)-(2*x) = x*(x-2) is zero for x=0 and x=2. Two real roots.
Newton Raphson finds one of these depending on the value of the initial
guess.
Bo.
 Den onsdag den 5. februar 2020 19.08.23 CET skrev Henry Rich <
henryhr...@gmail.com>:

  Yeah, a rational y wouldn't ever quite satisfy 0 = _2 0 1 p. y

Henry Rich

On 2/5/2020 1:04 PM, Devon McCormick wrote:

You especially need guardrails if you try something like this:
_2 0 1 Newton 1  NB. OK - square root of 2
1.41421
_2 0 1 Newton 1xNB. Try extended precision
C-c C-c|breakNB. After waiting a while...
|  _2 0 1 1
NB. Failure to terminate...


On Wed, Feb 5, 2020 at 7:34 AM Henry Rich  wrote:


I misread your function.

  (^~ - +:) Newton 1.1
0.346323j1.2326e_32
  (^~ - +:) Newton 0.5
0.346323

Still need those guardrails!

Henry Rich

On 2/5/2020 2:21 AM, Skip Cave wrote:

In "Fifty Shades of J" chapter 23, the Newton Raphson algorithm is
described thusly:

Newton =: adverb : ']-u%(u D.1)'(^:_)("0)

How would that be defined using the new derivative verbs?

Also, what is the replacement for d.?

How would I find the roots of (x^x)=2*x using Newton Raphson?

Skip

Skip Cave
Cave Consulting LLC
--
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

--
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] feature request: negative copy fill

2020-02-02 Thread Don Kelly

Why not this?

'  ',1j2#data   NB. 2 spaces in '' fixed width characters

a b r a c a d a b r a

3 ": i.~ data

0 1 2 0 4 0 6 0 1 2 0


Don Kelly



On 2020-02-02 2:15 a.m., Marshall Lochbaum wrote:

Assuming you want all fills to come before the corresponding element,
you can use:

1j2 #&.|. data
   a  b  r  a  c  a  d  a  b  r  a

I agree that fill-before is a reasonable interpretation for a negative
imaginary part, although I doubt J's complex replicate, or APL's expand,
are really the best way to deal with inserting fills (I don't have a
better one).

Marshall

On Sat, Feb 01, 2020 at 11:46:24AM -0500, David Lambert wrote:

data=:'abracadabra'

NB. whereas
1j_2 # data
|domain error
|   1j_2#data

NB. I've often wanted
_2 |. 1j2 # data
   a  b  r  a  c  a  d  a  b  r  a

NB. because it aligns with

3 ": i.~ data  NB. index from left
   0  1  2  0  4  0  6  0  1  2  0

3 ": i:~ data  NB. index from right
  10  8  9 10  4 10  6 10  8  9 10

duplicate =: (i: ~: i.)~
duplicate data
1 1 1 1 0 1 0 1 1 1 1
--
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] Geometric algebra

2019-11-25 Thread Don Kelly

you can also look at the base vectors using complex numbers

+. +/ 2.3 0j3.9 3.1

5.4 3.9


Don Kelly


On 2019-11-25 1:39 p.m., 'Bo Jacoby' via Programming wrote:

  Enumerate your base vectors 1 0 and 0 1 etc.

    (2.3*1 0)+(3.9*0 1)+(3.1*1 0)

5.4 3.9



Thanks.
Bo.Den mandag den 25. november 2019 19.45.04 CET skrev Raul Miller 
:
  
  Or, slightly more efficient (if that matters):


   V1=: |:(2 3 4;2.3),(1 2;3.9),: 2 3 4;3.1
   V2=: (~.@{.,:+/&.:>/./)V1
   V2-:|:(2 3 4;5.4),: 1 2;3.9

(Caution: email clients have become hostile to copy, and may not
represent code accurately.)

Thanks,


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


Re: [Jprogramming] Creating a distance matrix.

2019-10-28 Thread Don Kelly
Rather than "assigning " indices, use the actual node positions and what 
is done to make a suntraction (or other)  table, which is the same proplem.


In the case of all nodes being on a line at positions 0 1.5 2 2.5 3 the 
matrix would be given by


dij=: |@ -/~ 0 1.5 2 2.5 3

0 1.5 2 2.5 3

1.5 0 0.5 1 1.5

2 0.5 0 0.5 1

2.5 1 0.5 0 0.5

3 1.5 1 0.5 0

Note that if positions are on a plane, this still works- using complex 
numbers to represent positions


dij 0 1.5 0j_1.5 1.5j_1.5 2j2

0 1.5 1.5 2.12132 2.82843

1.5 0 2.12132 1.5 2.06155

1.5 2.12132 0 1.5 4.03113

2.12132 1.5 1.5 0 3.53553

2.82843 2.06155 4.03113 3.53553

Don Kelly

On 2019-10-22 9:35 a.m., pe...@easthope.ca wrote:

Given a fully connected graph of n nodes.
The nodes are assigned indices i.n arbitrarily.
D is a distance matrix.  Eg.
n =. 4
] D =. 4 4 $ 0 1.5 2 2.5  1.5 0 1.5 2  2 1.5 0 1.5  2.5 2 1.5 0

I'm not claiming this matrix fits in Euclidean geometry.
Nevertheless each element on the diagonal is 0 and
the matrix is symmetrical.

Can anyone suggest a more efficient way to create the
matrix.  Only (n * (n-1))%2 elements of D are unique.
Each unique elecment should be needed only once to build
the matrix.

Thanks,Peter E.




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


Re: [Jprogramming] Creating a distance matrix.

2019-10-24 Thread Don Kelly
I am a loss as to the actual location of the points in space. However, 
if the points are all on a plane, the positions can be expressed as 
complex numbers. I so the following  (useful. in power line analysis)


dij=: |@ -/~

dij 0 1 1.5 0j1.5 1j2

0 1 1.5 1.5 2.23607

1 0 0.5 1.80278 2

1.5 0.5 0 2.12132 2.06155

1.5 1.80278 2.12132 0 1.11803

2.23607 2 2.06155 1.11803 0

Does this help?

Don Kelly


the positions are expressed as complex numbers and the

On 2019-10-22 8:38 p.m., 'Jim Russell' via Programming wrote:

Wow!



On Oct 22, 2019, at 4:00 PM, Raul Miller  wrote:

Probably worth noting also that I could have instead said:

   D=: (+|:)>0;1.5;2 1.5;2.5 2 1.5 0

This is actually one character shorter than my previous expression...

Thanks,

--
Raul


On Tue, Oct 22, 2019 at 2:29 PM  wrote:

From:   Raul Miller 
Date:   Tue, 22 Oct 2019 13:29:19 -0400

What do you mean by "more efficient"? (What resource is constrained?)

I listed all 16 elements of the matrix.  It being symmetrical with 0s
on the diagonal, only 6 elements should be needed.  Rather than "more
efficient", better wording might have been "without redundant
information".  I might say "more efficient in use of information".


That said, if it's code golf, you could do something like this:

I didn't know the term "code golf" but it seems appropriate.


If you are working on problems where that's not enough to
work on your dataset, ...

At present I'm interested only in expressing concepts.  Computational
cost is not a concern at all.


   D=: (+|:)>'';1.5;2 1.5;2.5 2 1.5 0

This relies on the use of two placeholders to help represent the full
extent of the array, J's fill mechanism, and addition...

Thanks.  Definitely helpful.  I could create the matrix in a
commonplace compiled language without help.  Thinking about the
calculation in J is worthwhile.

Thanks again, ... P.


--
https://en.wikibooks.org/wiki/Medical_Machines
Tel: +1 604 670 0140Bcc: peter at easthope. ca

--
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

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


Re: [Jprogramming] Joey's %. benchmark

2019-09-08 Thread Don Kelly
Sorry to have omitted this info. Timings for inverting the original 
matrix  about 0.00025 sec  and for inverting the inverse, essentially 
the same.


Don

On 2019-09-08 7:09 p.m., Don Kelly wrote:
I have used the same approach as Joey for some time now and note that 
there have been quite amazing jumps  (avx helps) I  usually start with 
an integer array such as 1+10?1 and save it -then repeat with 
%. on the floating point result with  negligible differences in 
timing.  Storage time is insignificant and seem to be faster for the 
floating point array. Errors in multiplication of the matrix and its 
inverse  gives a unit matrix with off diagonal errors of the order of 
10^13 or less in magnitude.


Don

901-beta i

AMD a10-7800  windows 10


On 2019-09-08 1:56 p.m., Henry Rich wrote:
What I meant you couldn't have known is how much work would go into 
cache-friendly matrix multiply in J.


Henry Rich

On 9/8/2019 4:37 PM, Roger Hui wrote:

A J model of the QR decomposition can be found in
http://code.jsoftware.com/wiki/Essays/QR_Decomposition


He builded better than he knew: it relies on +/ .* for most of the

numeric work.

(Ahem) actually I knew.  It was part of my M.Sc. thesis and is another
lemma which shows that %.x has the same order of complexity as +/ .* 
, at

the time O(n*2^.7) (better than the conventional O(n*3)), now down to
O(n*2.3728639) according to Wikipedia.  The algorithm is also good 
answer

to claims that QR and other matrix decompositions are inherently loopy.
See Hui & Iverson, _A Note on Programming Style_, Vector, volume 12, 
number

13, 1996-01.





On Sun, Sep 8, 2019 at 1:14 PM Henry Rich  wrote:


For years Joey Tuttle has used the performance of (%. y) as a simple
measure of the performance of J releases.  It has improved pretty 
steadily.


This surprised me, because I know where the gaussian-elimination code
is, and that code doesn't do much except C loops that do add and
subtract.  I didn't see how improvements to the JE would have any 
effect

on (%. y).  Not wanting to mess up a good story, I kept my doubts to
myself.

Finally I understand.  The code I had been looking at is used only for
rational matrices.  The code for general (%. y) is a lovely little
recursive QR decomposition that does lots of memory allocation and 
calls

to internal J arithmetic functions.  In fact, it's a pretty good
exercise of the computational side of the system.  It's quite short 
but

uses general utilities so that it works on all fixed-precision numeric
types.  Bravo to Roger.  He builded better than he knew: it relies 
on +/
. * for most of the numeric work, and that code has now been 
polished so

well that it is the most efficient code in the system.

Long live Joey's benchmark!

Henry Rich

---
This email has been checked for viruses by AVG.
https://www.avg.com

--
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

--
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] Joey's %. benchmark

2019-09-08 Thread Don Kelly
I have used the same approach as Joey for some time now and note that 
there have been quite amazing jumps  (avx helps) I  usually start with 
an integer array such as 1+10?1 and save it -then repeat with %. 
on the floating point result with  negligible differences in timing.  
Storage time is insignificant and seem to be faster for the floating 
point array. Errors in multiplication of the matrix  gives a unit matrix 
with off diagonal errors of the order of 10^13 or less in magnitude.


Don

901-beta i

AMD a10-7800  windows 10


On 2019-09-08 1:56 p.m., Henry Rich wrote:
What I meant you couldn't have known is how much work would go into 
cache-friendly matrix multiply in J.


Henry Rich

On 9/8/2019 4:37 PM, Roger Hui wrote:

A J model of the QR decomposition can be found in
http://code.jsoftware.com/wiki/Essays/QR_Decomposition


He builded better than he knew: it relies on +/ .* for most of the

numeric work.

(Ahem) actually I knew.  It was part of my M.Sc. thesis and is another
lemma which shows that %.x has the same order of complexity as +/ .* 
, at

the time O(n*2^.7) (better than the conventional O(n*3)), now down to
O(n*2.3728639) according to Wikipedia.  The algorithm is also good 
answer

to claims that QR and other matrix decompositions are inherently loopy.
See Hui & Iverson, _A Note on Programming Style_, Vector, volume 12, 
number

13, 1996-01.





On Sun, Sep 8, 2019 at 1:14 PM Henry Rich  wrote:


For years Joey Tuttle has used the performance of (%. y) as a simple
measure of the performance of J releases.  It has improved pretty 
steadily.


This surprised me, because I know where the gaussian-elimination code
is, and that code doesn't do much except C loops that do add and
subtract.  I didn't see how improvements to the JE would have any 
effect

on (%. y).  Not wanting to mess up a good story, I kept my doubts to
myself.

Finally I understand.  The code I had been looking at is used only for
rational matrices.  The code for general (%. y) is a lovely little
recursive QR decomposition that does lots of memory allocation and 
calls

to internal J arithmetic functions.  In fact, it's a pretty good
exercise of the computational side of the system.  It's quite short but
uses general utilities so that it works on all fixed-precision numeric
types.  Bravo to Roger.  He builded better than he knew: it relies 
on +/
. * for most of the numeric work, and that code has now been 
polished so

well that it is the most efficient code in the system.

Long live Joey's benchmark!

Henry Rich

---
This email has been checked for viruses by AVG.
https://www.avg.com

--
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

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


Re: [Jprogramming] full screen windows?

2019-09-01 Thread Don Kelly
With windows: most other programs and apps do have the upper line 
-exceptions that I see are some graphic games and photo  displays . 
However with J having the title bars shown-great as it allows access to 
related items such as Vocabulary etc. If you want a snapshot without 
this there is a windows snipping tool which will save what you want as a 
jpg. It works well.


Don Kelly

On 2019-09-01 11:56 a.m., Michal Wallace wrote:

Hrm. Thanks, but I'm on windows, and also I should have specified that I'm
talking about a qt window created with the window driver.
QT does seem to have this feature, but I'm not sure how to get at it from J:

https://stackoverflow.com/questions/9014298/full-screen-desktop-application-with-qml



On Sat, Aug 31, 2019 at 2:23 PM Bill Heagy  wrote:


on linux, at least, F11 does that

On 8/31/19 12:28 PM, Michal Wallace wrote:

How can I make a jQt window full screen?
(i.e., maximized, but *also* filling up the whole screen and hiding the
title bar)
--
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

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


Re: [Jprogramming] 901 beta-i

2019-08-31 Thread Don Kelly

Got it, thanks

Don

On 2019-08-29 8:12 a.m., Eric Iverson wrote:

A j901 beta-i release is available that fixed a few problems in the recent
beta-h release.

If your 9!:14'' or JVERSION indicates you are running beta-h, then you
should be able to get beta-i with:

load'pacman'
je_update_jpacman_''

If you are running an older version then you need a few extra steps:

pacman update to the latest base library
load'pacman'' NB. load latest version
je_update_jpacman_''
restart J
je_update_jpacman_'' NB. 2nd time might get an advanced hardware version
if you system supports it
--
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] converting from 'floating' to 'rational'

2019-03-30 Thread Don Kelly
eyed precision-freak. I use iterative methods to
calculate functions that solve equations, and I see rounding errors build
up exponentially, making my algorithms go unstable. Eliminating rounding
errors by performing these algorithms in rational arithmetic is something
that needs to be tried. And I've just begun trying it.

Yes, at the end of the day computed quantities need to be displayed, and
conventionally such displays entail decimal numbers. Which need to be
chopped off at the right-hand end somewhere.

That's not my department. I'll let my user see as many places of decimals
as she's the stomach for. Even if (like Ellie in Carl Sagan's novel
"Contact") she's looking for a personal message from a galactic
intelligence in the far digits of π.

Ian Clark

On Thu, 28 Mar 2019 at 02:27, Devon McCormick  wrote:


Ian - could your display problem be solved by always formatting displays
but retaining arbitrary internal precision?  You probably already do this
but thought I'd mention it because I just had to format a correlation
matrix to show only two digits of precision, but was annoyed that my
rounding fnc was showing me things like "0.01" and "0.2001"
when I rediscovered "8!:0" and looked up how to format a number properly.


On Wed, Mar 27, 2019 at 7:57 PM Don Kelly  wrote:


Probalbly the main problem, as exemplified in the "sine(a) problem is
that a and sine a are the same within 10e-16 and the cosine is 1-7.5e-5
but the display is only 6 figures and so the displayed result is rounded
to 1.  as it is closer to 1 than 0.99.  This is grade 8
rounding.Increasing the numerical accuracy won't help but increasing the
display to say 12 digits might show something other (such as
0.9993).

Also, looking at the Tabula "church clock" somehow data which  is of 2
to 3 figure accuracy  is represented as  6 figure print precision
accuracy.  A height of 75 ft is of 2 figure accuracy  or 75+/_ 0.5 lb
is being presented in display as 75.000  and calculated to a greater
number of digits internally. The is doesn't mean that 75 is 75.0 nor
75.000 etc. Using 64 digit floating point simply reduces computer error
((partly due to converting from base 2 to base 10) hich but doesn't give
more accuracy than is present in the input data (neither does hand
calculation).  1r3 will be, in decimal form 0.333 ad nauseum no
matter how you do it and somewhere at the limit of the computer and real
world, it is rounded at some point.

Don Kelly

On 2019-03-27 11:32 a.m., Ian Clark wrote:

Raul wrote:

So I am curious about the examples driving your concern here.

I'm in the throes of converting TABULA (
https://code.jsoftware.com/wiki/TABULA ) to work with rationals

instead

of

floats. Or more accurately, the engines CAL and UU which TABULA uses.

No, I don't need to offer the speed of light to more than 10

significant

digits. My motivation has little to do with performing a particular
scientific calculation, and everything to do with offering a
general-purpose tool and rubbing down the rough edges as they emerge.

It's

a game of whack-the-rat.

The imprecision of working with floating-point numbers shows up so

often

with TABULA that I haven't bothered to collect examples. In just about
every session I hit an instance or ten. But it's worse when using the

tool

to demonstrate technical principles to novices, rather than do mundane
calculations, because in the latter case it would be used by an

engineer

well-versed in computers and the funny little ways of floating point,
tolerant comparisons and binary-to-decimal conversion. But a novice is

apt

to suffer a crisis of confidence when she sees (sin A)=1.23E-5 in the

same

display as (cos A)=1. Even hardened physicists wince.

Two areas stand out:
• Infinitestimals, i.e. intermediate values which look like zero – and
ought to be zero – but aren't. They act like grit in the works.
• Backfitting, where the user overtypes a calculated value and CAL

backfits

suitable input values, for which it mainly uses N-R algorithms – which
don't like noisy values.

It's too early to say yet – I have to finish the conversion and think

up

examples to stress-test it before I can be sure the effort is

worthwhile.

So far I've only upgraded UU (the units-conversion engine), but already
some backfitting examples which were rather iffy are hitting the target
spot-on: particularly where the slope of the "hill" being climbed is

nearly

zero. Even I succumb to feelings of pleasure to see (sin A)=0 in the

same

display as (cos A)=1.

But knowing the innards of CAL, I can't understand how it can possibly

be

showing benefits at this early stage. Perhaps UU's rational values are
leaking further down the cascade of calculations than I expected? I'd

love

to get to the bottom of it, but my systematic "rationalization" of the

CAL

code will destroy the evidence, just as exploring Mars wil

Re: [Jprogramming] converting from 'floating' to 'rational'

2019-03-27 Thread Don Kelly
Probalbly the main problem, as exemplified in the "sine(a) problem is 
that a and sine a are the same within 10e-16 and the cosine is 1-7.5e-5 
but the display is only 6 figures and so the displayed result is rounded 
to 1.  as it is closer to 1 than 0.99.  This is grade 8 
rounding.Increasing the numerical accuracy won't help but increasing the 
display to say 12 digits might show something other (such as 
0.9993).


Also, looking at the Tabula "church clock" somehow data which  is of 2 
to 3 figure accuracy  is represented as  6 figure print precision 
accuracy.  A height of 75 ft is of 2 figure accuracy  or 75+/_ 0.5 lb  
is being presented in display as 75.000  and calculated to a greater 
number of digits internally. The is doesn't mean that 75 is 75.0 nor 
75.000 etc. Using 64 digit floating point simply reduces computer error 
((partly due to converting from base 2 to base 10) hich but doesn't give 
more accuracy than is present in the input data (neither does hand 
calculation).  1r3 will be, in decimal form 0.333 ad nauseum no 
matter how you do it and somewhere at the limit of the computer and real 
world, it is rounded at some point.


Don Kelly

On 2019-03-27 11:32 a.m., Ian Clark wrote:

Raul wrote:

So I am curious about the examples driving your concern here.

I'm in the throes of converting TABULA (
https://code.jsoftware.com/wiki/TABULA ) to work with rationals instead of
floats. Or more accurately, the engines CAL and UU which TABULA uses.

No, I don't need to offer the speed of light to more than 10 significant
digits. My motivation has little to do with performing a particular
scientific calculation, and everything to do with offering a
general-purpose tool and rubbing down the rough edges as they emerge. It's
a game of whack-the-rat.

The imprecision of working with floating-point numbers shows up so often
with TABULA that I haven't bothered to collect examples. In just about
every session I hit an instance or ten. But it's worse when using the tool
to demonstrate technical principles to novices, rather than do mundane
calculations, because in the latter case it would be used by an engineer
well-versed in computers and the funny little ways of floating point,
tolerant comparisons and binary-to-decimal conversion. But a novice is apt
to suffer a crisis of confidence when she sees (sin A)=1.23E-5 in the same
display as (cos A)=1. Even hardened physicists wince.

Two areas stand out:
• Infinitestimals, i.e. intermediate values which look like zero – and
ought to be zero – but aren't. They act like grit in the works.
• Backfitting, where the user overtypes a calculated value and CAL backfits
suitable input values, for which it mainly uses N-R algorithms – which
don't like noisy values.

It's too early to say yet – I have to finish the conversion and think up
examples to stress-test it before I can be sure the effort is worthwhile.
So far I've only upgraded UU (the units-conversion engine), but already
some backfitting examples which were rather iffy are hitting the target
spot-on: particularly where the slope of the "hill" being climbed is nearly
zero. Even I succumb to feelings of pleasure to see (sin A)=0 in the same
display as (cos A)=1.

But knowing the innards of CAL, I can't understand how it can possibly be
showing benefits at this early stage. Perhaps UU's rational values are
leaking further down the cascade of calculations than I expected? I'd love
to get to the bottom of it, but my systematic "rationalization" of the CAL
code will destroy the evidence, just as exploring Mars will destroy the
evidence for indigenous life. Too bad: I'm not aiming at CAL working
occasionally, but every time.

Thanks for reminding me about digits separation. Yes, my numeral converter
(I find I'm mainly working with numerals than numeric atoms) can already
handle standard scientific notation, like '6.62607015E-34' -- plus a few
J-ish forms like '1p1'. I only had to type-in π to 50 places of decimals to
feel the need for some form of digit separation (…a good tool should
support ALL forms!) e.g.  '6.626,070,15E-34' but was unconsciously assuming
(y -. ',') would handle it.

…It won't. SI specifies spaces as digit separators, and Germany uses commas
where the UK and USA use dots, e.g. '6,626 070 15E-34'. Okay, fine… but in
places I detect the first space in a (string) quantity to show where the
numeral stops and the units begin. Ah well… another rat to whack.

Ian


On Wed, 27 Mar 2019 at 15:16, Raul Miller  wrote:


On Tue, Mar 26, 2019 at 7:38 PM Ian Clark  wrote:

I will still employ my "mickey-mouse" method, because it's easily checked
once it's coded. I need built-into TABULA a number of physical constants
which the SI defines exactly, e.g.
• The thermodynamic temperature of the triple point of water, Ttpw , is
273.16 K *exactly*.
• The speed of light in vacuo is 299792458 m/s *exactly*.

The first I can generate and handle as: 27316

Re: [Jprogramming] Adding leading zeros

2019-02-05 Thread Don Kelly

Thanks,  Raul

On 2019-02-05 8:09 a.m., Raul Miller wrote:

A more compact variant, in case anyone wants that (though, granted,
without safety measures):

d12a=: 0 1}.]":@+10x^[
4 d12a a
0001
0002
0003
0010
0020
0030
0100
0200
0300
0400
1000
2000
3000

A "safer" version would be:
d12b=: -@[{."1]":@+10x^[

(Same result, for this example, but properly truncates extra digits in
right argument.)

(Note also that you'll need an x in your numeric argument if it
exceeds 1.8e19 by much -- or I think this limit might have been 9e15
in older versions of J...  Anyways, d12b could be made to be "safer"
(closer to accurate) for arguments which exceed this limit, but that
could only hide part of the error.)

And... d12a/d12b use nines complement representation for negative numbers.

--
Raul

On Mon, Feb 4, 2019 at 10:20 PM Don Kelly  wrote:

Phrases 13C gives

d12=: [:}."1[:": (10"_^[)+([:,.])

Format list y as x-wide col with leading 0s

a=: 1 2 3 10 20 30 100 200 300 400 1000 2000 3000
4 d12 a
0001
0002
0003
0010
0020
0030
0100
0200
0300
0400
1000
2000
3000

The column form serves well in making a number list for tickets using
clipwrite  to put in word or writer.


Don Kelly

On 2019-02-03 11:15 a.m., 'Skip Cave' via Programming wrote:

Paolo and Devon provided the named dyadic verbs Fill and lead0s that
perform the function I specified. Devon's verb has some extra bells and
whistles which I like.
Roger pointed out that the built-in format function 8!:2 allows a fill
option, but with my limited J expertise I wasn't able to turn Roger's
example into a named dyadic verb.
I liked R.E. Boss' approach, as it automatically sets the number of
characters, given the number of characters in the largest integer, as that
would work for my current problem. Again, however, I don't know how to turn
that verb into a named monadic verb.
All in all, I learned quite a lot from this exercise.

Skip


On Sun, Feb 3, 2019 at 2:36 AM Skip Cave  wrote:


What's the best way to add leading zeros to a set of integers. How to
design a verb f, that does the following:

 a =.  1 2 3 4 5 10 20 30 40 50 100 200 300 400 500 1000 2000 3000 4000
5000
4 f a NB. make each integer a total of 4 digits using leading zeros.
0001 0002 0003 0004 0005 0010 0020 0030 0040 0050 0100 0200 0300 0400 0500
1000 2000 3000 4000 5000

Skip



--
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

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

Re: [Jprogramming] Adding leading zeros

2019-02-04 Thread Don Kelly

Phrases 13C gives

d12=: [:}."1[:": (10"_^[)+([:,.])

Format list y as x-wide col with leading 0s

a=: 1 2 3 10 20 30 100 200 300 400 1000 2000 3000

4 d12 a

0001

0002

0003

0010

0020

0030

0100

0200

0300

0400

1000

2000

3000

The column form serves well in making a number list for tickets using 
clipwrite  to put in word or writer.



Don Kelly

On 2019-02-03 11:15 a.m., 'Skip Cave' via Programming wrote:

Paolo and Devon provided the named dyadic verbs Fill and lead0s that
perform the function I specified. Devon's verb has some extra bells and
whistles which I like.
Roger pointed out that the built-in format function 8!:2 allows a fill
option, but with my limited J expertise I wasn't able to turn Roger's
example into a named dyadic verb.
I liked R.E. Boss' approach, as it automatically sets the number of
characters, given the number of characters in the largest integer, as that
would work for my current problem. Again, however, I don't know how to turn
that verb into a named monadic verb.
All in all, I learned quite a lot from this exercise.

Skip


On Sun, Feb 3, 2019 at 2:36 AM Skip Cave  wrote:


What's the best way to add leading zeros to a set of integers. How to
design a verb f, that does the following:

a =.  1 2 3 4 5 10 20 30 40 50 100 200 300 400 500 1000 2000 3000 4000
5000
4 f a NB. make each integer a total of 4 digits using leading zeros.
0001 0002 0003 0004 0005 0010 0020 0030 0040 0050 0100 0200 0300 0400 0500
1000 2000 3000 4000 5000

Skip



--
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] Release-a j807 problem with plot

2019-01-17 Thread Don Kelly
No problems with plot on win 10/64 AMDA10-7800 (avx) Asus mother 
board-regular relatively cheap computer. As a side note the time for 
inverting a 100x100 matrix is a lot faster in 807 than 806


Don Kelly


On 2019-01-17 11:10 a.m., Eric Iverson wrote:

Could be a nonavx error. Isolating the problem a bit would help us greatly.

An expression and data that fails from a clean start would be best.

A a failure in linux would be better than mac (and windows even better,
although I realize unlikely).

Am I right that it looks like a code bug rather than hardware? That is, avx
works and nonavx fails on the same machine,

On Thu, Jan 17, 2019 at 1:49 PM Henry Rich  wrote:


Any chance you can see what the values are on that failing line, in case
the error is in that line?

Henry Rich

On 1/17/2019 1:45 PM, Joey K Tuttle wrote:

   dat=.}:"1(y,.1)mp Tfm


---
This email has been checked for viruses by AVG.
https://www.avg.com

--
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] Square Roots and Extended Arithmetic

2018-11-01 Thread Don Kelly
Heron was ahead of his time- this is actually   now called Newton 
Rhapson   iteration . The basic process can be used to solve  some very 
large order (in variables) simultaneous non-linear equations   as in 
power system  load flow  problems that can have hundreds or more 
variables (first applied to these problems in the 1960's - a time when 
many numerical analysts didn't think there was a need to deal with 
anything near as many variables.


I recall showing my youngest son this when he first encountered square 
roots.


Don Kelly



On 2018-11-01 12:53 PM, Jimmy Gauvin wrote:

Hi,

A good read on the subject of square roots :

A Perfect Square Root Routine
E.E. McDonnell
http://www.jsoftware.com/papers/eem/sqrt.htm

On Thu, Nov 1, 2018 at 3:32 PM Raul Miller  wrote:


Square roots cannot (in the typical case) be represented using
extended precision numbers (which are integers).

a=:1234567890101020405060708090x
a^1r2
3.51364e13
datatype a^1r2
floating

This floating representation represents numbers using a representation of
sign * 1+fraction * 2^exponent

This all fits into a 64 bit representation with one bit for sign
(choosing from 1 or _1), 52 bits for the fraction, and the remaining
11 bits for the exponent (with a few exponent values reserved for
handling infinities and "NaN" numbers). (All arranged so that the same
less than / greater than logic used for integers will also work for
floating point numbers.)

But the (a) value is not a square number:

__ q: a
2 5 211 461 23339 54381270850093261
1 1   1   1 1 1

If it were square, the values in the second row of that result would
all be even numbers.

So that means that a precise representation of the square root would
take an infinite number of bits in the floating point fraction, which
is more than the 52 bits which get used.

Anyways, if you want a better approximation of the square root, you'd
probably use the floating point value as a starting point and then use
some algorithm to improve that estimate until it seems good enough.

--
Raul





FYI,

--
Raul
On Thu, Nov 1, 2018 at 3:13 PM Skip Cave  wrote:

a=:1234567890101020405060708090x


a=2^~a^1r2

1

a=2^~%:a

1

a-:2^~a^1r2

1

a-:2^~%:a

1


NB. All looking good. However:


x:2^~a^1r2

1234567890101024064259751936

a

1234567890101020405060708090


NB. Clearly not equal.


x:2^~%:a

1234567890101020490846961664

a

1234567890101020405060708090


NB. Also clearly not equal, and different from the first one!


What's going on!


Skip
--
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


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

Re: [Jprogramming] Finding integers:

2018-06-12 Thread Don Kelly
If the original list is floating point as indicated- then intolerant 
comparison may not be possible.   If there are true integers (e.g 2 vs 
2.0.) does the square/square root operation differentiate in a 
mixed floating point and integer vector?. I note that Skip's 'a' vector 
is a vector of integers so it appears that the return result is only the 
squares that are integer-not the integers in the original vector 'a=.1+i.20


fi 1+i.20

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

If the values of the tolerantly integer items are needed then modify fi 
given by Henry


f=: (=<.) #]
f 1.0 2.4 3.0 _1.0 3.0010001 _3.1

1 3 _1

f 1.0 2.4 3.0 _1.0 3.01 _3.1

1 3 _1 3


On 2018-06-12 1:42 PM, Henry Rich wrote:

fi =: (= <.)

Consider whether you want intolerant comparison.

Henry Rich

On 6/12/2018 4:40 PM, Skip Cave wrote:

I want to find the integers in a vector of floating point numbers, by
generating a boolean marking vector indicating the locations of the
integers in the floating-point vector:

Generate a vector of integers & store in a, and generate a second 
vector of

floating and integer numbers by taking the square root of a:

b =. %: a=. 1+i.20


Create an integer-finding/marking verb:


fi =. 3 :'(<.y)=y'


Use 'fi' to find the integers in b:

fi b

1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0


Use the mark vector to find the perfect squares in a, by finding the
integers in b:


a#~ fi b

1 4 9 16

My question is:  What are some tacit ways to implement the fi verb?

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



---
This email has been checked for viruses by AVG.
http://www.avg.com

--
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] belated Re: How accurate is (o.) for arguments close to 0 or 1?

2018-03-18 Thread Don Kelly
I finally got down to analyzing this  rather than making guesses. I find 
that the problem involves 2 dimensional geometry where the only thing 
that changes when looking at the center of the "ruler" vs the end of the 
ruler is the horizontal distance to the ruler. No spherical trig and use 
of similar triangles. The results are the same but the capability of J 
to efficently manipulate complex numbers (and I have a lot of experience 
with these) leads to the following


In this dh, dv are the horizontal and vertical distance to the horizon 
with respect to the observer.


cdtr=:1p1%180

Re=:6.378e6

alpha=: 30 NB. half of angle subtended by ruler

findel =: dyad define NB. angles in radians

'dh dv'=.+. (%:y*y+2*Re)r. a=._2 o. Re%Re+y

del=: (-a)+_3 o. dv%dh*2 o. x

)

] del10=: 30r180p1 findel 10

0.000273945 (radians)

del10%cdtr

0.0156959 (degrees) -same as what you got

] del400k=: 30r180p1 findel 4e5

0.0483724

del400k%cdtr

2.77154 (same as your value)

]del400k90 =:45r180p1 findel 4e5

0.125281

del400k90 %cdtr

7.17807 (again agreed)

You got it right first- I just used a different approach in part

Don

On 2018-02-27 1:04 PM, J. Patrick Harrington wrote: Someone once told me 
that the only phrase an academic needs in any language is "Well, it's 
not that simple ..." If the height of the observer is 0, then the 
horizon is the plane through the observer perpendicular to the zenith 
direction - it's a great circle and there is no curvature. But if you're 
above the surface, the horizon is at the distance d where your 
line-of-sight is tangent to the earth's surface. The distance to the 
horizon is then d=sqrt[2Rh+h^2], from the Pythagorean triangle d^2 + R^2 
= (R+h)^2 where R=Earth's radius. In J NB. The angle from the zenith to 
the horizon will exceed NB. 90 degrees by an amount depending upon the 
height h NB. of the observer above the ocean surface. This excess NB. is 
called the "dip" of the horizon. (This formula NB. neglects atmospheric 
refraction which isn't justified!) NB. Usage: hdip h --> angle to 
horizon in excess of 90 deg hdip=: monad define R_E=. 6378e3 NB. Earth's 
equatorial radius in meters h=. y    NB. height of observer in 
meters d=: %: (2*R_E*h)+ h*h  NB. distance to horizon NB. dip=: asin d% 
R_E+ h dip=: atan d%R_E dip%cdtr ) cdtr=: 1p1%180   NB. convert degrees 
to radians E.g., If you're 10m above the surface     hdip 10 0.10146 and 
   d 11294.3 So the horizon is 11.3 km away and appears 0.1 degree 
below the horizontal plane." At this point, we must do some spherical 
trig. (I've taught observational astronomy, so it's no problem for me 
Imagine you are at the center of the celestial sphere. Your 
staright-edge will project on to the sphere as a *great circle*. But 
your horizon is *not* a great circle, it is a "small circle" cut into 
the celestial sphere by a plane that does not pass through the center 
(you). (A small circle is like a circle of constant latitude on the 
globe away from the equator.) So if your straight-edge touches the 
horizon at two points, it will pull away from the horizon it the middle. 
(Just like your plane doesn't fly along a line of constant latitude when 
it takes a great circle route from NY to Spain.) I've tried to impliment 
the spherical trig here (I'm sure it's worked out carefully somewhere.) 
NB. arc of horizon = the angular extent of the straight-edge NB. Usage: 
(arc of horizon) curve (dip of horizon) ===> Z NB. Z = angle of horizon 
above straight edge at its midpoint NB. all angles in degrees curve=: 
dyad define alpha=: cdtr*x a=: 0.5p1 - cdtr*y s=: acos (*: cos a)+ (*: 
sin a)*cos alpha chs=: cos -:s c=: acos (cos a)%chs del=: a - c del%cdtr 
) So for a straight-edge the subtends 60 degrees of the horizon and an 
observer 10 meters above the sea, we find    60 curve (hdip 10) 
0.0156959 The horizon is ~0.016 degree above the mid-point of the ruler, 
about a minute of arc. For the space station at h= 400 km, we get    60 
curve (hdip 400e3) 2.77154 an easily noticed ~3 degrees. Or with a wider 
ruler, spanning 90 deg    90 curve (hdip 400e3) 7.17807 I think this 
makes sense, but I offer no guarantees. Patrick


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

Re: [Jprogramming] How accurate is (o.) for arguments close to 0 or 1?

2018-03-01 Thread Don Kelly
If the answer to the Haddon question is yes or no. it comes down to need 
for a much smaller world or a bigger ruler than one can carry, to get a 
yes. As a crude ballpark  approximation with a 10m high eyeball and a 60 
degree angle at  an 11km distance (Harrington)and ignoring all the real 
factors involved. the difference in height between between the edge and 
center is less than 10m. extrapolating back to the 30cm ruler subtending 
60 degrees, scale this down by 0.3%11000 gives a  maximum height at the 
ruler of 0.3mm.  Less is expected-pretty hard to tell. Now if the "hero" 
with eagle eyes can hold a 1m ruler 87cm from his eyeball and perfectly 
horizontal in cold clear weather-maybe- Now, with a person standing on 
the shore by the sea- divide by 5. These are ball park estimates. The 
problem with going with extended precision is that some operations may 
automatically float results and the accuracy of the parameters given as 
well as the factors ignored do cause problems.  The funny result you got 
with different precisions  originally was that you were looking at the 
length of the ruler related to the diameter of the earth rather than the 
length of the diameter of the horizontal slice.


Don


On 2018-02-28 5:42 AM, Ian Clark wrote:

Well, there's certainly a fund of ideas here!

But I must distinguish them for priority reasons as follows:

(a) validating an approximate treatment to estimate an upper bound for the
size of the Mark Haddon effect (if I may call it that),
(b) the correct use of spherical trigonometry for a precise treatment
involving height of the observer above the ground
(c) curvature of a light ray due to atmospheric diffraction,
(d) issues surrounding the use of J to work with very small angles.

To which I forbore to add: relativistic effects due to a flat earth
constituting a supermassive gravitational lens (because I felt it would
unduly clutter the discussion).

All of these aspects interest me, and I'd love to discuss them at greater
depth, since history and philosophy of science is a fad of mine. But I
chose to put my question to the J-programming forum specifically to get my
head around (d), which is the only J-programming topic. I'm assembling a
collection of case-studies using TABULA, and observational geometry looms
large – and triangles with the radius of the earth along one side
frequently crop up.

With the resulting very small angles, 'float' precision won't do. I want to
explore the scope for extended precision, which means collecting techniques
for doing geometry and trigonometry which don't contingently revert to
'float' partway through. Thank you for your ideas on this topic, which has
likely given me enough to go on.

On Wed, Feb 28, 2018 at 1:33 PM, Ian Clark <earthspo...@gmail.com> wrote:


@Don – I'm not sure about this. If the straight-edge is replaced by a
horizontal hoop equidistant from the eye at all points, then I agree with
you.
But suppose an infinitely long straight-edge: there is no longer symmetry
in all directions. As you look out towards its extremities wouldn't you see
the sphere of the earth progressively dropping away from beneath it? Yes,
the increased distance will shrink the perceived drop-away, but the sphere
drops away faster.
The argument is more convincing if you don't line up the ends with the
horizon, as my original diagram requires, but make the middle of the
lower-edge tangential to the horizon. Then the looked-for "arch" is below
the straight-edge, not rising above it.
The shortness of a 30 cm steel ruler can be overcome by moving the eye
ever closer. Yes I agree the drop-away is minute in practice (the thickness
of a strand of DNA), which is what I wanted to demonstrate. But I find it
hard to accept that it is mathematically zero.

On Wed, Feb 28, 2018 at 4:16 AM, Don Kelly <d...@shaw.ca> wrote:


If the observer is standing at some point on the surface of the earth.and
is facing in a given direction with the straight edge. you are looking  as
you describe. If facing another direction, you are , by symmetry, looking
at the same curvature and the same distance to the horizon. You are looking
at a great circle in any direction. Replace the straight edge by a barrel
band of some radius -with you at the center- whichever way you look there
is symmetry which reflects the statements "if the height...  radius" In
theory the distance from the eye to the end of a straight ruler is
different from that to the center of the ruler-but does this give a
measurable effect?   Not with a 30 cm ruler 2 m above the  surface of the
earth. Certainly the horizon is a small circle but looking out in any
direction from a given point close to the surface of the earth is looking
along a line tangent to a great circle. I'm not sure that there is a need
to deal with  spherical trig because of the symmetry.  However, my last use
of spherical trig was about 1952 so i am rusty (and not standing at the
center o

Re: [Jprogramming] How accurate is (o.) for arguments close to 0 or 1?

2018-03-01 Thread Don Kelly
Ah, yes, but this is a perfect world with a constant radius (not too 
large ) and , presumably, no atmosphere. Fiction can ignore little 
details but it does lead into some interesting calculations and errors 
(I made a big one with respect to the distance from the eye to different 
parts of an ideal straight ruler. I apologize to all for my mind fart- 
whch is always realized a few seconds after hitting send)


don.




On 2018-02-27 10:55 PM, bill lam wrote:

there is diffraction when light travels inside atmosphere.

On Feb 28, 2018 12:16 PM, "Don Kelly" <d...@shaw.ca> wrote:


If the observer is standing at some point on the surface of the earth.and
is facing in a given direction with the straight edge. you are looking  as
you describe. If facing another direction, you are , by symmetry, looking
at the same curvature and the same distance to the horizon. You are looking
at a great circle in any direction. Replace the straight edge by a barrel
band of some radius -with you at the center- whichever way you look there
is symmetry which reflects the statements "if the height...  radius" In
theory the distance from the eye to the end of a straight ruler is
different from that to the center of the ruler-but does this give a
measurable effect?   Not with a 30 cm ruler 2 m above the  surface of the
earth. Certainly the horizon is a small circle but looking out in any
direction from a given point close to the surface of the earth is looking
along a line tangent to a great circle. I'm not sure that there is a need
to deal with  spherical trig because of the symmetry.  However, my last use
of spherical trig was about 1952 so i am rusty (and not standing at the
center of the celestial sphere or even the earthly sphere).

Don


On 2018-02-27 1:04 PM, J. Patrick Harrington wrote:


Someone once told me that the only phrase an academic needs in any
language is "Well, it's not that simple ..."

If the height of the observer is 0, then the horizon is the plane through
the observer perpendicular to the zenith direction - it's a great circle
and there is no curvature. But if you're above the surface, the horizon
is at the distance d where your line-of-sight is tangent to the earth's
surface. The distance to the horizon is then d=sqrt[2Rh+h^2], from the
Pythagorean triangle d^2 + R^2 = (R+h)^2 where R=Earth's radius. In J

NB. The angle from the zenith to the horizon will exceed
NB. 90 degrees by an amount depending upon the height h
NB. of the observer above the ocean surface. This excess
NB. is called the "dip" of the horizon. (This formula
NB. neglects atmospheric refraction which isn't justified!)
NB. Usage: hdip h --> angle to horizon in excess of 90 deg
hdip=: monad define
R_E=. 6378e3 NB. Earth's equatorial radius in meters
h=. yNB. height of observer in meters
d=: %: (2*R_E*h)+ h*h  NB. distance to horizon
NB. dip=: asin d% R_E+ h
dip=: atan d%R_E
dip%cdtr
)
cdtr=: 1p1%180   NB. convert degrees to radians

E.g., If you're 10m above the surface
 hdip 10
0.10146
and
d
11294.3
So the horizon is 11.3 km away and appears 0.1 degree below the
horizontal plane." At this point, we must do some spherical trig. (I've
taught observational astronomy, so it's no problem for me :-) Imagine
you are at the center of the celestial sphere. Your staright-edge will
project on to the sphere as a *great circle*. But your horizon is *not*
a great circle, it is a "small circle" cut into the celestial sphere by
a plane that does not pass through the center (you). (A small circle is
like a circle of constant latitude on the globe away from the equator.)
So if your straight-edge touches the horizon at two points, it will pull
away from the horizon it the middle. (Just like your plane doesn't fly
along a line of constant latitude when it takes a great circle route from
NY to Spain.) I've tried to impliment the spherical trig here (I'm sure
it's worked out carefully somewhere.)

NB. arc of horizon = the angular extent of the straight-edge
NB. Usage: (arc of horizon) curve (dip of horizon) ===> Z
NB. Z = angle of horizon above straight edge at its midpoint
NB. all angles in degrees
curve=: dyad define
alpha=: cdtr*x
a=: 0.5p1 - cdtr*y
s=: acos (*: cos a)+ (*: sin a)*cos alpha
chs=: cos -:s
c=: acos (cos a)%chs
del=: a - c
del%cdtr
)

So for a straight-edge the subtends 60 degrees of the horizon and an
observer 10 meters above the sea, we find

60 curve (hdip 10)
0.0156959

The horizon is ~0.016 degree above the mid-point of the ruler,
about a minute of arc.

For the space station at h= 400 km, we get
60 curve (hdip 400e3)
2.77154

an easily noticed ~3 degrees. Or with a wider ruler, spanning 90 deg
90 curve (hdip 400e3)
7.17807

I think this makes sense, but I offer no guarantees.
Patrick

On Tue, 27 Feb 2018, Don Kelly wrote:


I agree with the series approach but the final result depends on
division which has limited accuracy. I would suggest us

Re: [Jprogramming] How accurate is (o.) for arguments close to 0 or 1?

2018-02-28 Thread Don Kelly

*I think that I flushed my brains down the toilet when I wrote this *

_"__In theory the distance from the eye to the end of a straight ruler 
is different from that to the center of the ruler-but does this give a 
measurable effect? __" _

---
*In fact it is very important- but the length of the "straight" ruler is 
not of importance- the angle it subtends and the distance to the horizon 
viewed at the ends of *the ruler. If this is about 11km and the angle is 
60 degrees- then one is looking at a slice of of a "near" circle of 
diameter 11km rather than at a 30cm ruler. The numbers are nicer and 
once the height of the slice is found -it can be scaled back to the 
height "seen" at the ruler. Patrick has it right. Yes the observed 
height at the ruler will be small -haven't worked it out.
Don   



On 2018-02-28 5:33 AM, Ian Clark wrote:

@Don – I'm not sure about this. If the straight-edge is replaced by a
horizontal hoop equidistant from the eye at all points, then I agree with
you.
But suppose an infinitely long straight-edge: there is no longer symmetry
in all directions. As you look out towards its extremities wouldn't you see
the sphere of the earth progressively dropping away from beneath it? Yes,
the increased distance will shrink the perceived drop-away, but the sphere
drops away faster.
The argument is more convincing if you don't line up the ends with the
horizon, as my original diagram requires, but make the middle of the
lower-edge tangential to the horizon. Then the looked-for "arch" is below
the straight-edge, not rising above it.
The shortness of a 30 cm steel ruler can be overcome by moving the eye ever
closer. Yes I agree the drop-away is minute in practice (the thickness of a
strand of DNA), which is what I wanted to demonstrate. But I find it hard
to accept that it is mathematically zero.

On Wed, Feb 28, 2018 at 4:16 AM, Don Kelly <d...@shaw.ca> wrote:


If the observer is standing at some point on the surface of the earth.and
is facing in a given direction with the straight edge. you are looking  as
you describe. If facing another direction, you are , by symmetry, looking
at the same curvature and the same distance to the horizon. You are looking
at a great circle in any direction. Replace the straight edge by a barrel
band of some radius -with you at the center- whichever way you look there
is symmetry which reflects the statements "if the height...  radius" In
theory the distance from the eye to the end of a straight ruler is
different from that to the center of the ruler-but does this give a
measurable effect?   Not with a 30 cm ruler 2 m above the  surface of the
earth. Certainly the horizon is a small circle but looking out in any
direction from a given point close to the surface of the earth is looking
along a line tangent to a great circle. I'm not sure that there is a need
to deal with  spherical trig because of the symmetry.  However, my last use
of spherical trig was about 1952 so i am rusty (and not standing at the
center of the celestial sphere or even the earthly sphere).

Don



On 2018-02-27 1:04 PM, J. Patrick Harrington wrote:


Someone once told me that the only phrase an academic needs in any
language is "Well, it's not that simple ..."

If the height of the observer is 0, then the horizon is the plane through
the observer perpendicular to the zenith direction - it's a great circle
and there is no curvature. But if you're above the surface, the horizon
is at the distance d where your line-of-sight is tangent to the earth's
surface. The distance to the horizon is then d=sqrt[2Rh+h^2], from the
Pythagorean triangle d^2 + R^2 = (R+h)^2 where R=Earth's radius. In J

NB. The angle from the zenith to the horizon will exceed
NB. 90 degrees by an amount depending upon the height h
NB. of the observer above the ocean surface. This excess
NB. is called the "dip" of the horizon. (This formula
NB. neglects atmospheric refraction which isn't justified!)
NB. Usage: hdip h --> angle to horizon in excess of 90 deg
hdip=: monad define
R_E=. 6378e3 NB. Earth's equatorial radius in meters
h=. yNB. height of observer in meters
d=: %: (2*R_E*h)+ h*h  NB. distance to horizon
NB. dip=: asin d% R_E+ h
dip=: atan d%R_E
dip%cdtr
)
cdtr=: 1p1%180   NB. convert degrees to radians

E.g., If you're 10m above the surface
 hdip 10
0.10146
and
d
11294.3
So the horizon is 11.3 km away and appears 0.1 degree below the
horizontal plane." At this point, we must do some spherical trig. (I've
taught observational astronomy, so it's no problem for me :-) Imagine
you are at the center of the celestial sphere. Your staright-edge will
project on to the sphere as a *great circle*. But your horizon is *not*
a great circle, it is a "small circle" cut into the celestial sphere by
a plane that does not pass through the center (you). (A small circle is
like a circle of co

Re: [Jprogramming] How accurate is (o.) for arguments close to 0 or 1?

2018-02-27 Thread Don Kelly
If the observer is standing at some point on the surface of the 
earth.and is facing in a given direction with the straight edge. you are 
looking  as you describe. If facing another direction, you are , by 
symmetry, looking at the same curvature and the same distance to the 
horizon. You are looking at a great circle in any direction. Replace the 
straight edge by a barrel band of some radius -with you at the center- 
whichever way you look there is symmetry which reflects the statements 
"if the height...  radius" In theory the distance from the eye to the 
end of a straight ruler is different from that to the center of the 
ruler-but does this give a measurable effect?   Not with a 30 cm ruler 2 
m above the  surface of the earth. Certainly the horizon is a small 
circle but looking out in any direction from a given point close to the 
surface of the earth is looking along a line tangent to a great circle. 
I'm not sure that there is a need to deal with  spherical trig because 
of the symmetry.  However, my last use of spherical trig was about 1952 
so i am rusty (and not standing at the center of the celestial sphere or 
even the earthly sphere).


Don


On 2018-02-27 1:04 PM, J. Patrick Harrington wrote:
Someone once told me that the only phrase an academic needs in any 
language is "Well, it's not that simple ..."


If the height of the observer is 0, then the horizon is the plane 
through the observer perpendicular to the zenith direction - it's a 
great circle

and there is no curvature. But if you're above the surface, the horizon
is at the distance d where your line-of-sight is tangent to the earth's
surface. The distance to the horizon is then d=sqrt[2Rh+h^2], from the
Pythagorean triangle d^2 + R^2 = (R+h)^2 where R=Earth's radius. In J

NB. The angle from the zenith to the horizon will exceed
NB. 90 degrees by an amount depending upon the height h
NB. of the observer above the ocean surface. This excess
NB. is called the "dip" of the horizon. (This formula
NB. neglects atmospheric refraction which isn't justified!)
NB. Usage: hdip h --> angle to horizon in excess of 90 deg
hdip=: monad define
R_E=. 6378e3 NB. Earth's equatorial radius in meters
h=. y    NB. height of observer in meters
d=: %: (2*R_E*h)+ h*h  NB. distance to horizon
NB. dip=: asin d% R_E+ h
dip=: atan d%R_E
dip%cdtr
)
cdtr=: 1p1%180   NB. convert degrees to radians

E.g., If you're 10m above the surface
    hdip 10
0.10146
and
   d
11294.3
So the horizon is 11.3 km away and appears 0.1 degree below the 
horizontal plane." At this point, we must do some spherical trig. 
(I've taught observational astronomy, so it's no problem for me :-) 
Imagine

you are at the center of the celestial sphere. Your staright-edge will
project on to the sphere as a *great circle*. But your horizon is *not*
a great circle, it is a "small circle" cut into the celestial sphere by
a plane that does not pass through the center (you). (A small circle is
like a circle of constant latitude on the globe away from the equator.)
So if your straight-edge touches the horizon at two points, it will pull
away from the horizon it the middle. (Just like your plane doesn't fly
along a line of constant latitude when it takes a great circle route from
NY to Spain.) I've tried to impliment the spherical trig here (I'm sure
it's worked out carefully somewhere.)

NB. arc of horizon = the angular extent of the straight-edge
NB. Usage: (arc of horizon) curve (dip of horizon) ===> Z
NB. Z = angle of horizon above straight edge at its midpoint
NB. all angles in degrees
curve=: dyad define
alpha=: cdtr*x
a=: 0.5p1 - cdtr*y
s=: acos (*: cos a)+ (*: sin a)*cos alpha
chs=: cos -:s
c=: acos (cos a)%chs
del=: a - c
del%cdtr
)

So for a straight-edge the subtends 60 degrees of the horizon and an
observer 10 meters above the sea, we find

   60 curve (hdip 10)
0.0156959

The horizon is ~0.016 degree above the mid-point of the ruler,
about a minute of arc.

For the space station at h= 400 km, we get
   60 curve (hdip 400e3)
2.77154

an easily noticed ~3 degrees. Or with a wider ruler, spanning 90 deg
   90 curve (hdip 400e3)
7.17807

I think this makes sense, but I offer no guarantees.
Patrick

On Tue, 27 Feb 2018, Don Kelly wrote:
I agree with the series approach but the final result depends on 
division which has limited accuracy. I would suggest using the 
following which uses 100*L%R as a rational fraction


(10^_2)*(1r2)* 175r637816300

1.37187e_9


However, the solution is wrong in any case. It is the result of using 
a circle and a line parallel to the tangent line at any point. In 
other words, looking at the earth from a great distance.


The right answer (for a perfect sphere) is 0 as the curvature of the 
earth is the same in every direction from the observer. There is no 
"arch"   It seems that the old Greeks had it right- as ships went off 
into the distance, they didn't just shrink and remain whole 

Re: [Jprogramming] How accurate is (o.) for arguments close to 0 or 1?

2018-02-27 Thread Don Kelly
I agree with the series approach but the final result depends on 
division which has limited accuracy. I would suggest using the following 
which uses 100*L%R as a rational fraction


(10^_2)*(1r2)* 175r637816300

1.37187e_9


However, the solution is wrong in any case. It is the result of using a 
circle and a line parallel to the tangent line at any point. In other 
words, looking at the earth from a great distance.


The right answer (for a perfect sphere) is 0 as the curvature of the 
earth is the same in every direction from the observer.  There is no 
"arch"   It seems that the old Greeks had it right- as ships went off 
into the distance, they didn't just shrink and remain whole but would 
also disappear gradually from the  bottom up. What Patrick Harrington 
said is at the core of what is actually observed.



Don Kelly


On 2018-02-26 10:10 PM, J. Patrick Harrington wrote:

The way to avoid loss of accuracy is to expand in a binomial series:
 D = R - √(R²-L²) = R[ 1 - (1 - (L/R)^2)^(1/2)]
   = R[ 1 - (1 -(1/2)(L/R)^2 + ...)] = (1/2) L*L/R
and thus
 ]D=. -:L*L%R
 1.76384e_9

On Tue, 27 Feb 2018, Ian Clark wrote:
In "The Curious Incident of the Dog in the Night-Time", Mark Haddon 
has his
young autistic hero verify that the earth is not flat by holding up a 
steel

straight-edge to the horizon.

In the course of private research into public gullibility, I tried to
replicate Haddon's thought-experiment – and failed! Try as I might, I 
could
not see the slightest discrepancy between the horizon and my 
straight-edge.


I strongly suspect that Haddon hasn't performed the experiment 
himself, but

simply written down what he thought one "ought" to see.

So what am I to conclude?
(a) The earth is flat.
(b) The curvature is too small to be seen this way.
(c) Don't believe everything you read in novels.

Let's go with (b), and try to calculate the height D of the "arch" of 
the

horizon over the ruler's edge, and show it's too small to observe by the
naked eye.

There's a diagram at:

https://whitbywriters.wordpress.com/2018/02/26/the-curious-incident-of-the-dead-flat-horizon 


where I discuss the matter for non-mathematical readers. There I baldly
state that D is given by the formula:

  D = R * (1 – cos arcsin L/R)

where L is the half-length of the straight-edge and R the radius of the
earth.

Have I got it right?

I calculated D = 1.4 nm, but omit to say how. (I used J of course).

  R=: 6378163  NB. equatorial radius of earth (m)
  L=: 0.15 NB. half-length of metal ruler (m)
  cos=: 2
  arcsin=: _1
  smoutput D=: R * (1 - cos arcsin L%R)
1.41624e_9

Now 1.41624e_9 m is roughly 1.4 nm, less than the width of a DNA 
molecule.


But I suspect that my estimate of D is unreliable. Moreover it could 
be out
by several orders of magnitude. Why? Because I'm calculating the 
arcsin of
a very small number, and then calculating the cosine of the resulting 
very

small angle, which may be pushing (o.) beyond its limits.

Now I could use Pythagoras instead of trigonometry:

  D = R - √(R²-L²)

which avoids using (o.) and may perform the entire calculation in 
extended
precision without conversion to (float). I'll also work in nanometres 
(nm),

not metres (m):

  R=: 63781630x   NB. (nm)
  L=: 15000x  NB. (nm)
  smoutput D=: R - %:(R*R)-(L*L)
2

I thought I was getting 6-figure accuracy, so this result worries me.
2 nm differs significantly from the result of the trig formula: 1.4 nm.

Now (R*R)-(L*L) is extended precision, but (%:) is returning (float) not
(extended). Is it also corrupting the result? Is "2" just an artefact of
its algorithm?

So let's work in picometres, to see if the "2" holds up under greater
precision:

  R=: 6378163x
  L=: 1500x
  smoutput D=: R - %:(R*R)-(L*L)
2048

It does. This is encouraging. But (%:) still returns (float).

Let's try different ways of calculating the square root of an extended
precision result:

  sq=: ^&2
  sqr=: %:
  smoutput D=: R - sqr (sq R)-(sq L)
2048
  sqr=: ^&0.5
  smoutput D=: R - sqr (sq R)-(sq L)
2048
  sqr=: ^&1r2
  smoutput D=: R - sqr (sq R)-(sq L)
3072
…which is even more worrying!

So which is the most dependable approximation to D?
 3 nm
 2 nm
 1.4 nm
 none of the above?

Is it robust enough to warrant my original deduction?

Have I made a logical error somewhere?
--
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] Let's discuss: .Net interface to J

2018-02-20 Thread Don Kelly
I apologize for one of the test messages which  was sent because I had 
seen no activity on this forum for at least 10 to 15 days and wanted to  
check to see if I was, for some reason, not getting messages and would 
have to try and fix a problem. test message received -OK.


Don Kelly


On 2018-02-17 6:30 AM, chris burke wrote:

Test messages probably should have gone to the chat forum?

Yes. The same mailman engine is used for all the forums, so any forum could
be used for test messages.

We also run a test forum for debugging the very occasional problem when a
member's messages are not being posted. It has been some time since the
forums were so quiet, so I used the test forum to make sure everything is
still working.


On Sat, Feb 17, 2018 at 6:15 AM, Raul Miller <rauldmil...@gmail.com> wrote:


Test messages probably should have gone to the chat forum?

Not sure about this .Net thing (general forum or programming forum),
but it should be possible to build a .Net application in visual studio
which uses the j dll for computation. I know I did something similar
with an earlier version of .Net and an earlier version of j at a
previous job.

I hope this helps,

--
Raul


On Sat, Feb 17, 2018 at 8:46 AM, Randy MacDonald <array...@rogers.com>
wrote:

(two Test: messages in a row is two too many...)

What moves have been made to have an .Net interface for J?  Does it being
open source preclude that?

--

== "Greenlight your own desires and get on with it." -- Scott "The

Nametag

Guy" Ginsburg
Randy A MacDonald| The problem with APL is
Natural Born APL'er  | it is still ahead of its time.
Personal Web Server <http://mormac39.no-ip.biz/?ref=sig.160310%20>
| -- Morten Kromberg
==

--
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


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

[Jprogramming] test- don't bother

2018-02-09 Thread Don Kelly

test

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

Re: [Jprogramming] Strange behavior of 0x1

2017-12-17 Thread Don Kelly

The error doesn't appear in J806 Windows 10/64 bit /amd a10-7800

Don


On 2017-12-16 7:49 PM, bill lam wrote:

On j android, it looks like that
0xn is evaluated as nxn
0x1
2.71828
1x1
2.71828
0x2
14.7781
2x2
14.7781
0x3
60.2566
3x3
60.2566

On Dec 17, 2017 12:33 AM, "Henry Rich"  wrote:


When I try it (on a couple of different J versions) I get
0x1
0
0x0
0
etc.

If your error persists please run
9!:14''

to indicate what version you are running, and report the error again.

Welcome to J!

Henry Rich

On 12/16/2017 6:19 AM, roua...@gmail.com wrote:


Hi.

Could someone please shed some light on the following behavior:

 1p1
3.14159
 0p1
0
 0p0
0
 1x1
2.71828
 0x1
2.71828
 0x0
0

I don't understand why 0x1 isn't the same as 0 * ^1 even though
other constants seem to obey this form. I haven't found any
explanation in
http://www.jsoftware.com/docs/help806/dictionary/dcons.htm .



I am new to J and am yet to write a useful script in it, but
I've already been greatly impressed by how consistent the
language felt in most cases. For example, just the other day
I wrote a monadic verb which took $n$ as an argument and
returned $\sum_k {n \choose 3k}$. The verb was the following:

  a =: [:+/(3*i.)!]

But if you try to pass it not a single $n$ but a list, the
verb doesn't work. Which is a shame because the intended use
was to examine the series. And so I started searching for
something akin to Haskell's `map`. After half an hour of
sifting through J tutorials that expressed delight in the
fact that J lifts operations to arrays of arbitrary ranks
by default and therefore doesn't need `map`, I've finally
found what I was looking for, namely `a "0 i.50`, the rank
operator, and it turned out that `map` isn't magic after
all and is just a single case of a more general operation.
I hadn't seen the rank operator in any language before and
was thrilled to feel the potential that this operator holds.

So the language is great, and it seems that common use cases
are handled by elegant general solutions, that is, the
language is designed to be mostly free from corner cases.

That's why the unintuitive handling of 0x1 seems to me
especially weird. I could ignore it if Python did it, if
C++ did it, but J simply doesn't look like a language that
intoduces inconsistencies for no reason. So it is highly
probable that it's me who doesn't understand higher purpose
of the construct. And so I came here hoping that someone
explains it to me. The J community has a reputation of
being tolerant to uninsightful questions of beginners.



Sorry if my English has some mistakes or is in the wrong
tone. The reason isn't negligence, it's just that English
isn't my native language.

Regards,
Dmitry Khalansky.
--
For information about J forums see http://www.jsoftware.com/forums.htm



---
This email has been checked for viruses by AVG.
http://www.avg.com

--
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] SVMs in J

2017-12-05 Thread Don Kelly
A quadratic equation solver is, in J, simply using*p. c a b*  to find 
the roots of a single quadratic equation ax^2+bx+c=0 . This and most of 
the Wiki solvers deal with this form for which there is a 
straightforward solution(even by hand). IF and ONLY IF a, b, and c are 
constant. I suspect that this is not what Scott wanted.
For cases involving multiple quadratic functions of multiple variables, 
the Newton-Raphson method   can be extended using the Jacobean matrix. 
This is done in power system "power flow" solutions where, often, 
hundreds of non-linear simultaneous and complex equations are involved 
and need to be solved quickly. Your reference does note the N-R method.


What you have suggested may well be much more useful to Scott.

Don Kelly


On 2017-12-05 4:36 PM, Scott Locklin wrote:

On Dec 04, 2017; 7:37pm Devon McCormick wrote:


I searched the J wiki for "quadratic" and found a mention from a 2005
NYCJUG meeting where we were lamenting that other environments simply
have
quadratic solvers available but J does not.  Looking into it more, I was
unsure "quadratic" means in "quadratic solver"; from "Numerical
Recipes", I
gather that it may refer to quadratic convergence.  On further
reflection,
I'm not exactly sure what this means either but suspect it means
something
like O(sqrt(n)) solution time but am not sure.  I'm also unclear if this
non-linear solver in J - http://code.jsoftware.com/wiki/Scripts/nlls - is
an example of a quadratic solver (with this follow-up page I put
together -
http://code.jsoftware.com/wiki/NYCJUG/2010-11-09/Levenberg-MarquardtAlgorithm
).
Perhaps someone more acquainted with this domain can shed some light.
My ultimate goal for these sort of tools is to do something with the
million or so photos I have but I'm seeing from what I've learned so far
that the real work is in feature-extraction, so that at least is
something
where I can use J to good effect.


Image processing is one of the reasons people have moved to GPUs; it's
pretty heavy duty stuff for regular processors. Particularly on full
sized photographic quality images. "Do something with photos" is also a
REALLY open ended statement. What do you want to do? Identify faces in
the images? Identify similar shapes in an image database? SVM isn't very
good at any of these things, though it's OK at small stuff like MNIST
(classifying tiny cropped images of handwritten number digits).

Identifying something is a face: use Viola-Jones (adaboost on Haar
wavelet summaries).
https://en.wikipedia.org/wiki/Viola%E2%80%93Jones_object_detection_framework

Identifying a specific face in a bag of faces; after you've identified
the faces in your images, Eigenfaces is actually pretty easy to code up
in J:
https://en.wikipedia.org/wiki/Eigenface

Identifying similar images... I dunno, maybe locality sensitive hashing.

Feature extraction, maybe SIFT or HOG descriptors (along with Haar
wavelets):
https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients

If you still want to build a native J SVM (which you shouldn't try to
use on large photographic data), the appropriate quadratic programming
is this thing:
https://en.wikipedia.org/wiki/Quadratic_programming

Most ML (and optimization such as QP) algorithms are fiddley and hard
enough to code up, people almost always use libraries. I mean, people
still use LAPACK which is more or less code from the 60s! Pretty sure
the quadprog algo in R is of similarly ancient vintage.

flann is a good example of this: there are basically three useful open
source general purpose KD-tree-like data structures available to the
general public for doing low dimensional KNN kinds of things. It was a
Ph.D. thesis worth of work. It would be brilliant to have one in
native-J, but FFIing out isn't cheating! It's what everyone does!

-SL

--
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] J strengths?

2017-11-28 Thread Don Kelly
While I have done, in the past, with APL*PlUS, (Yes, I am that old) more 
than I have done with J (interest rather than need  is now dominant), I 
find that the potential of J to deal with many things in a compact way 
is superior to that APL and any other languages which I have dealt with 
-from MAD, Fortran, Basic, Pascal and C++ . In J, the problem solution 
is the main objective and the bit twiddling can be left to the idiot 
box, not the programmer. The array orientation eliminates much of the  
need for looping and control structures which, while defined, are often 
unneeded.


An example is  (explicit) scripts to solve electric and magnetic fields 
under power transmission lines. The scripts are compact and take 
advantage of the use of complex numbers for electrical as well as 
positional factors and geometric means -- there is no looping that would 
have to be explicitly  built  as would be the case in most languages.  
Explicit loops have their place and usefulness and  this is recognized 
in J.


The difference between J and most other languages is that J eliminates  
the housekeeping that the idiot box can do -so that the*problem rather 
than the housekeeping is dominant*. It is true that compiled C++ lies 
behind many of the operations - but J is beyond C++ as much as C++ is 
beyond assembly language for programming.


Don Kelly


On 2017-11-28 12:59 PM, Andrew Dabrowski wrote:
As much as I've complained about J in these forums I've been having a 
good time translating some simple code into J.  Someone gave me wise 
advice, to stick with explicit definitions until I know the language 
well, which advice I have cordially ignored because I'm having too 
much fun playing code golf with tacit tangles.


I was fascinated by J because it seemed to try to build on aspects of 
the human linguistic system.  Natural language unfolds in one 
dimension, time, so everything relevant to understanding a particular 
word in a sentence either came before it or is yet to come.  J seemed 
to emulate this by having verbs which relate directly only to objects 
on the immediate left and immediate right.  Moreover J seemed to be 
following a linguistic paradigm in have nouns which are inert, verbs 
that act on nouns, and adverbs which modify objects.  This seemed like 
a promising way to exploit humans' natural linguistic capabilities.


But maybe that's not way the J community currently sees J.  Do you 
love J most because of (pick only one)


1. the NL inspired syntax;

2. the suite of array utilities;

3. the concision of J code;

4. its being open-source; or

5. _?

I've come to feel that all programming languages are ugly compromises 
that are about equally good/bad at solving practical problems, and the 
"best" language is just the one you know the best.  I used to be 
contemptuous of Perl, but after having learned it well enough for my 
purposes I now kind of enjoy the brain teaser quality of trying to fit 
problems into its procrustean bed (although I still think it's a silly 
language).  I have no doubt that I could live happily with J as my 
primary language, but only after an extended period of being 
handcuffed to it and forced to assimilate its quirks.  I don't know 
that I'll have the patience for that.


Is there any project in the J repos that demonstrates the strength of 
J, as opposed to just showing that it's at least as good as other 
languages?  Any project that would have been significantly harder to 
complete with say Python?  Does J have any killer advantage, even in 
just one aspect of programming?  Or does J just appeal to you the way 
pistachio ice-cream might, it just tickles your palate in a 
no-accounting-for-taste way?  That's how it appeals to me.


I was hoping someone could talk me into studying J seriously, but now 
it looks to me like a language which, with APL, has had enormous 
beneficial influence on many other languages, but which has failed to 
learn in its turn from them.  J seems a tad solipsistic.



--
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] [Jbeta] request a new forum for number representation issue???

2017-10-10 Thread Don Kelly
An example is a script which evaluates and plots electric and magnetic 
fields under and near powerlines as well as some for T-line parameters. 
A load flow program written in APL has been partially moved to J. J 
lends itself to matrix manipulation such as using the Y matrix of a 
system and from that forming the Z-Bus matrix which lends itself to 
fault analysis. These are practical applications. The advantage of J 
lies in the fact that the programming effort can be concentrated on the 
problem rather than the declarations of variable types, etc. and 
experimentation with individual parts of the script is easy to do. There 
are businesses which had in the past used APL  and could do the same with J


Yes the above are mathematical applications but are of concern and are 
not "puzzles"


Don Kelly


On 2017-10-10 5:09 AM, Rob B wrote:

My many trips around the J home website have given me the impression that J is 
very much geared to maths and puzzles.

I would be genuinely interested in reading about real world appllications of J.

Regards, Rob Burns.


On 10 Oct 2017, at 02:43, Don Kelly <d...@shaw.ca> wrote:

The possibility of a forum dealing with the extended variations would be  
useful in that the present forum would then deal with more realistic problems  
rather  than the more esoteric ones. We don't need to slow down operations, 
useful to all, to satisfy the needs of a few.

Any digital expression is limited by machine word limits  and data limits. 
Machine limits exceed data limits in most cases- -useful where multiple 
operations   result in digital fuzz that is insignificant relative to real data 
fuzz.

Don Kelly



On 2017-10-09 12:29 PM, Raul Miller wrote:
I think this proposal would require, at minimum, a rewrite of ve.c

Also, each primitive which takes numeric arguments and/or produces a
numeric result would need a test to make sure it behaved properly for
each different mode of number handling.

Want to take a crack at it?

Thanks,

--
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] [Jbeta] request a new forum for number representation issue???

2017-10-09 Thread Don Kelly
The possibility of a forum dealing with the extended variations would 
be  useful in that the present forum would then deal with more realistic 
problems  rather  than the more esoteric ones. We don't need to slow 
down operations, useful to all, to satisfy the needs of a few.


Any digital expression is limited by machine word limits  and data 
limits. Machine limits exceed data limits in most cases- -useful where 
multiple operations   result in digital fuzz that is insignificant 
relative to real data fuzz.


Don Kelly


On 2017-10-09 12:29 PM, Raul Miller wrote:

I think this proposal would require, at minimum, a rewrite of ve.c

Also, each primitive which takes numeric arguments and/or produces a
numeric result would need a test to make sure it behaved properly for
each different mode of number handling.

Want to take a crack at it?

Thanks,



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

Re: [Jprogramming] Sequence generation

2017-09-29 Thread Don Kelly
So it is a game- fair enough- it shows that in J there are more ways 
than one to skin a cat. BUT does it really bring out the reason for a 
language like J or APL? Does it bring out the power of J to make so many 
things simpler and more elegant for the user? You have used APL and so 
have I -and the benefit has been the ability to express a solution to a 
problem-in APL it has bee explicit but in J there is a choice and ,for 
some things, explicit is clearer and more understandable -where for 
other things tacit J  has advantages. I have an explicit script for 
finding electric or magnetic fields in the region of a powerline. This 
can involve some internal calls on a tacit operation. The balance is 
dependent on the problem  and the preferences of the user.


Don


On 2017-09-28 4:41 PM, Erling Hellenäs wrote:
It's not better. Skip asked for a recursive version too so  we gave 
him one. Very complicated way to write a simple thing. Lol. /Erling


On 2017-09-29 01:24, Don Kelly wrote:

why is this better than the easy to read version that Roger Hui sent?

quote:

   +/\4+i.10
4 9 15 22 30 39 49 60 72 85

unquote: This is also the way APL does it Sure it is fun to try 
different ways such as below, just as it is fun to make a 1 liner to 
generate a series for sin x. It is also nice to come back to a piece 
of code written a year earlier and be able to recognize quickly what 
it did. In the end- the simpler expression uses the power of J to do 
it more neatly and faster Don Kelly


On 2017-09-28 1:02 PM, Xiao-Yong Jin wrote:


On Sep 28, 2017, at 2:45 PM, Erling Hellenäs 
<erl...@erlinghellenas.se> wrote:


    4 [`(] (] , [ + [: {: ]) [ $: [: <: ])@.(<) 8
4 9 15 22 30

Super!

4 [`(] (] , (+{:)) ($:<:) )@.< 8


/Erling

On 2017-09-28 20:33, Skip Cave wrote:

What is a good way to generate this sequence in J?

  4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8)+.

Show one way using i. and insert.

Show another way using recursion.

Skip

Skip Cave
Cave Consulting LLC
-- 

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


--
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] Sequence generation

2017-09-28 Thread Don Kelly
Fair enough -he did ask for a recursive form. summing  is similar to the 
non recursive method for forming "sin" from  a series . In other words- 
why go to recursive- shades of Basic, Fortran and other languages 
needing a loop for this. It is a bit of beating a dead horse.


Don


On 2017-09-28 4:41 PM, Erling Hellenäs wrote:
It's not better. Skip asked for a recursive version too so  we gave 
him one. Very complicated way to write a simple thing. Lol. /Erling


On 2017-09-29 01:24, Don Kelly wrote:

why is this better than the easy to read version that Roger Hui sent?

quote:

   +/\4+i.10
4 9 15 22 30 39 49 60 72 85

unquote: This is also the way APL does it Sure it is fun to try 
different ways such as below, just as it is fun to make a 1 liner to 
generate a series for sin x. It is also nice to come back to a piece 
of code written a year earlier and be able to recognize quickly what 
it did. In the end- the simpler expression uses the power of J to do 
it more neatly and faster Don Kelly


On 2017-09-28 1:02 PM, Xiao-Yong Jin wrote:


On Sep 28, 2017, at 2:45 PM, Erling Hellenäs 
<erl...@erlinghellenas.se> wrote:


    4 [`(] (] , [ + [: {: ]) [ $: [: <: ])@.(<) 8
4 9 15 22 30

Super!

4 [`(] (] , (+{:)) ($:<:) )@.< 8


/Erling

On 2017-09-28 20:33, Skip Cave wrote:

What is a good way to generate this sequence in J?

  4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8)+.

Show one way using i. and insert.

Show another way using recursion.

Skip

Skip Cave
Cave Consulting LLC
-- 

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


--
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] Sequence generation

2017-09-28 Thread Don Kelly

why is this better than the easy to read version that Roger Hui sent?

quote:

   +/\4+i.10
4 9 15 22 30 39 49 60 72 85

unquote: This is also the way APL does it Sure it is fun to try 
different ways such as below, just as it is fun to make a 1 liner to 
generate a series for sin x. It is also nice to come back to a piece of 
code written a year earlier and be able to recognize quickly what it 
did. In the end- the simpler expression uses the power of J to do it 
more neatly and faster Don Kelly


On 2017-09-28 1:02 PM, Xiao-Yong Jin wrote:



On Sep 28, 2017, at 2:45 PM, Erling Hellenäs <erl...@erlinghellenas.se> wrote:

4 [`(] (] , [ + [: {: ]) [ $: [: <: ])@.(<) 8
4 9 15 22 30

Super!

4 [`(] (] , (+{:)) ($:<:) )@.< 8


/Erling

On 2017-09-28 20:33, Skip Cave wrote:

What is a good way to generate this sequence in J?

  4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8)+.

Show one way using i. and insert.

Show another way using recursion.

Skip

Skip Cave
Cave Consulting LLC
--
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


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

Re: [Jprogramming] Puzzling result

2017-09-11 Thread Don Kelly
I believe that Raul has hit it on the head.  14^2 will be floating as 
will generally be the case with % so it is possible that errors add or 
subtract to give an erroneous result. Note that


(14^2) (] - [ * [: <. ] % [)5729082486784839x

147


(14^2x) (] - [ * [: <. ] % [)5729082486784839

147

and

(14^2x)|5729082486784839

147


does it more simply


Don

On 2017-09-11 6:50 AM, Erling Hellenäs wrote:

(14^2x) (] - [ * [: <. ] % [)5729082486784839x

147

(14^2) (] - [ * [: <. ] % [)5729082486784839

_49

(14^2) (] - [ * _1 + [: <. ] % [)5729082486784839

147

/Erling


Den 2017-09-11 kl. 15:40, skrev Erling Hellenäs:
From what I see, floor gives an incorrect result which I correct with 
the " _1 + " There is not other problem. No loss of precision. /Erling



Den 2017-09-11 kl. 15:27, skrev Raul Miller:

I do not know what you are thinking, and you have not illustrated your
thoughts sufficiently for me to grasp them.

So, I thought I'd work through this:

    (14^2) (] - [ * _1 + [: <. ] % [)5729082486784839
147
    (14^2x) (] - [ * _1 + [: <. ] % [)5729082486784839x
343

Clearly, the exact answer is different from the quick answer.

If we compare
    load'debug/dissect'
    dissect '(14^2) (] - [ * _1 + [: <. ] % [)5729082486784839'
    dissect '(14^2x) (] - [ * _1 + [: <. ] % [)5729082486784839x'

We can see the initial off-by-one errors, but the big difference shows
up at the end (where we subtract from 5729082486784839)

The value we are subtracting is:

    (14^2x) ([ * _1 + [: <. ] % [)5729082486784839x
5729082486784496
    (14^2) ([ * _1 + [: <. ] % [)5729082486784839
5.72908e15

Looking at the bits needed to represent that as an integer:

    2^.(14^2) ([ * _1 + [: <. ] % [)5729082486784839
52.3472

we can see that that's right on the edge of being the number of
representable digits in a 64 bit float.

But, also, it's the result of multiplying

    14^2
196

by an off-by-one amount. And...

    343-196
147

...

Anyways, I'm not sure what you were thinking, but I guess we can take
this as a good example of the idea that errors can actually
accumulate.

Thanks,



--
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] Puzzling result

2017-09-09 Thread Don Kelly
IF and only IF there is  an application for extended complex numbers- 
which I expect to be  much rarer than the need for extended numbers in 
the first place- it would be possible to go back to the past and use the 
get-around routines used in handling them with real numbers only and 
scripting operations on these in rectangular components. It can be and 
has been done. Exponential and related trigonometric operations also can 
be extended but never will be exact.  There is a definite cost in time 
and space involved I have done this in APL*Plus and in a simulation of 
an HP11 calculator -modified for complex number operations (in visual 
Basic).   If somebody has an urgent need for extended operations, they 
can do this with their own definitions and accept the performance costs.


There appears to be a tendency to believe that a computer with an entry 
of 2 significant figures can provide a result good to 8 or 10 sig figs.


Enough of a rant

Don Kelly


On 2017-09-09 2:34 AM, Raul Miller wrote:

What would it be used for? (Related: how would the exponential aspects
of complex number operations get handled?)

Thanks,



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

Re: [Jprogramming] Puzzling result

2017-09-08 Thread Don Kelly
It appears that the verb   ^  may be a large part of the problem (as in 
14^2). Check NuVoc  /vocabulary/Numeric Precision  and go the table for 
different verbs . This and the division may be floating point in this case


_

^ ^. -: % %. inexact (complex if needed),

preserves extended and rational
if result is exact

_

Don Kelly

On 2017-09-08 1:36 AM, Raul Miller wrote:

No: integers do not automatically get converted to extended precision.

Integers simply have sufficient precision for this example.

Thanks,



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

Re: [Jprogramming] Puzzling result

2017-09-07 Thread Don Kelly

Yet this works

n=:14

(n^2x) |5729082486784839

147


Don Kelly

On 2017-09-07 11:40 AM, Erling Hellenäs wrote:

Hi all !

Case 1:
    3!:0 [ (n^2)

8

 (n^2) | 5729082486784839

0

It is non-intuitive that an integer raised to an integer is a float, 
but I think it is normal. It would be possible with a performance 
penalty to get an integer result. One problem with that is that it 
would easily overflow. It would also be possible to have a special 
operation for this case.
When the left argument is a float the right argument has to be 
converted to a float. It must be assumed that this conversion is 
intentional, even though it is implicit.


Case 2:
 3!:0 [ (n^2)

8

 (n^2) | 5729082486784839x

0

3!:0 (n^2) | 5729082486784839x

8

Here the rational seems to be converted to a float and the result is 
float. Shouldn't we have an error instead of converting rationals to 
float?


Case 3:

3!:0 (x: n^2)

128

 (x: n^2) | 5729082486784839

0

3!:0 (x: n^2) | 5729082486784839

128

I have a hard time understanding what happens here. This result seems 
very peculiar. Is the left and right argument converted to float and 
the float result converted to rational?!

Shouldn't we have an error instead of converting rationals to float?
We could not have floats auto-converted to rationals?
In this case the integer should be converted to rational and we should 
get a rational result?


It is non-intuitive that (*: n) does not give the same result as 
(n^2). Maybe once this was decided because of performance reasons.


Cheers,

Erling Hellenäs

On 2017-09-05 18:41, Rob B wrote:

Could someone explain this please?

  n=.14
    n
14
    (*: n) | 5729082486784839
147
    196 | 5729082486784839
147
    (n^2) | 5729082486784839
0
    (n^2) | 5729082486784839x
0
    (x: n^2) | 5729082486784839
0
    (x: n^2) | 5729082486784839x
147


Regards, Rob Burns
--
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] Another Quora Problem

2017-09-04 Thread Don Kelly

correction sum=: ]1+] for even numbers only from 2 to n%2

For numbers from 1 to n the sum is (n+1)*n%2 .

In the case that you give  x= sum of a+ (n-1)b,    which should be 
a+sum(n-1*b)  which can be simplified to a +b(1+2+3+..n-1)which becomes 
a +b*n*(n-1)%2  As you are considering a +(a+b)+ (a+2b) etc then this 
becomes (a*n) +b*n*(n-1)%2 which can be reduced to

a +1r2*b*]*1+]

Try it

Don

On 2017-08-31 7:39 PM, Don Kelly wrote:
The pairing eliminates the brute force  summing of the series. This is 
what Gauss found. In the case of only even numbers from 2 to n , this 
works. In the case of 42 there are 21 even numbers of which 20 can be 
paired off pairs 2+42,4+40 etc, each averaging 22 and there is an 
unpaired number which  is also 22 so we have 21*22. we could use


sum=: ]1+]

sum 21

462   But 'evensum ' below avoids the  onerous task of dividing 42 by 
2 before entry



evensum=: 1r4*]*2+]

evensum 42
462

evensum 10 100 1000 1

30 2550 250500 25005000


If you want numbers >4 to  42 then  -/evensum 42  4 does the trick



On 2017-08-30 9:27 PM, Xiao-Yong Jin wrote:

On Aug 30, 2017, at 10:43 PM, Don Kelly <d...@shaw.ca> wrote:

I agree with your opinion of what Skip wrote.  looking back to Gauss 
and figuring out the symmetry works for both odd and even cases (42 
&43 for example. However in his statement the numbers are 1...21 
where the numbers are 2 to 42  all even numbers- the result is still 
21*22 . 42%2 is 21 which is odd so that there is 1 number that isn't 
paired and 20  pairs averaging 22 and the oddball is 1 number =22  
Hence 22*21. The same result is for 1 to 43 as the odd numbers are 
ignored. If one considers evens between 2 and 44, there are 22 pairs 
(no oddball) averaging 23- the same rule works average =1+number of 
pairs. For summing odd numbers, add 1 to each number, drop the odds 
and do the even sum- then subtract the total (21 in this case to get 
462-21=441.
I don't understand why you worry about pairing, but if j code makes 
it easier to understand, here is a derivation I learned from my 
elementary school.


NB. for any evenly spaced sequence X: a, a+b, a+2*b, ... , a+(n-1)*b
X =. a+n*i.b
( +/ -: +/@|.   ) X
( +/ -: -:@(+/ + +/@|.) ) X
( +/ -: -:@([:+/ +/@(,:|.)) ) X
( +/ -: -:@([:+/ ##{.+{:)   ) X
( +/ -: -:@(#*{.+{:)    ) X

--
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] Another Quora Problem

2017-08-30 Thread Don Kelly
I agree with your opinion of what Skip wrote.  looking back to Gauss and 
figuring out the symmetry works for both odd and even cases (42 &43 for 
example. However in his statement the numbers are 1...21 where the 
numbers are 2 to 42  all even numbers- the result is still 21*22 . 42%2 
is 21 which is odd so that there is 1 number that isn't paired and 20  
pairs averaging 22 and the oddball is 1 number =22  Hence 22*21. The 
same result is for 1 to 43 as the odd numbers are ignored. If one 
considers evens between 2 and 44, there are 22 pairs (no oddball) 
averaging 23- the same rule works average =1+number of pairs. For 
summing odd numbers, add 1 to each number, drop the odds and do the even 
sum- then subtract the total (21 in this case to get 462-21=441.


Don


On 2017-08-30 6:47 AM, 'Mike Day' via Programming wrote:

Good points,  Skip.

Mind you,  I've learnt (and then forgotten again) a lot of J AND maths 
doing Euler probs.


Keep sharing,

Thanks,

Mike



On 29/08/2017 20:48, Skip Cave wrote:

Project Euler problems typically assume the use of a computer. Thus the
problems are often posed in a way that makes brute-force computer 
solutions
impractical, even when using fairly powerful machines. This forces 
Project

Euler problem-solvers to seek algorithmic approaches that avoid large
amounts of memory and/or compute time.
​ Thus Project Euler solutions emphasize the discovery of novel
(not-brute-force) algorithms, to minimize ​computational overhead.

However, discovering compute-optimal algorithms was not my primary 
goal in

working on Quora problems. My goal was to improve my proficiency in J,
particularly tacit J.

Quora problems are typically constructed to be difficult to solve by 
brute

force, if all you have is pencil and paper.
​
The idea is usually to study the problem and come up with a simple 
scheme

that
​can achieve
the answer, just using pencil and paper.
​
​
This is much like Project Euler, but the limit with Quora is space
​ on your paper,​
and your personal time to perform the individual manual calculations. ​
​Roger posted a perfect example of this issue with his story about 
Euler in

his math class, solving the sum of a sequence.​

Quora problems can quite often be solved using a brute force approach,
which can be constructed using a matrix language like J. My idea was 
that

solving selected Quora problems in J would be an excellent way for me to
improve my skills using tacit J. I believe my conjecture has been 
validated

by the array of diverse solutions presented by forum members, and my
resulting improved understanding of J.

​Skip​


Skip Cave
Cave Consulting LLC

On Tue, Aug 29, 2017 at 1:28 PM, 'Mike Day' via Programming <
programm...@jsoftware.com> wrote:

At the risk of getting too chatty,  I'd point out that in the 
majority of

Project
Euler problems*,  while you can (sometimes) explore the foothills of 
the

challenge,
including example solutions provided,  with a brute-force approach, 
it is

generally
necessary to find ways to avoid requiring too much of either or both
memory and
compute time.

BTW,  I recall the story that Gauss answered the sum of integers 
problem

in his
High School class,  by considering,  say,  the sequence 1 2 3 ... 20 
21,
and its reverse,  21 20 ... 3 2 1,  showing that each pair of items 
from

each sums
to 22,  so that the sum of the two sequences is 21 * 22... No doubt
apocryhal.

Cheers,

Mike

* see https://projecteuler.net

On 29/08/2017 09:04, Skip Cave wrote:


There seems to be two basic approaches to this problem:

1. Generate the even numbers between 1 & 42, and add them up.
2. Use the formula for the sum of an arithmetic progression - e.g.:

Sum=n(a+b)/2
*n* = number of numbers in the sequence (here 21)
*a* = the first number in the sequence (here 2)

*b* = the last number in the sequence (here 42)


Generally, I like to approach these kinds of Quora sequence 
problems using

a "brute force" approach, and ignore simplifying formulas. In the days
before modern computers, formulas were developed to make 
computations on
sequences like this Quora problem more tractable, particularly when 
the

number of terms got large.

Today, with powerful modern computers and languages, it is often 
easier to

simply generate a sequence in it's entirety, and then compute some
property
of that sequence such as it's limit, sum, etc. to get the final 
result.

This is particularly true when you have at your fingertips a powerful
matrix language such as APL or J.

For me, the obvious approach to this problem is to simply generate the
sequence of even integers and then sum them, instead of trying to 
find a
formula that relates to that specific sequence (in any case, I 
didn't have

a clue where to look for such formulas).

So the plan was: Generate the numbers from 0 to 42, throw out the odd
numbers (zero doesn't matter in this problem), and then add up what's
left:

  a =:i.43

  +/(-.2|a)#a

462


My main dissatisfaction was that 

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Don Kelly

Did anyone try these?

+/2*1+i.21

462


+/2*i.22


462


Don Kelly


On 2017-08-29 6:17 AM, Murray Eisenberg wrote:

The sum in question is twice the sum of the integers from 1 to 21. By the 
well-known formula (sometimes attributed to Gauss), the latter sum is half the 
product of 21 and 21 + 1, so the sum in question is

 */21+i. 2
462



On28 Aug 2017 12:02:57 -0500,S kip Cave <s...@caveconsulting.com 
<mailto:s...@caveconsulting.com>> wrote:

A simple problem posted on Quora:

What is the sum of all the even numbers from 2 to 42?

My J solution:
   a=:>:i.42
  +/(-.2|a)#a
462

I'm sure this can be done in a single line using a hook or fork.
but I'm not clear enough with the train rules to put this all together
on a single line.
Any suggestions?

——
Murray Eisenbergmur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower  phone 240 246-7240 (H)
University of Massachusetts
710 North Pleasant Street
Amherst, MA 01003-9305




--
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] "n-volume" of an "n-sphere"

2017-08-20 Thread Don Kelly
Possibly I had an incomplete description of the problem but the use of 
"point" brought up the problem of "how big is a point?".


Your definitions below do help -and also make the problem more 
interesting for n>3


Don

On 2017-08-20 7:33 AM, Murray Eisenberg wrote:

Re Don Kelly’s comment:

NO the ball of radius r at a point p in n-space is the set of all points of 
distance strictly less than than r from p;
  the disk of radius r at a point p in n-space is the set of all points 
of distance at most r from p.
   
“Infinitesimal” has utterly nothing to do with it, nor does transfinite math (although the set of points in such a ball, or such a disk, is definitely infinite and, in fact, uncountable.


Re Jimmy Gauvin’s comment:

  It is utterly trivial to prove that a ball (or disk) in euclidean n-space 
is convex. It requires nothing more than what is commonly taught in standard 
courses in sophomore linear algebra today. Specifically, basic properties of 
the euclidean norm, including the triangle inequality.


On 2Sat, 19 Aug 2017 18:03:49 -0700,Don Kelly <d...@shaw.ca 
<mailto:d...@shaw.ca>> wrote:

If one considers a point as infinitesimal -as usually considered-, then
we have an infinite number of points at an infinitesimal distance from
the origin and at a larger distance from the origin there are still an
infinite number of points on the surface and  an infinite number of
points enclosed . Isn't this getting into transfinite math?

What's the point?

Don Kelly


On 2017-08-15 8:23 PM, Jimmy Gauvin wrote:

The construction of the sphere implies it cannot be convex but you will
have to find a topologist to prove it to you.

The sphere is the collection of points whose distance to the origin is
equal to the radius of the sphere.

The ball or volume is comprised of the points whose distance to the origin
is equal or smaller than the radius of the sphere.

——
Murray Eisenbergmur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower  phone 240 246-7240 (H)
University of Massachusetts
710 North Pleasant Street
Amherst, MA 01003-9305




--
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] "n-volume" of an "n-sphere"

2017-08-19 Thread Don Kelly
If one considers a point as infinitesimal -as usually considered-, then 
we have an infinite number of points at an infinitesimal distance from 
the origin and at a larger distance from the origin there are still an 
infinite number of points on the surface and  an infinite number of 
points enclosed . Isn't this getting into transfinite math?


What's the point?

Don Kelly


On 2017-08-15 8:23 PM, Jimmy Gauvin wrote:

The construction of the sphere implies it cannot be convex but you will
have to find a topologist to prove it to you.

The sphere is the collection of points whose distance to the origin is
equal to the radius of the sphere.

The ball or volume is comprised of the points whose distance to the origin
is equal or smaller than the radius of the sphere.


On Tue, Aug 15, 2017 at 10:41 PM, bill lam <bbill@gmail.com> wrote:


Has the n-sphere become concave in higher dimension?

Вт, 15 авг 2017, Jimmy Gauvin написал(а):

Funny how the n-Sphere volume dwindles for the higher dimensions.
Not quite intuitive but the factorial always "win" even with bigger

radii.

The hypercubes do not share this characteristic (V= edge ^ n)



On Tue, Aug 15, 2017 at 3:33 PM, Ben Gorte - CITG <

b.g.h.go...@tudelft.nl>

wrote:


A little surprise (to me) was
plot 1 sphvol i.30
(for example)

Can you predict it?

greetings,
Ben

From: Programming [programming-boun...@forums.jsoftware.com] on

behalf of

Raul Miller [rauldmil...@gmail.com]
Sent: Tuesday, August 15, 2017 19:55
To: Programming forum
Subject: [Jprogramming] "n-volume" of an "n-sphere"

sphvol=: (1p1&^%!)@-:@] * ^
1 sphvol 3
4.18879
1 sphvol i.7
1 2 3.14159 4.18879 4.9348 5.26379 5.16771

Left argument is the radius of the "n-sphere".

Right argument is the number of dimensions.

I put "n-volume" in quotes, because if the dimension is 2 (for
example), the "n-volume" is what we call the area of the circle. (And
if the dimension is 1 that "n-volume" is the length of a line
segment).

Anyways, I stumbled across this and thought it might be interesting
for someone else.

Thanks,

--
Raul
--
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

--
regards,

GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
--
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] Integer-floating type change for large numbers in j805 and j806

2017-08-12 Thread Don Kelly
I think that Don Guinn was referring to the fact that the output results 
from input of n sig figs will not be good to anything better than n  sig 
figs. You have pointed out limits in  the representation of base 10 
integers in a base 2 system. In fact, the results of multiplying 2 4 
digit numbers might result in an overflow or conversion to float with 
truncation.


Don Kelly
On 2017-08-12 12:19 PM, 'Bo Jacoby' via Programming wrote:

Don Guinn wrote: "But few things need precision beyond 16 significant digits". 
Well, just computing the determinant of a 4*4 matrix of 4-figure integers require 16 
digit precision!

 Den 1:52 lørdag den 12. august 2017 skrev Don Kelly <d...@shaw.ca>:
  


  Right on!

In most numerical operations on a  computer, there is an inherent
propagation of errors (in fact Numerical analysis texts spend a lot of
effort on ways to reduce such errors) and 16 or more digits don't
provide precision greater than  that of the input data but do reduce the
computational  fuzz to an insignificant level. The ideal kit for a
student using a hand calculator would be a strip of electrical tape to
cover the extra digits.

Don Kelly


On 2017-08-11 6:33 AM, Don Guinn wrote:

We too often assume that calculations carried out to 16 significant digits
are accurate when the input may not be known to less than 2 or 3
significant digits. We can calculate the distance to the moon accurately to
the wavelength of visible light in IEEE floating point. We can calculate
the national debt to the penny. Maybe calculating relativistic effects on a
satellite orbiting the earth might exceed IEEE floating point. But few
things need precision beyond 16 significant digits.

On Thu, Aug 10, 2017 at 11:14 PM, Don Kelly <d...@shaw.ca> wrote:


isn't an advantage of APL and J that the person writing a
program/app/whatever, doesn't  have to deal with the distinctions between
integer and damn near integer  within the limitations of the computer
binary resolution?. In most cases this isa good thing because close enough
-given the +/- of data input is sufficient for the idiot box to decide. J
moves away from C/C++/ and other languages which often seem to be
emphasizing stuff that Iverson tried to eliminate in APL and J . Muh of
that stuff is something that can be handled by the idiot box so that:

Problem-->basic analysis--. coding that fits the analysis rather than the
details( users aim at the essentials rather than the details- "/I  want the
answer and I dont care about what is involved in the background of %,*
*/

The discussion below deals with representation of numeric values being
floating point or integer when pushing the limits-IS IT IMPORTANT IN THE
REAL WORLD unless  you have a Cray in the back bedroom?

Old fart expressing opinions

Don Kelly

On 2017-08-10 6:27 PM, Bill wrote:


I suspect J interpreter didn't has the knowledge  that the original
string had been .3
with .3 because what J saw was the floating point result of parsing by c
library. Ieee floating point has 15 to 16 significant digits so that 1e16
and 1e16-1 is the same number.

Perhaps one could use long double to parse number on J64.

Sent from my iPhone

On 10 Aug, 2017, at 3:48 AM, Henry Rich <henryhr...@gmail.com> wrote:

Quite right.

Henry Rich

On Aug 9, 2017 20:46, "Raul Miller" <rauldmil...@gmail.com> wrote:

Well, since it's encoded as an integer (which I would have noticed if

I had read Bob Therriault's original post more closely), and not [like
I was thinking] a float, I agree that dropping the .3 is better than
adding a 1.

That said, I guess we also should not object too loudly if
.3 were instead encoded the same as
+0.3 gets encoded.

Thanks,

--
Raul

On Wed, Aug 9, 2017 at 3:25 PM, Henry Rich <henryhr...@gmail.com>
wrote:


Surely integer 999...9 is a better value than 1000...0 .

Henry Rich

On Aug 9, 2017 18:33, "Raul Miller" <rauldmil...@gmail.com> wrote:

It's not a bug, it's an artifact of the 64 bit floating point standard.

 2 ^.
53.1508

https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats

The binary64 format has 53 binary digits or 15.95 decimal digits. This
means ".16#'9' cannot be represented exactly using this format.

And, we do not use exact representation of large numbers by default
because that's too slow for large datasets. Put differently, if you
want exact representation and are willing to take the performance hit,
you should specify that. For example: ".'x',~16#'9' or
".'3r10+','x',~16#'9'

Thanks,

--
Raul

On Wed, Aug 9, 2017 at 12:05 PM, Henry Rich <henryhr...@gmail.com>


wrote:
This is a bug,  since 999...9.3 should become 999...9 rather than

100...0.


I'm away from home now,  but I think what's happening is this:

999...9 is converted to integer

. is encountered and turns it to float

It's rounded to the nearest float

Re: [Jprogramming] Integer-floating type change for large numbers in j805 and j806

2017-08-11 Thread Don Kelly

Right on!

In most numerical operations on a  computer, there is an inherent 
propagation of errors (in fact Numerical analysis texts spend a lot of 
effort on ways to reduce such errors) and 16 or more digits don't 
provide precision greater than  that of the input data but do reduce the 
computational  fuzz to an insignificant level. The ideal kit for a 
student using a hand calculator would be a strip of electrical tape to 
cover the extra digits.


Don Kelly


On 2017-08-11 6:33 AM, Don Guinn wrote:

We too often assume that calculations carried out to 16 significant digits
are accurate when the input may not be known to less than 2 or 3
significant digits. We can calculate the distance to the moon accurately to
the wavelength of visible light in IEEE floating point. We can calculate
the national debt to the penny. Maybe calculating relativistic effects on a
satellite orbiting the earth might exceed IEEE floating point. But few
things need precision beyond 16 significant digits.

On Thu, Aug 10, 2017 at 11:14 PM, Don Kelly <d...@shaw.ca> wrote:


isn't an advantage of APL and J that the person writing a
program/app/whatever, doesn't   have to deal with the distinctions between
integer and damn near integer  within the limitations of the computer
binary resolution?. In most cases this isa good thing because close enough
-given the +/- of data input is sufficient for the idiot box to decide. J
moves away from C/C++/ and other languages which often seem to be
emphasizing stuff that Iverson tried to eliminate in APL and J . Muh of
that stuff is something that can be handled by the idiot box so that:

Problem-->basic analysis--. coding that fits the analysis rather than the
details( users aim at the essentials rather than the details- "/I  want the
answer and I dont care about what is involved in the background of %,*
*/

The discussion below deals with representation of numeric values being
floating point or integer when pushing the limits-IS IT IMPORTANT IN THE
REAL WORLD unless  you have a Cray in the back bedroom?

Old fart expressing opinions

Don Kelly

On 2017-08-10 6:27 PM, Bill wrote:


I suspect J interpreter didn't has the knowledge  that the original
string had been .3
with .3 because what J saw was the floating point result of parsing by c
library. Ieee floating point has 15 to 16 significant digits so that 1e16
and 1e16-1 is the same number.

Perhaps one could use long double to parse number on J64.

Sent from my iPhone

On 10 Aug, 2017, at 3:48 AM, Henry Rich <henryhr...@gmail.com> wrote:

Quite right.

Henry Rich

On Aug 9, 2017 20:46, "Raul Miller" <rauldmil...@gmail.com> wrote:

Well, since it's encoded as an integer (which I would have noticed if

I had read Bob Therriault's original post more closely), and not [like
I was thinking] a float, I agree that dropping the .3 is better than
adding a 1.

That said, I guess we also should not object too loudly if
.3 were instead encoded the same as
+0.3 gets encoded.

Thanks,

--
Raul

On Wed, Aug 9, 2017 at 3:25 PM, Henry Rich <henryhr...@gmail.com>
wrote:


Surely integer 999...9 is a better value than 1000...0 .

Henry Rich

On Aug 9, 2017 18:33, "Raul Miller" <rauldmil...@gmail.com> wrote:

It's not a bug, it's an artifact of the 64 bit floating point standard.

2 ^.
53.1508

https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats

The binary64 format has 53 binary digits or 15.95 decimal digits. This
means ".16#'9' cannot be represented exactly using this format.

And, we do not use exact representation of large numbers by default
because that's too slow for large datasets. Put differently, if you
want exact representation and are willing to take the performance hit,
you should specify that. For example: ".'x',~16#'9' or
".'3r10+','x',~16#'9'

Thanks,

--
Raul

On Wed, Aug 9, 2017 at 12:05 PM, Henry Rich <henryhr...@gmail.com>


wrote:
This is a bug,  since 999...9.3 should become 999...9 rather than

100...0.


I'm away from home now,  but I think what's happening is this:

999...9 is converted to integer

. is encountered and turns it to float

It's rounded to the nearest float which is 100...0

As a final step the JE checks to see if the value is exactly
integral,
which it is,  and it is converted back to integer.

If you add this to Interpreter/Bugs I'll fix it when i get back.

Henry Rich

On Aug 9, 2017 16:16, "bill lam" <bbill@gmail.com> wrote:

I think this is the difference between 32 and 64-bit,

9!:14''
j602/2008-03-03/16:45
3!:0[ .3
4

In J32

a.i. 2 fc .3
0 128 224 55 121 195 65 67
a.i. 2 fc 1e16
0 128 224 55 121 195 65 67

the number has the same bit pattern as 1e16 (an integer)
which can be represented as a 64-bit integer. I guess
J64 is correct since .3 and 1e16 is the
same number in 

Re: [Jprogramming] 4 <3!:0 <. y WAS: Integer-floating type change for large numbers in j805 and j806

2017-08-11 Thread Don Kelly
I see your point but how likely will a 9999. sort of situation 
occur? Drop 1 digit and the result will be 1e15. which is perfectly 
satisfactory. The problem is that when you push the limits of the size 
of a floating point number, the result is within the the tolerance level 
for 'close enough" to integer to be treated as one. This is inherent in 
APL and J and was done for a purpose. -the number of digits of a float 
will be less than  for an integer because the float requires an exponent 
as well as a mantissa while then integer doesn't need the exponent. A 
32bit word could hold a 31 bit number while a float with an 8 bit 
exponent would hold a 23 bit number


r=:1.0009

r=1

1

r-1

8.88178e_16

r=:1.9

r=1

1

r-1

0

least significant bits lost because there is no room for them. in 
99.+ % of cases this is not a problem.


Don Kelly

On 2017-08-11 2:11 AM, Henry Rich wrote:

The error, methinks, is that 999...9. is rounded to integer and then
reported as integer.   It should keep floating type.

Bit-twisting code needs to be sure that no bits have been lost.   Integral
type should be a guarantee of that.  Floats that have values
unrepresentable accurately should not be automatically called ints.

Henry Rich

On Aug 11, 2017 06:14, "Don Kelly" <d...@shaw.ca> wrote:

isn't an advantage of APL and J that the person writing a
program/app/whatever, doesn't   have to deal with the distinctions between
integer and damn near integer  within the limitations of the computer
binary resolution?. In most cases this isa good thing because close enough
-given the +/- of data input is sufficient for the idiot box to decide. J
moves away from C/C++/ and other languages which often seem to be
emphasizing stuff that Iverson tried to eliminate in APL and J . Muh of
that stuff is something that can be handled by the idiot box so that:

Problem-->basic analysis--. coding that fits the analysis rather than the
details( users aim at the essentials rather than the details- "/I  want the
answer and I dont care about what is involved in the background of %,*
*/

The discussion below deals with representation of numeric values being
floating point or integer when pushing the limits-IS IT IMPORTANT IN THE
REAL WORLD unless  you have a Cray in the back bedroom?

Old fart expressing opinions

Don Kelly


On 2017-08-10 6:27 PM, Bill wrote:


I suspect J interpreter didn't has the knowledge  that the original string
had been .3
with .3 because what J saw was the floating point result of parsing by c
library. Ieee floating point has 15 to 16 significant digits so that 1e16
and 1e16-1 is the same number.

Perhaps one could use long double to parse number on J64.

Sent from my iPhone

On 10 Aug, 2017, at 3:48 AM, Henry Rich <henryhr...@gmail.com> wrote:

Quite right.

Henry Rich

On Aug 9, 2017 20:46, "Raul Miller" <rauldmil...@gmail.com> wrote:

Well, since it's encoded as an integer (which I would have noticed if

I had read Bob Therriault's original post more closely), and not [like
I was thinking] a float, I agree that dropping the .3 is better than
adding a 1.

That said, I guess we also should not object too loudly if
.3 were instead encoded the same as
+0.3 gets encoded.

Thanks,

--
Raul

On Wed, Aug 9, 2017 at 3:25 PM, Henry Rich <henryhr...@gmail.com> wrote:


Surely integer 999...9 is a better value than 1000...0 .

Henry Rich

On Aug 9, 2017 18:33, "Raul Miller" <rauldmil...@gmail.com> wrote:

It's not a bug, it's an artifact of the 64 bit floating point standard.

2 ^.
53.1508

https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats

The binary64 format has 53 binary digits or 15.95 decimal digits. This
means ".16#'9' cannot be represented exactly using this format.

And, we do not use exact representation of large numbers by default
because that's too slow for large datasets. Put differently, if you
want exact representation and are willing to take the performance hit,
you should specify that. For example: ".'x',~16#'9' or
".'3r10+','x',~16#'9'

Thanks,

--
Raul

On Wed, Aug 9, 2017 at 12:05 PM, Henry Rich <henryhr...@gmail.com>


wrote:
This is a bug,  since 999...9.3 should become 999...9 rather than

100...0.


I'm away from home now,  but I think what's happening is this:

999...9 is converted to integer

. is encountered and turns it to float

It's rounded to the nearest float which is 100...0

As a final step the JE checks to see if the value is exactly integral,
which it is,  and it is converted back to integer.

If you add this to Interpreter/Bugs I'll fix it when i get back.

Henry Rich

On Aug 9, 2017 16:16, "bill lam" <bbill@gmail.com> wrote:

I think this is the difference between 32 and 64-bit,

9!:14''
j602/2008-03-03/16:45
3!:0[ .3
4

In J32

a.i. 2 

Re: [Jprogramming] Integer-floating type change for large numbers in j805 and j806

2017-08-10 Thread Don Kelly
isn't an advantage of APL and J that the person writing a 
program/app/whatever, doesn't   have to deal with the distinctions 
between integer and damn near integer  within the limitations of the 
computer binary resolution?. In most cases this isa good thing because 
close enough -given the +/- of data input is sufficient for the idiot 
box to decide. J  moves away from C/C++/ and other languages which often 
seem to be  emphasizing stuff that Iverson tried to eliminate in APL and 
J . Muh of that stuff is something that can be handled by the idiot box 
so that:


Problem-->basic analysis--. coding that fits the analysis rather than 
the details( users aim at the essentials rather than the details- "/I  
want the answer and I dont care about what is involved in the background 
of %,*

*/

The discussion below deals with representation of numeric values being 
floating point or integer when pushing the limits-IS IT IMPORTANT IN THE 
REAL WORLD unless  you have a Cray in the back bedroom?


Old fart expressing opinions

Don Kelly

On 2017-08-10 6:27 PM, Bill wrote:

I suspect J interpreter didn't has the knowledge  that the original string had 
been .3
with .3 because what J saw was the floating point result of parsing by c 
library. Ieee floating point has 15 to 16 significant digits so that 1e16 and 
1e16-1 is the same number.

Perhaps one could use long double to parse number on J64.

Sent from my iPhone

On 10 Aug, 2017, at 3:48 AM, Henry Rich <henryhr...@gmail.com> wrote:


Quite right.

Henry Rich

On Aug 9, 2017 20:46, "Raul Miller" <rauldmil...@gmail.com> wrote:


Well, since it's encoded as an integer (which I would have noticed if
I had read Bob Therriault's original post more closely), and not [like
I was thinking] a float, I agree that dropping the .3 is better than
adding a 1.

That said, I guess we also should not object too loudly if
.3 were instead encoded the same as
+0.3 gets encoded.

Thanks,

--
Raul

On Wed, Aug 9, 2017 at 3:25 PM, Henry Rich <henryhr...@gmail.com> wrote:

Surely integer 999...9 is a better value than 1000...0 .

Henry Rich

On Aug 9, 2017 18:33, "Raul Miller" <rauldmil...@gmail.com> wrote:


It's not a bug, it's an artifact of the 64 bit floating point standard.

   2 ^.
53.1508

https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats

The binary64 format has 53 binary digits or 15.95 decimal digits. This
means ".16#'9' cannot be represented exactly using this format.

And, we do not use exact representation of large numbers by default
because that's too slow for large datasets. Put differently, if you
want exact representation and are willing to take the performance hit,
you should specify that. For example: ".'x',~16#'9' or
".'3r10+','x',~16#'9'

Thanks,

--
Raul

On Wed, Aug 9, 2017 at 12:05 PM, Henry Rich <henryhr...@gmail.com>

wrote:

This is a bug,  since 999...9.3 should become 999...9 rather than

100...0.

I'm away from home now,  but I think what's happening is this:

999...9 is converted to integer

. is encountered and turns it to float

It's rounded to the nearest float which is 100...0

As a final step the JE checks to see if the value is exactly integral,
which it is,  and it is converted back to integer.

If you add this to Interpreter/Bugs I'll fix it when i get back.

Henry Rich

On Aug 9, 2017 16:16, "bill lam" <bbill@gmail.com> wrote:

I think this is the difference between 32 and 64-bit,

   9!:14''
j602/2008-03-03/16:45
   3!:0[ .3
4

In J32

   a.i. 2 fc .3
0 128 224 55 121 195 65 67
   a.i. 2 fc 1e16
0 128 224 55 121 195 65 67

the number has the same bit pattern as 1e16 (an integer)
which can be represented as a 64-bit integer. I guess
J64 is correct since .3 and 1e16 is the
same number in ieee fp and J prefers integer to floats,
eg
  3!:0 [ 2.0
4

Ср, 09 авг 2017, robert therriault написал(а):

Hi Pascal,

I see the same behaviour in j806 as j805. Do you see something

different?

JVERSION
Engine: j806/j64avx/darwin
Beta-4: commercial/2017-06-27T12:55:06
Library: 8.06.03
Qt IDE: 1.5.3/5.6.2
Platform: Darwin 64
Installer: J806 install
InstallPath: /users/bobtherriault/j64-806
Contact: www.jsoftware.com
   (; datatype) 999.3
┌┬┐
│1e15│floating│
└┴┘
   (; datatype) .3
┌─┬───┐
│1│integer│
└─┴───┘
   (; datatype) 9.3
┌──┬───┐
│10│integer│
└──┴───┘
   (; datatype) 99.3
┌───┬───┐
│100│integer│
└───┴───┘
   (; datatype) 999.3
┌┬┐
│1e19│floating│
└┴┘

Cheers, bob


On Aug 9, 2017, at 7:54 AM, 'Pascal Jasmin' via Programming <

programm

Re: [Jprogramming] Multidimensional Root Finding with Newton Solver

2017-08-10 Thread Don Kelly
I also suggest that you look at references to the use of NR for power 
system  load flow problems which are non-linear and generally expressed 
in  terms of complex numbers in the  polar format. These do converge 
well. I haven't written one in J but one written in APL has 11 readable 
lines-most of which are setting up the matrices to solve (with no 
complex number capability- J should be more compact).


Don


On 2017-08-10 1:10 PM, Ian Clark wrote:

Is it also possible to solve a system of equation like the following

one… ?

Basically, yes.

Because not only can x = (x1,x2) be a vector, but so can y = (y1,y2) in
this adaptation of your equations:

  y1 = a*(1-x1)
  y2 = b*(x2-x1^2)

TABULA is an app (distributed as a JAL "addon") which employs
Newton-Raphson (occasionally) to "solve" systems of non-linear equations
supplied by the user. "Solve" includes replacing y2, say, with (y2+∆y2) and
relying on TABULA to adjust x2, x1 and y1 accordingly.

…And to do so without forcing a debate with the clueless user as to what
"accordingly" means here.

As you'll be aware, N-R algorithms don't always converge, especially when
you don't have control over what the user throws at you. Pure
mathematicians do; engineers don't. Hyperbolic functions behave badly, e.g.
y-->(y+∆y) in: y = k/x unless (∆y) is "small enough"… again there is no
point asking the poor user what "small enough" is supposed to mean in this
instance.

For a problem that has no general solution, TABULA performs remarkably well
with the systems of (sometimes non-linear) equations that physicists and
engineers typically need solving. Occasionally TABULA throws up its hands
in despair – as even the perfect app would have to, when faced with y-->(y+∆y)
in: y = sin(x) whenever ∆y takes (y+∆y) outside the domain: [-1,1].

I suggest you read these articles:

http://code.jsoftware.com/wiki/TABULA/LaunchElephant
http://code.jsoftware.com/wiki/TABULA/ChurchClock-NEW

as examples of the sort of empirical problem TABULA is designed to address.
Then examine the code of the addon: CAL, the engine used by TABULA to do
the real work. Particularly the verb: (inversion) and its ancillary (and
alternative) verbs.


… in a similar elegant manner?

Since TABULA is an empirical tool for non-mathematicians, such as K-12
pupils and college students training to be physicists, engineers and
ecologists, it sacrifices a great deal of elegance in the interests of
generality and practicality, not to mention giving the user a
comprehensible answer when things go wrong. Thus in practice the "_" in "
N^:_" needs replacing by a finite value simply to timeout the infinite
iterations which can and do occur.

Accordingly you'll see that the different variants of the verb (inversion)
are nowhere near as pretty as: N=: 1 : '- u % u d. 1'

You don't say whether you are a mathematician (in particular a functional
analyst) or an engineer. Whichever it is, you'll either be baffled by, or
scornful of, the code in CAL.ijs. But it should give you a bit of a start
in whatever you want to do.


On Thu, Aug 10, 2017 at 7:07 PM, Martin  wrote:


Hi there,

J looks very interesting. I have no previous experience with array
languages and, being curious, started to experiment.  Now, I would
like to solve a system of non-linear equations. I could only examples
solving single equations like this one:

   N=: 1 : '- u % u d. 1'   NB. Adverb implementing Newton-Raphson
iteration.
   (_2 + *:) N^:_ ]1NB. Find root of “0 = _2+x^2”, starting guess
of “1”.

Is it also possible to solve a system of equation like the following
one in a similar elegant manner?

   f1(x) = a*(1-x1)
   f2(x) = b*(x2-x1^2)

Example from https://www.gnu.org/software/gsl/doc/html/multiroots.html#
examples

Thanks for any ideas!
-Martin

--
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] Fractional parts

2017-08-10 Thread Don Kelly

I agree with your contention  on the basis that _3.15 = -(3.15) or _3 +_0.15

and your  use of   what I named   fp1=:* * 1 | | does this

For the real part   rp1=: ] - fp1

v

_2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986

fp1 v

_0.375 _0.84615 _0.4 0.0028 0.0014 0 0.9986

rp1 v

_2 _5 _11 13 13 13 12

Don Kelly


On 2017-08-09 2:21 PM, Skip Cave wrote:

Bo said:
v=(<.v)+(1|v) NB. number = integer part + fractional part? Yes!

True. However, if
   ]v=:2%(3r19-%1 2 3 245 246 247 248)
_2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986

And we define the fractional part of v your way:

 1|v

0.625 0.153846 0.6 0.0027933 0.00139082 0 0.998621

I contend that 0.0625 is NOT the fractional part of _2.375, at least not in
my eyes. It may be the residue of a division by one, but that isn't what I
call a fractional part of a negative number (except maybe in 2s complement
binary)

Also, using your definition of the integer part:

  ]v=:2%(3r19-%1 2 3 245 246 247 248)
_2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986

   <. v

_3 _6 _12 13 13 13 12

_3 _6 _12 isn't the integer part of  _2.375 _5.84615 _11.4

However, as you say:

  v=(<.v)+(1|v)

1 1 1 1 1 1 1

So my test for finding the correct fractional and integer parts of a number
by adding the two parts together are not sufficient to determine if the ip
and fp are the correct values.


Skip
--
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] Matrix operations questions

2017-07-29 Thread Don Kelly
NB: I wrote this before looking at the J rosetta code which includes the 
generation of the Ybus matrix -


If your object is to find the equivalent (Thevenin) resistance between 
any 2 points, I would suggest that it would be better to work with an 
admittance model. It eliminates the problem with infinite resistances  
and typically will be sparse. Such methods are used with large power 
grid analyses. The admittance method chooses one node  as reference, 
typically ground but it could be an other node or vertex.  (it doesn't 
appear in the admittance "Ybus" matrix) .  This is easy to set up as the 
yii terms are simply the sum of admittance's connected to that node and 
the yij terms are the negative of the sum of admittance's connected 
between i and j. Inverting this matrix gives what is called the Zbus 
matrix where the diagonal elements are the Thevenin impedance's 
(resistive in your case). Off diagonal elements are transfer 
impedance's. Essentially a two port idea extended to multi ports. A neat 
thing is that Zbus includes all the information to find the resistance 
seen between any pair of nodes as once you have it, the resistance 
between nodes i and j is Rii +Rjj- 2Rij


here is a simple sample:

node  node  r1/r
  0ref0.254
  010.5 2
  020.2 5
  1ref 0.25   4
  1 2   0.25   4

]ybus=: > 11 _2 _5;_2 10 _4;_5 _4 9

11 _2 _5

_2 10 _4

_5 _4 9

]zbus=:%.ybus

0.165179 0.0848214 0.129464

0.0848214 0.165179 0.120536

0.129464 0.120536 0.236607

+/ 1 _1 _1 1*,(<0 2;0 2){zbus

0.142857 impedance seen between node 0 and node 2

etc

Don

On 2017-07-27 9:56 PM, Brian Babiak wrote:

I’m working on a project to compute the distance resistance between two 
vertices in an electronic grid. I will share that later. But I am having domain 
error issues with matrix inverse and matrix product operations. See the 
following:

  


f=.2 2$3 4 1 4

g=.2 2$i.2

h=.2 2$_3 4 2 _3

  


2 3$'f';'g';'h';f;g;h

┌───┬───┬─┐

│f  │g  │h│

├───┼───┼─┤

│3 4│0 1│_3  4│

│1 4│0 1│ 2 _3│

└───┴───┴─�




2 3$'$f';'$g';'$h';($f);($g);($h)

┌───┬───┬───┐

│$f │$g │$h │

├───┼───┼───┤

│2 2│2 2│2 2│

└───┴───┴───�




f . g

|domain error

|   f .g

f . h

|domain error

|   f .h

%. f

0.5  _0.5

_0.125 0.375

%. g

|domain error

|   %.g

f . f

|domain error

|   f .f

g . g

|domain error

|   g .g

h . h

|domain error

|   h .h

h * g

0  4

0 _3

  


The answers to all these operations are simple. Why are there these domain 
errors?

  


Here is the project this issue is coming up in, although I believe it is more 
basic than that.

  


vw=: (,@(((_ 0)$~#@:])`]`(1$~,~@:}.@[)}))`(,@(((0 
_)$~#@:])`]`(1$~,~@:}.@[)}))@.(<:@:({.@:[))

NB. (moveno boardsz) nw (x1 y1;x2 y2; etc)

NB. Gives vertex weights for a move list of a game as vector

  

  


rows=: <"1

cols=: <"1@|:

diags=: (-.((0;_1)&{))@:(0{z [ i=. 1 [ n=. #z [ z=. diags y

while. ii{z

   i=. >:i

   adds=. >2<\col

   r=. r,adds

   r=. r,(|."1 adds)

end.

)

  


connsq=: 3 : 0

r=. 0 2$0 [ i=. 0 [ n=. #z [ z=. y

while. ii{z

   i=. >:i

   adds=. >2<\col

   r=. r,adds

   r=. r,(|."1 adds)

end.

)

connrws=: connsq@:rows

conncls=: connsq@:cols

  


edges=: 3 : 0 NB. takes board size as argument

a=. (2$bs)$i.*:bs [ bs=. y

r=. (connrws a),(conncls a)

r=. r,conndiag a

)

  


BOARDSZ=: 5

EDGES=: edges BOARDSZ

VPLYR=: 1 NB. whether the vertical player is first or second

  


A=: 3 : 0

mat=. (2$netsz)$0 [ netsz=. *:BOARDSZ [ j=. 0 [ i=. 0 [ arg=. VPLYR,BOARDSZ

if. y=0 do. pcweights=. netsz$1 else. pcweights=. arg vw y end.

while. i:j

   end.

   j=. 0

   i=. >:i

end.

mat

)

  


D=: 3 : 0

diag=. (2$netsz)$ 1,netsz#0 [ netsz=. *:BOARDSZ [ colsum=. +/y [ y=. A y

r=. colsum*diag

)

  


L=: D-A NB. the Laplacian

  


NB. %. Laplacian or . (dot) for Laplacian times current gives domain errors

  


Any help would be appreciated!

  


Brian Babiak MD

https://drbabiak.com

  

  


--
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] Request for comments: multiple assignment

2017-07-12 Thread Don Kelly

How is "is" more useful  than  from x=: y

what is interesting is that

'abc' is "0 i.3 4 5 displays the i.3 4 5 array but the value of abc 
appears as : although a, b, c correspond to


(<0 1 2; 3; 4){i. 3 4 5

19 39 59


In the use of "is" in this case it appears that it


whereas 'abc' =: i. 3 4 5 gives stores the noun abc as the array but 
leaves a, b and c undefined


and 'a b c' =:i.3 4 5  gives 3  (4 by 5 )arrays


Don Kelly


On 2017-07-12 11:08 AM, Jose Mario Quintana wrote:

Maybe I am misunderstanding...  Are you trying to imply that one cannot
find a verb such as  is=: 4 :'(x)=:y'  useful?


On Tue, Jul 11, 2017 at 8:37 PM, Raul Miller <rauldmil...@gmail.com> wrote:


Ok, so, just to be clear - this has nothing to do with default assignment?

That said, it's probably intentional that there's no verb form of =:
(or =.). For example, given

is=: 4 :'(x)=:y'

consider:

   'abc' is"0 i.3 4 5

Questions:

(1) what is

a+b+c

(2) how is this useful?

Thanks,

--
Raul


On Tue, Jul 11, 2017 at 12:53 PM, 'Pascal Jasmin' via Programming
<programm...@jsoftware.com> wrote:

Don't fixate on just Henry's syntax or default values.

The basic "delegated function assignment" is:

assign =: 4 : '(x) =: y'

its a verb, that can be composed with others (or rewritten for a

different/enhanced delegated assignment function) in a wide variety of ways
that include all of the discussed applications in this thread.

problem 1:  can only use =: not =.

problem 2:  performance issue in any "delegated function assignment"

that wouldn't (or might not) exist if there were verb (and adverb forms I
proposed) forms of copula.

I've just repeated previous statements entirely here.  Perhaps the

mistake I made was not providing an ideal example to your first request.


From: Raul Miller <rauldmil...@gmail.com>
To: Programming forum <programm...@jsoftware.com>
Sent: Tuesday, July 11, 2017 12:37 PM
Subject: Re: [Jprogramming] Request for comments: multiple assignment



I do not see yet that it would be even possible to do that in a way
that takes advantage of in place assignment optimization. The default
mechanism only kicks in when no value was being assigned, and it seems
to me that cases where you can meaningly have "no value was being
assigned so we need a default" already have complexity which defeats
the in place assignment optimization.

Worse, though, is that this does not seem like a common case (which
suggests that it's best not to optimize for it).

That said, if we're not going to be dealing with code examples (and I
certainly cannot think of any - the requirements seem contradictory),
and we are going to continue discussing this, perhaps we should move
to the chat forum?

That said, here's a hypothetical non-example based on Henry's initial

post:

'L(0)'=: L,y

For that default value (0) to be relevant, the expression (L,y) must
be undefined. But if y were undefined the statement would fail with an
error. And if y were defined and the statement does not fail with an
error, then that default of (0) can never be used.

Which  takes me back to my previous thought which was that taking
advantage of in place optimizations for this default seems impossible.

So... once again... what are you talking about?

Thanks,

--
Raul


On Tue, Jul 11, 2017 at 10:48 AM, 'Pascal Jasmin' via Programming
<programm...@jsoftware.com> wrote:



assignment within a delegated function includes default values,

handling unassigned names, and other applications. Although update can be a
"delegated assigment function" append is more relevant to default values.

Even if there are just a few "general applications" to delegated

assignment, "other applications" count.  I mentioned append rather than
update as a better example of using default values, but update is still a
delegatable assignment function.  Instead of default values, it uses the "C
pattern" u}= 'name' ... another general feature mentioned in this thread.



From: Raul Miller <rauldmil...@gmail.com>
To: Programming forum <programm...@jsoftware.com>
Sent: Tuesday, July 11, 2017 10:17 AM
Subject: Re: [Jprogramming] Request for comments: multiple assignment



In every definition of default assignment that I have seen, update is
not supported, does not make sense, and is not implemented.

So that is what I am asking about: How does it make sense to optimize
for the impossible case?

Thanks,

--
Raul


On Tue, Jul 11, 2017 at 10:07 AM, 'Pascal Jasmin' via Programming
<programm...@jsoftware.com> wrote:

fields can often have default values other than null... relevant more

to append than update.

But this is more of a comment on "assignment within a delegated

function" family of processes, which is what =:: and =.. essentially
propose.

For a differe

Re: [Jprogramming] Request for comments: multiple assignment

2017-07-10 Thread Don Kelly

Thank  you.

I have, since about 1961, dealt with computer languages from MAD 
(Michigan Algorithmic Decoder) through Fortran, early Basic, turbo 
Basic, Pascal, C++ and  APL*Plus then J . The earlier languages were 
compiled and the compilers used "assembly" code.  C and its relatives, 
as far as I could C, led to  a bloating in code  for many things (e.g. 
a  growth in memory requirements for word processing).  The problem with 
most of these is that a great deal of programming was and is  dealing 
with the handling of data and vectors or matrices through explicit 
looping. While I recognize that much of J and APL depends on 
C(+whatever) for coding, the advantages ro the user are that much of 
this is built in so that the user can leave this to the "idiot box" and 
get on to the actual problem of concern. Looping and if then "what next 
" situations are reduced (APL could handle these by a branching to one 
of several choices -i.e. a "goto" and J has added such branching.


My point is that the languages developed by Iverson and those who worked 
with him, were a different approach -where the actual dealing with the 
problem was paramount and most of the necessary background operations   
can be handled automatically by the "idiot box".  Yes, the fact that J 
is interpreted rather than compiled (eventually, in whatever language is 
used ,  into "get this, put it where, get that put it somewhere, bring 
the two together by counting on 2 fingers very quickly and putting the 
result somewhere else").


Often we forget the principal of KISS.

An opinion of an  old fart (Electrical Engineering ,  not Computer Science).

 Don Kelly



On 2017-07-05 2:39 PM, Devon McCormick wrote:

I agree with Don's suggestion.  I've also found things like "++" to be a
little notational wart in the C; it extends to "--", both pre- and post-fix
forms, but is similar to nothing else in the language.  Learning about it
gives you nothing of value that's generally applicable elsewhere.

On Wed, Jul 5, 2017 at 1:44 PM, Don Kelly <d...@shaw.ca> wrote:


Why? Is this accomplishing anything ? Is the value of t changed?

t=:1 2 3

t+3 or 3+t give 4 5 6 but t is not changed

to have a change in t then t=:t+3 works and its meaning is clear.

I would suggest that the value of J (as with APL) is that it is not C and
non-C thinking is a benefit.

Don Kelly




On 2017-07-04 10:55 AM, 'Mike Day' via Programming wrote:


Not multiple assignment,  but copula-related.

I've often wondered why J doesn't have the C family feature of assignments
such as
t =: 1 2 3
   [t+=: 3
4 5 6

I don't know what it's called,  and I realise it's only an arguably
attractive
feature, not an essential one, but would be useful,  especially when
translating
(or plagiarising) to J from C-like code.

John Scholes et al managed to include it in Dyalog APL many years ago;
it's
in his "dfns" (dynamic functions, I think) as well as their more
conventional
APL functions and session operations. If I recall correctly,  John spells
out rules
for passing values to variables of local scope within dfns using such
operators.

Dyalog doesn't have constructs like t++,  though.

Thanks,
Mike

On 04/07/2017 06:40, HenryRich wrote:


Here is a feature that I have wanted for a long time:

http://code.jsoftware.com/wiki/System/Interpreter/Requests#
Expanded_Multiple_Assignment

It attempts to solve the problem of moving verb arguments into
variable-names.  Allows defaults and multilevel arguments.  I will
implement this within a month or so, so get your comments in ASAP.

Henry Rich

---
This email has been checked for viruses by AVG.
http://www.avg.com

--
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






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

Re: [Jprogramming] Request for comments: multiple assignment

2017-07-05 Thread Don Kelly

Why? Is this accomplishing anything ? Is the value of t changed?

t=:1 2 3

t+3 or 3+t give 4 5 6 but t is not changed

to have a change in t then t=:t+3 works and its meaning is clear.

I would suggest that the value of J (as with APL) is that it is not C 
and non-C thinking is a benefit.


Don Kelly



On 2017-07-04 10:55 AM, 'Mike Day' via Programming wrote:

Not multiple assignment,  but copula-related.

I've often wondered why J doesn't have the C family feature of 
assignments

such as
   t =: 1 2 3
  [t+=: 3
4 5 6

I don't know what it's called,  and I realise it's only an arguably 
attractive
feature, not an essential one, but would be useful,  especially when 
translating

(or plagiarising) to J from C-like code.

John Scholes et al managed to include it in Dyalog APL many years 
ago;  it's
in his "dfns" (dynamic functions, I think) as well as their more 
conventional
APL functions and session operations. If I recall correctly,  John 
spells out rules
for passing values to variables of local scope within dfns using such 
operators.


Dyalog doesn't have constructs like t++,  though.

Thanks,
Mike

On 04/07/2017 06:40, HenryRich wrote:

Here is a feature that I have wanted for a long time:

http://code.jsoftware.com/wiki/System/Interpreter/Requests#Expanded_Multiple_Assignment 



It attempts to solve the problem of moving verb arguments into 
variable-names.  Allows defaults and multilevel arguments.  I will 
implement this within a month or so, so get your comments in ASAP.


Henry Rich

---
This email has been checked for viruses by AVG.
http://www.avg.com

--
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] Complex Number Problems

2017-07-01 Thread Don Kelly
It appears that the construct 2r.2   is not described in NuVoc and that 
it is , in fact equivalent to 2%0.2 or 20r2. it is similar to 1p.2 
==1p0.2  or pi to the power of 0.2


you are dealing with nouns in either case and there is a built in 
conversion that allows the use of 2r.2 to be treated as 2 % 0.2 and the 
result is a floating point number (example 2r.3 is 6.7 - the same as 
2r0.3) not a rational number


In the case of j we have 2j0.2  the same as 2j.2 interpreted as above. 
in both cases the term is a noun expressing a complex number  equivalent 
to 2+ j.0.2.


x  r.  y and x j. y behave the same as the r. and j. are verbs acting on 
x and y are nouns
but xr.y and xj.y are nouns. There is an inconsistency in this with 
respect normal appli cation of 0.n rather than .n


0.2 j. 0.2

0.2j0.2


.2j.2


.2j0.20001

At least that is my take on this.

Don Kelly



On 2017-07-01 4:34 AM, Martin Kreuzer wrote:
Looking at (r.) Angle, which is a verb somewhat similar to (j.) 
Complex, I get


   2 r. 0.2
1.96013j0.397339
   2 r.0.2
1.96013j0.397339
   2 r. 2
_0.832294j1.81859
   2 r.2
_0.832294j1.81859

which all four look fine to me, but are not constistent with (j.)'s 
behaviour, that's been my point ...


and then there is this construct

   2r.2
10

which doesn't have anything to do with (r.) Angle but is a 
(fractional) constant of value 2/0.2 showing another instance of .2 
being interpreted as 0.2 which is not accepted in other circumstances.


-M

At 2017-07-01 10:50, you wrote:


this is parsed as a token
   ;:'3e.4'
++
|3e.4|
++
but it (rightfully?) throws an error
   3e.4
|ill-formed number

this is also parsed as a token
   ;:'3j.4'
++
|3j.4|
++

the behavior seems endemic
   3p.4
4.74221
   3ad.4
2.3j0.0209438
   3ar.4
2.76318j1.16826
   3x.4
4.47547
   3b.4
1.3

I think either 3e.4 should be legal or all others should be illegal
for consistent.

Сб, 01 июл 2017, Martin Kreuzer написал(а):
> Looking at the examples, I came across the difference between
>
>3 j. 4  NB. spaces
> 3j4
>
> and
>
>3j.4  NB. no spaces
> 3j0.4
>
> Given that this (rightfully) throws an error
>
>.2 .3 .4 .5
> |syntax error
> |.2 .3 .4 .5
>
>  while this doesn't
>
>0.2 0.3 0.4 0.5
> 0.2 0.3 0.4 0.5
>
> why then is the construct  3j.4 valid..?
>
> -M
>
>
> At 2017-07-01 04:43, you wrote:
>
> > > As Henry points out, the NuVoc page is quite a bit clearer on 
this topic.

> >
> > Sample google search:
> >site:jsoftware.com inurl:nuvoc complex
> >
> > Quite a bit of reading there, if you have the patience for it (be 
sure
> > to mix in plenty of trial and error, though, or it's a total 
snoozer).

> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> > On Fri, Jun 30, 2017 at 11:30 PM, Rob Hodgkinson 
<rhodg...@me.com> wrote:
> > > Hi Lawrence, the “ill-formed number” is because "j." 
is a verb,
> > quite different to “j” which is part of a noun 
construct (like 3j4,

> > or 1e3 for 1000).
> >
> > > So in your examples ...
> >
> > > NB. But wait, not so fast:
> > >   1j.(2^0.5)%2
> > > |ill-formed number
> > > NB. No
> >
> > > NB. Now try to separate the “j.” verb with a space 
either side to
> > make it clear to J that this is not “1jxxx” where J 
would assume you

> > are trying to make a complex constant.
> > >1 j. (2^0.5)%2
> > > 1j0.707107
> >
> > > The reason is that J can also directly interpret ‘complex
> > constants’ entered directly using the j notation (as a 
continuous

> > sequence of non-blank chars)…
> > >3j4NB. This is a single complex constant 3+i4
> > > 3j4
> >
> > >3 j4NB. But now J tries to view this as a list of (3) 
and (j4)

> > which which J would assume is (3) and a variable called (j4).
> > > |syntax error
> > > | 3 j4
> >
> > > As Henry points out, the NuVoc page is quite a bit clearer on 
this topic.

> >
> > > HTH, Regards Rob
> >
> >
> > >> On 1 Jul 2017, at 1:14 pm, Lawrence Wickert 
<skippy_...@hotmail.com>

> > wrote:
> > >>
> > >> Hello,  I am a old EE still trying to learn. I am a real beginner
> > having no end of problems with specifying complex numbers.  I am 
using
> > j64-804 on ubuntu 12.04.  I am either doing something really 
stupid or I
> > need to update to 806.  Updating anything gives me heartburn or 
worse so
> > I hope it is just my misunderstanding of basic principles. 
Although I
> > have a bad habit of R

Re: [Jprogramming] Complex residue

2017-06-23 Thread Don Kelly
the floor and related residue operations in the dictionary are related 
to the paper. The dictionary residue is as in the dictionary but the 
floor definition  for complex numbers is apparently as in this paper. 
However the question as to whether floor, ceiling and residue of complex 
numbers are of any use-fairly esoteric and not related to the pole 
oriented mathematical complex integrals.


http://www.jsoftware.com/papers/eem/complexfloor.htm 
<cid:part1.7E9EFC8E.956DF47D@shaw.ca>


Don Kelly


On 2017-06-23 7:06 AM, Louis de Forcrand wrote:

Thanks for the quick answers (and quick bug-fixing for that matter).

Louis


On 23 Jun 2017, at 14:25, Henry Rich <henryhr...@gmail.com> wrote:

After reflection it seems clear that this is a bug in the implementation, so I 
have fixed it for the next release, to match the Dictionary.

Henry Rich


On 6/22/2017 9:32 PM, Henry Rich wrote:
I admit that the definition as it is implemented is less pretty than the one in 
Ye Dic.  It would be easy to change the code to match the Dictionary definition 
- I just don't know if that would break existing code.  Is that something we 
could thrash out here?

Does anyone use complex residue?  Would they care if we changed the code to 
match the Dictionary definition?

Henry Rich


On 6/22/2017 6:49 PM, Raul Miller wrote:
Yeah... over time, I've probably argued at least three sides of this issue...



---
This email has been checked for viruses by AVG.
http://www.avg.com

--
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


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

Re: [Jprogramming] Complex residue

2017-06-22 Thread Don Kelly

This is from NuVoc  (for 806)

1. For finite x, x | y is extended to negative numbers by the definition 
x|y ==> y-x*<. y % x+0=x and to complex 
<http://code.jsoftware.com/wiki/Vocabulary/Glossary#Complex> numbers by 
the definition x|y ==> y-x* <.@(0.5&+)&.+. y % x+0=x .


which agrees with your algebra.

The Vocabulary uses

y-x*<. y % x+0=x extends the residue to a zero left argument, and to 
negative and fractional finite arguments.


but says that the dyad | extends to complex numbers

In either case  the result appears to be different from the Complex Residue

In mathematics, more specifically *complex* analysis, the *residue* is a 
*complex number* proportional to the contour integral of a meromorphic 
function along a path enclosing one of its singularities. Don Kelly



 Residue (complex analysis) - Wikipedia
 
<https://www.google.ca/url?sa=t=j==s=web=2=rja=8=0ahUKEwjwqYKwxNLUAhUJ8WMKHVhgCQsQFggoMAE=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FResidue_%28complex_analysis%29=AFQjCNGJ2qCb-juMCMekL7Vd4znD0H9xnA>

https://en.wikipedia.org/wiki/Residue_(complex_analysis)

*SO why do we **attempt to use rhe "common residue" for a complex 
number- does it have meaning?

*
Don Kelly



On 2017-06-22 2:53 PM, Henry Rich wrote:

What it actually is (when x and y are not infinite and x is not 0) is

d =. |x
ab =. (+x) * y
q =. <.@(0.5&+)&.+. ab%d
y - x * q

If my algebra is right, this is equivalent to

(x|y)=y-x* <.@(0.5&+)&.+.y%x+0=x

In other words, the Dictionary description incorrectly says that the 
complex quotient will be rounded using complex floor, while in reality 
each component of the quotient is (tolerantly) rounded independently.


Henry Rich






On 6/22/2017 4:53 PM, Louis de Forcrand wrote:

Hi,

There's been recent discussion on the GNU APL forums about how to 
define the residue function on complex arguments. I wondered how it 
was specified in J, but the dictionnary page seems kind of vague.


Nuvoc says that
(x|y)=y-x*<.y%x+0=x
for all scalars x and y (including complex numbers).
However, this is untrue for
'x y'=: 1j1 3j4
(tested on the old J for iOS)

While it would seem like a logical extension, the dictionnary only 
says that this is true for rational numbers.


So how is the residue of two complex numbers defined in J?

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



---
This email has been checked for viruses by AVG.
http://www.avg.com

--
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] Empty lists?

2017-06-08 Thread Don Kelly
Could it be that you are copying multiline code into J rather than 
direct entry?  You can enter an explicit verb directly but writing it 
into a script is a better way to go as, if it fails, you can correct the 
script and reload it- otherwise you will likely have to erase and 
rewrite the whole function. Experimentation with a 1 line code is easy 
because you can edit it and "enter"  but I haven't found a way to 
correct a single line from a multiline verb and get it to work -probably 
because that line is interpreted as stand alone. Flip etc are fine but 
search may be a problem -so if flip etc are ok move them to a script 
-they are done and can be kept. Think of it as an editor as well as  a 
text file  (such a file can be pasted into a script file and run but  
pasting directly into the J window won't work- tried that!)


Don Kelly


On 2017-06-08 7:50 AM, Michael Rice wrote:

Thanks for the tip, Henry, but I'm still sitting at the children's table.
I'd rather input the functions separately until I graduate to the adult's
table.

Could you please remove the extraneous characters required, or inserted, by
the script reader and just send me the text of the five functions? I'd
certainly appreciate it

Best,.

Michael

On Thu, Jun 8, 2017 at 10:28 AM, Henry Rich <henryhr...@gmail.com> wrote:


Have you created an .ijs script (with File|New temp), put the lines into
the script, and then pressed ctrl+L in the script window to load the
script?  That works fine for me.

Henry Rich




On 6/8/2017 10:07 AM, Michael Rice wrote:


@ Raul Miller

Back in Win 10 jqt now. Here's what I get for inputting the first four
functions:

 move_table=:
<:(,|."1)(#~0<*/"1)~.,/,/_3&{.\@/:~"1(,|:"2)>|:((;|.)@(1++)+/)\i.5

 flip=: ~: (i.15)

 legal_moves=: [ #~ 6 = 2 #. {

 search=:3 :0
((15#1) flip y) search i.0 3
NB. x: board; y: moves
:
if. 1=+/x do. y return. end.
for_move. move_table legal_moves x do.
  r=.(x flip move) search move,y
  if. #r do. r return. end.
end.
i.0 3
)
|syntax error
|   )

Michael

On Thu, Jun 8, 2017 at 8:55 AM, Raul Miller <rauldmil...@gmail.com>
wrote:

I cannot reproduce that spelling error you are getting.

This suggests to me that either (a) your implementation of J (or some
part of the infrastructure it relies on) is damaged, or (b) there's an
illegal character hidden somewhere in your copy of that line.

That said, note that while I did try using jqt's Run > Clipboard menu
option when trying to reproduce your problem, I normally run this as a
script (File > New temp; paste code into the green window; File > Save
in the green window; Run > Load Script also in that green window, then
go back to the yellow window to try it out).

Meanwhile:

 solitaire 0 10 14
No solution
 timespacex 'solitaire 0 10 14'
6.53433 41600

Thanks,

--
Raul


On Thu, Jun 8, 2017 at 8:37 AM, Michael Rice <limitc...@gmail.com>
wrote:


I've tried inputting your code in jqt several times, each time with a
new
jqt terminal and keep encountering errors. Here's the last try:

 move_table=:
<:(,|."1)(#~0<*/"1)~.,/,/_3&{.\@/:~"1(,|:"2)>|:((;|.)@(1++)+/)\i.5

 flip=: ~: (i.15)

 legal_moves=: [ #~ 6 = 2 #. {

 search=:3 :0
((15#1) flip y) search i.0 3
NB. x: board; y: moves
:
if. 1=+/x do. y return. end.
for_move. move_table legal_moves x do.
  r=.(x flip move) search move,y
  if. #r do. r return. end.
end.
i.0 3

 solitaire=:3 :0
path=. search y
if. #path do. path else. 'No solution' end.
|spelling error
|   if. #path do. path else. 'No solution' end.
|   ^

B/t/w, does it work for:

solitaire 0 10 14?

I remember you had some question about that.

Michael

On Thu, Jun 8, 2017 at 6:44 AM, Raul Miller <rauldmil...@gmail.com>


wrote:


I've already posted code for changing a board and extracting legal

moves

from it that satisfactorily produced a path to a win. If you like,

you're

free to take a swing at finishing it any way you think will work.

I thought I had posted a finished implementation?

http://www.jsoftware.com/pipermail/programming/2017-June/047522.html

 solitaire 5
14 9 5
   2 5 9
   3 4 5
10 6 3
   1 3 6
12 7 3
13 8 4
   9 5 2
   2 4 7
11 7 4
   6 3 1
   0 1 3
   3 4 5

If you feel there's something wrong with this approach, let me know
and I'll see if I can wrap my head around those issues.

Thanks,

--
Raul


On Wed, Jun 7, 2017 at 11:21 PM, Michael Rice <limitc...@gmail.com>


wrote:
@ Raul Miller

"I guess I disagree with the model you posted here, about how to
implement the peg game"

I've already posted code for changing a board and extracting legal


moves

from it that satisfactorily produced a path to a win. If you like,

you're

free to take a swing at finishing it any way you think will work.

Here's

my

Clojure code (see below) for the two remaining 

Re: [Jprogramming] Explicit fib

2017-03-02 Thread Don Kelly
I wondered about using ^: but didn't get it to work  -I wasn't iterating 
a verb string alone.


Good on you

Don


On 3/2/17 11:53 AM, Raul Miller wrote:

These are equivalent:

(,+/ @(_2&{.))^:4(1)
1 1 2 3 5
(,+/ @(_2&{.))(,+/ @(_2&{.))(,+/ @(_2&{.))(,+/ @(_2&{.))(1)
1 1 2 3 5

In other words, (F)^:4 does F four times.

Does this help?

Thanks,



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

Re: [Jprogramming] Explicit fib

2017-03-01 Thread Don Kelly

 maybe a variant like this- a combination of ideas presented

fibb=:verb define

series=:0 1

while. (y>: # series) do.

series=: series, +/_2{. series

end.

)


Don Kelly


On 2/26/17 11:37 AM, Raul Miller wrote:

Then perhaps something like this:

fib=:verb define
   series=. 0 1
   needed=. >./, y
   while. needed >: #series do.
 series=. series, +/_1 _2 { series
   end.
   y { series return.
)

Thanks,



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

Re: [Jprogramming] Running jqt without Project?

2016-10-02 Thread Don Kelly
Thanks, This might  make it easier to open a given script. However, what 
I suggest does put all scripts in a directory dedicated to scripts, 
rather than being scattered about. Also, I am not sufficiently 
proficient to fully understand your myrun verb commands. I may get there 
sometime.


Don Kelly

On 10/2/2016 3:40 AM, bill lam wrote:

You can define a verb in startup.ijs to choose and run scripts

myrun_z_=: 3 : 0
empty (libjqt, ' immexj + n *c') <'0!:100<', quote wd'mb open1 run . "*.ijs"'
)

Also the verb can be binded to a function key in the ide,
see menu Edit>configure>user keys

Сб, 01 окт 2016, dhkelly написал(а):

In Windows copy  the desired files and folders   to the J " user" directory
I did this with some of mine which were on a backup and simply copied them
over -this acts as an ordinary windows directory.
File>open>user and get a normal window folder pane and paste the folders/
files or make new folders as desired.

I have found that when   from 803 to 804, for example, this has to be done
with the  scripts from 803 as 804 installed independently from 803 .

Don Kelly


On 9/29/2016 7:23 PM, Donald Pittenger wrote:

Bill,

I haven’t programmed in J for 5 or 6 years, so I’m probably doing something 
wrong.

But I tried ‘load’ and keep getting error messages because the system cannot 
seem to follow the desired filepath.

Working via ‘File’ items resulted in error messages.

J6 allowed one to step through directory levels until one found the target 
script for loading.  All jqt seems to offer (that works) is what’s under ‘RUN’ 
on the toolbar.

As mentioned, I’m probably doing something wrong, but my feeble excuse is that 
jqt is new to me.

On Sep 29, 2016, at 5:43 PM, bill lam <bbill@gmail.com> wrote:


I cannot understand your question.  A script can be loaded and executed
using the verb load.

Or open/edit the script into edit window, and then choose run script from
menu bar there.

On Sep 30, 2016 8:04 AM, "Donald Pittenger" <dbpitten...@earthlink.net>
wrote:


I finally got around to revamping a j6 system on j804 using jgt.

But I find the Projects feature slightly annoying and would like to be
able to simply have j8 behave similarly to j6 where I could fetch and run
stuff from places other than Projects.

I’ve pretty much OD’d on J documentation for the time being, so could use
a brief answer: perhaps someone could either tell me that Projects are the
only option or else how to do things in the J6 manner in jqt.

FYI, I program using OSX.

Thanks,

Donald Pittenger
--
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

--
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] 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] A plane rotation

2016-02-22 Thread Don Kelly

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

1r2p1 rotheta 3 4

_4 3



1r4p1 rotheta 2 2$ 3 4 _1 1

_0.707107 4.94975

_1.41421 0


2 1$ 1r2p1 1r4p1 rotheta 2 2$ 3 4 _1 1

_4 3


_1.41421 0



It would be simpler to enter positions as complex numbers in the first 
place.


(r.1r2p1) * 3j4

_4j3


Don Kelly




On 2/16/2016 8: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 <b49p23t...@gmail.com> 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<thekipmur...@gmail.com>
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 added.

--Kip Murray



--
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] Non-scalar Newton-Raphson

2016-02-13 Thread Don Kelly


You are right on target - you need a matrix of derivatives  which is 
called a Jacobian matrix


http://mathworld.wolfram.com/Jacobian.html

In the case of an example:  that  of a power system flow of real and 
reactive power as related to voltage phase and magnitude The Newton 
Raphson approach involves the Jacobian matrix.
This approach has been used since the late 1950's  for systems with up 
to000 to 1 variables (something that one numerical analysis text 
dismissed, erroneously,  as not being  a realistic problem ) and 
provides fast convergence (partially due to the sin/cos differential cycle.
I am not a mathematician but an engineer using this as a tool. I have 
written this in Turbo Basic as well as in APL (STSC version11-no  
complex number capability). The APL version took about 11 lines of 
actual solution with added lines of checking limits and dressing up 
output. The other version involves about 3 pages of code.  I have 
partially developed a J version but overall I may not have the skill to 
make it more compact than the APL coding.


https://en.wikipedia.org/wiki/Power-flow_study

Don Kelly


On 2/13/2016 8:00 AM, Roger Hui wrote:

If the atoms of the function are independent, then it's easiest to do f"0
Newton (or f Newton"0) and be done with it.  If they are not independent,
that is f is what's called a vector function in conventional mathematical
notation, then you need to use %. (matrix divide) instead of % (plain old
divide), among other things.

My knowledge of vector calculus is minimal.  Perhaps the mathematicians in
this Forum can help you if you really do have a vector function.




On Sat, Feb 13, 2016 at 7:50 AM, Louis de Forcrand <ol...@bluewin.ch> wrote:


I’ve been trying to write a conjunction that will find the zeros to a
function using the
Newton-Raphson method. The simplest way to do this is probably:

English:
x_n+1 = x_n - f ( x_n ) / f ‘ ( x_n )

J:
eznewt=: 2 : ‘ ( - u % u D.1 ) ^: n ‘

This works fine for scalar -> scalar functions, but won’t work if the rank
of the
result is AND the rank of the arguments are above 1.
Probably the most evident situation where this would be a problem is if one
were searching for a minimum instead of a zero, in which case the algorithm
would be applied to the derivative of the function: +/@:*: D.1 newt 30 ] 3
4
As I understand it, this would give a result shape at each iteration (with
a function u) of:

( $y ) , $ u eznewt 1 y

where A is the original argument, or the result of the previous iteration.
What we would
want is a result with shape $y .

First, let’s get some rules clear:
- the syntax should be: (verb) newt (# of iterations) (argument)
- the argument can be of any rank
- the shape of the argument matches the shape of the result at any
iteration
- this implies that $ u y matches i. 0 or $ y

The hard part is getting u % u D.1 to have the shape of the argument.
If y is a vector, and u y is a scalar, then u D.1 y will be a vector, and
u D.1 D.1 y will be a $y by $y matrix. All that is needed then is to take
its diagonal with (<0 1)&|: .

But what if y is a matrix? Since $ u D.1 y -: ( $ y ) , $ u y , I though
maybe running
y's axis together with |: might work

newt=: 2 : '(- u diag_and_divide u D.1)^:n’
diag_and_divide=: [ % ] |:~ -@#@$@[ <@}. i.@#@$@]

  but something about it doesn’t.
My head is $pinning now, and I figured I’d send this and then take a break.

Thanks in advance!
Louis
--
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] advent of code - day 2

2015-12-12 Thread Don Kelly
Thanks- this was something that I had just come across the night before  
and by the morning after- I had messed it up.


Don

On 12/11/2015 12:12 PM, R.E. Boss wrote:

(<0 1)|: y

Nuvoc is correct: 
http://www.jsoftware.com/jwiki/Vocabulary/Idioms#Extract_The_Diagonal_Of_A_Table
 and http://www.jsoftware.com/jwiki/Vocabulary/barco#More_Information


R.E. Boss



-Original Message-
From: programming-boun...@forums.jsoftware.com [mailto:programming-
boun...@forums.jsoftware.com] On Behalf Of Don Kelly
Sent: vrijdag 11 december 2015 0:59
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] advent of code - day 2

NuVoc
(>0 1 )|: y

Don

On 12/10/2015 12:13 AM, Linda A Alvord wrote:

I'm just getting started on these and here is an elementary school solution.

(I couldn't remember a shortcut to get a diagonal from a square matrix.

f=: 13 :'(*/0 1{(/:y){y)+2*+/+/(=/~i.$y)*1|."1*/~(/:y){y'

Linda

-Original Message-
From: programming-boun...@forums.jsoftware.com

[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Jan-
Pieter Jacobs

Sent: Thursday, December 3, 2015 3:41 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] advent of code - day 2

My solutions to the Day2 problems:


Probably there's better solutions around, but well...


NB. the surface of a box is the product of 2 elements of each permutation

of sides

NB. Needed paper surface

s1a =: [: +/ (+/ + s1slack)@s1facesurf@s1parse NB. paper needed = sum of

surfaces + slack

 s1parse =: [: |: ([: ". ;. _1 'x', ]) ;. _2 NB. parse box sizes

 s1facesurf =: */@(}:"2)@((i.@!@#) A. ]) NB. face surfaces

 s1slack =: <./ NB. Slack space = smallest face


NB. Ribbon length

s1b =: [: +/ (s1vol + s1faceperm)@s1parse NB. ribon = volume + smallest

perimeter

 s1vol =: */ NB. Volume

 s1faceperm=: ([: <./ +:@(+/)@(}:"2))@((i.@!@#) A. ]) NB. smallest

perimeter.


NB. input as text.


Best regards,


Jan-Pieter

2015-12-03 17:35 GMT+01:00 Thomas Costigliola <tcost...@gmail.com>:


Here's my solution to part 1.

I=. /:~@:(do;._1)@:('x'&,);._2 ] 0 : 0

3x11x24

13x5x19

1x9x27

24x8x21

6x8x17

...

)


M=. 7 3 $ 1 1 0 1 0 1 0 1 1

I +/@(+/@:(*/) . ^) |:M

1588178




On Thu, Dec 3, 2015 at 6:47 AM, Ryan Eckbo <ec...@cim.mcgill.ca>

wrote:

And mine:

# part 1
Presents=. do each ('x');._2 freads'/tmp/input.txt'
sa=: 3 : '(l*w) + (2*l*w) + (2*w*h) + 2*h*l [ ''l w h''=. /:~y'
+/ sa"1 Presents

# part 2
ribbon=. +/@:+:@:}:@:(/:~)@:>
vol=. */@:>
+/ (vol + ribbon)"1 Presents

Ryan


On 3 Dec 2015, at 13:54, Ric Sherlock wrote:


Here's mine:

require 'tables/csv stats'
parcels=: _99 ". > 'x' readdsv jpath '~temp/aoc_day2_inp.txt'

NB. Part 1
+/ (<./ + [: +/ +:)"1 */"1 (0 1 , 1 2 ,: 0 2) {"_ 1 parcels

   NB. or...
getFaceSides=: (2 comb 3) {"_ 1 ]
calcFaceArea=:  */"1@:getFaceSides
calcPaper=: (<./ + +/@:+:)"1
calcTotalPaper=: +/@:calcPaper@calcFaceArea

calcTotalPaper parcels

NB. Part 2
​+/ (*/"1 + ([: <./"1 [: (+/@:+:)"1 (2 comb 3)&{"_ 1))  parcels

   NB. or ...
volume=: */"1
perimeters=: (+/@:+:)"1@getFaceSides
calcRibbonLength=: (volume + <./"1@:perimeters)
calcTotalRibbonLength=: +/@calcRibbonLength echo
calcTotalRibbonLength parcels


On Thu, Dec 3, 2015 at 3:36 PM, 'Pascal Jasmin' via Programming <
programm...@jsoftware.com> wrote:


outfix is quite forgettable, but this is much more elegant than
what I did.


   1 */\.  2 3 4
12 8 6



- Original Message -
From: Joe Bogner <joebog...@gmail.com>
To: programm...@jsoftware.com
Sent: Wednesday, December 2, 2015 8:54 PM
Subject: Re: [Jprogramming] advent of code - day 2

Pascal's #2 is the answer to part 2 of the question. Both of his
answers match mine and yours matches my part one.

Pascal - looks similar to mine, albeit compressed in a single
line, which is close to the original problem description

Henry - I haven't figured the logic of yours out yet at a quick
glance, I will need to look closer

Thank you both for sharing


On Wed, Dec 2, 2015 at 8:40 PM, Henry Rich <henryhr...@gmail.com>

wrote:

The 2 versions give different results.

Mine:

i =. ".;._1@('x'&,);._2 wd 'clippaste'

+/ (/:~@(1&(*/\.))"1 i) +/ . * 3 2 2


Henry Rich




On 12/2/2015 8:19 PM, 'Pascal Jasmin' via Programming wrote:

was wondering what took 7 lines, but its style

1: with input parsing

+/ +/ (<./, 2&*)"1 */every@:(0 2&{ ; 1 2&{ ; 0 1&{)"1 ". >
+cutLF

'x'

rplc~ wdclippaste ''

2:

+/ +/@(*/ , +:@(2 {. /:~))("1) ". > cutLF 'x ' rplc~ wdclippaste ''



- Original Message -
From: Joe Bogner <joebog...@gmail.com>
To: programm...@jsoftware.com
Sent: Wednesday, December 2, 2015 7:37 PM
Subject: [Jprogramming] advent of code - day 2

building upon:


http://jsoftware.com/pipermail/progra

Re: [Jprogramming] advent of code - day 2

2015-12-10 Thread Don Kelly

NuVoc
(>0 1 )|: y

Don

On 12/10/2015 12:13 AM, Linda A Alvord wrote:

I'm just getting started on these and here is an elementary school solution.

(I couldn't remember a shortcut to get a diagonal from a square matrix.

f=: 13 :'(*/0 1{(/:y){y)+2*+/+/(=/~i.$y)*1|."1*/~(/:y){y'

Linda

-Original Message-
From: programming-boun...@forums.jsoftware.com 
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Jan-Pieter Jacobs
Sent: Thursday, December 3, 2015 3:41 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] advent of code - day 2

My solutions to the Day2 problems:


Probably there's better solutions around, but well...


NB. the surface of a box is the product of 2 elements of each permutation of 
sides

NB. Needed paper surface

s1a =: [: +/ (+/ + s1slack)@s1facesurf@s1parse NB. paper needed = sum of 
surfaces + slack

s1parse =: [: |: ([: ". ;. _1 'x', ]) ;. _2 NB. parse box sizes

s1facesurf =: */@(}:"2)@((i.@!@#) A. ]) NB. face surfaces

s1slack =: <./ NB. Slack space = smallest face


NB. Ribbon length

s1b =: [: +/ (s1vol + s1faceperm)@s1parse NB. ribon = volume + smallest 
perimeter

s1vol =: */ NB. Volume

s1faceperm=: ([: <./ +:@(+/)@(}:"2))@((i.@!@#) A. ]) NB. smallest perimeter.


NB. input as text.


Best regards,


Jan-Pieter

2015-12-03 17:35 GMT+01:00 Thomas Costigliola :


Here's my solution to part 1.

I=. /:~@:(do;._1)@:('x'&,);._2 ] 0 : 0

3x11x24

13x5x19

1x9x27

24x8x21

6x8x17

...

)


M=. 7 3 $ 1 1 0 1 0 1 0 1 1

I +/@(+/@:(*/) . ^) |:M

1588178




On Thu, Dec 3, 2015 at 6:47 AM, Ryan Eckbo  wrote:


And mine:

# part 1
Presents=. do each ('x');._2 freads'/tmp/input.txt'
sa=: 3 : '(l*w) + (2*l*w) + (2*w*h) + 2*h*l [ ''l w h''=. /:~y'
+/ sa"1 Presents

# part 2
ribbon=. +/@:+:@:}:@:(/:~)@:>
vol=. */@:>
+/ (vol + ribbon)"1 Presents

Ryan


On 3 Dec 2015, at 13:54, Ric Sherlock wrote:


Here's mine:

require 'tables/csv stats'
parcels=: _99 ". > 'x' readdsv jpath '~temp/aoc_day2_inp.txt'

NB. Part 1
+/ (<./ + [: +/ +:)"1 */"1 (0 1 , 1 2 ,: 0 2) {"_ 1 parcels

  NB. or...
getFaceSides=: (2 comb 3) {"_ 1 ]
calcFaceArea=:  */"1@:getFaceSides
calcPaper=: (<./ + +/@:+:)"1
calcTotalPaper=: +/@:calcPaper@calcFaceArea

calcTotalPaper parcels

NB. Part 2
​+/ (*/"1 + ([: <./"1 [: (+/@:+:)"1 (2 comb 3)&{"_ 1))  parcels

  NB. or ...
volume=: */"1
perimeters=: (+/@:+:)"1@getFaceSides
calcRibbonLength=: (volume + <./"1@:perimeters)
calcTotalRibbonLength=: +/@calcRibbonLength echo
calcTotalRibbonLength parcels ​


On Thu, Dec 3, 2015 at 3:36 PM, 'Pascal Jasmin' via Programming <
programm...@jsoftware.com> wrote:


outfix is quite forgettable, but this is much more elegant than
what I did.


  1 */\.  2 3 4
12 8 6



- Original Message -
From: Joe Bogner 
To: programm...@jsoftware.com
Sent: Wednesday, December 2, 2015 8:54 PM
Subject: Re: [Jprogramming] advent of code - day 2

Pascal's #2 is the answer to part 2 of the question. Both of his
answers match mine and yours matches my part one.

Pascal - looks similar to mine, albeit compressed in a single
line, which is close to the original problem description

Henry - I haven't figured the logic of yours out yet at a quick
glance, I will need to look closer

Thank you both for sharing


On Wed, Dec 2, 2015 at 8:40 PM, Henry Rich 

wrote:

The 2 versions give different results.

Mine:

i =. ".;._1@('x'&,);._2 wd 'clippaste'

+/ (/:~@(1&(*/\.))"1 i) +/ . * 3 2 2


Henry Rich




On 12/2/2015 8:19 PM, 'Pascal Jasmin' via Programming wrote:

was wondering what took 7 lines, but its style

1: with input parsing

+/ +/ (<./, 2&*)"1 */every@:(0 2&{ ; 1 2&{ ; 0 1&{)"1 ". >
+cutLF

'x'

rplc~ wdclippaste ''

2:

+/ +/@(*/ , +:@(2 {. /:~))("1) ". > cutLF 'x ' rplc~ wdclippaste ''



- Original Message -
From: Joe Bogner 
To: programm...@jsoftware.com
Sent: Wednesday, December 2, 2015 7:37 PM
Subject: [Jprogramming] advent of code - day 2

building upon:


http://jsoftware.com/pipermail/programming/2015-December/043407.html,

but starting a new thread since the other one started to go in
a different direction.

http://adventofcode.com/day/2

Here's my solution:
https://github.com/joebo/lang-lab/blob/master/j/advent2015/day2
.ijs


--

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

-
- For information about J forums see

http://www.jsoftware.com/forums.htm

-
- For information 

Re: [Jprogramming] My first J conjuction

2015-12-08 Thread Don Kelly
pyth=: 13 : '| x+j.y'  also works but does call on complex 
numbers-not generally grade 4.


pyth

[: | [ + [: j. ]


5 pyth 4

6.40312


You must have a great grade 4 class.

Don

On 12/7/2015 10:35 PM, Linda A Alvord wrote:

Yes and Me Too

-Original Message-
From: programming-boun...@forums.jsoftware.com 
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Don Kelly
Sent: Tuesday, December 8, 2015 12:58 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] My first J conjuction

p for Pythagorus theorem?

Don
(apologies for the tree format -I tried to get it to look good but blew it.)

   



On 12/6/2015 2:36 AM, Linda A Alvord wrote:


Neat! Guess what p stands for?

   


 ffp=: 13 : '%:+/*:x,y'

 5!:4 <'ffp'

┌─ [:
├─ %:
──┤┌─ [:
│├─ / ─── +
└┤
 │ ┌─ [:
 └─┼─ *:
   └─ ,

 


Linda

   

   

   

 


-Original Message-
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Don
Kelly
Sent: Saturday, December 5, 2015 7:23 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] My first J conjuction

   


how about

ff=: 13 : ' +/*:x,y'

   


4 ff 5

   


41

   


ff

   


[: +/ [: *: ,   2 capped forks

   

   


5!:4< 'ff'

   


*┌─ [: *

   


**

   


*├─ / ─── + *

   


**

   


*──┤ *

   


**

   


*│┌─ [:*

   


**

   


*└─┼─ *:*

   


**

   


*└─ , *

   

   


Don

   


On 12/4/2015 7:38 AM, Linda A Alvord wrote:


g looks more like forks than f:

  f=: 13 :'x(*:@[ + *:@])y'

  g=: 13 :'(*:x)+*:y'
  (4 f 5)-:4 g 5
1
  5!:4 <'f'
   -- *:
 -- @ -+- [
 +- +
--+ -- *:
 L- @ -+- ]
  5!:4 <'g'
 -- [:
 +- *:
 │   L- [
--+- +
 │   -- [:
 L---+- *:
 L- ]
  

Linda


-Original Message-

From:  <mailto:programming-boun...@forums.jsoftware.com>
programming-boun...@forums.jsoftware.com
[ <mailto:programming-boun...@forums.jsoftware.com>
mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Kip
Murray
Sent: Friday, December 4, 2015 1:20 AM
To:  <mailto:programm...@jsoftware.com> programm...@jsoftware.com
Subject: Re: [Jprogramming] My first J conjuction

And you can use a fork in the definition of a conjunction:

   of =: 2 : 'v@[ u v@]'

   4 + of *: 5
41

On Thursday, December 3, 2015, Kip Murray < <

<mailto:thekipmur...@gmail.com> mailto:thekipmur...@gmail.com>  
<mailto:thekipmur...@gmail.com> thekipmur...@gmail.com> wrote:


A fork is not a conjunction but it shows what you are doing:
   4 (*:@[ + *:@]) 5
41
On Thursday, December 3, 2015, Lippu Esa <esa.li...@varma.fi
<javascript:_e(%7B%7D,'cvml','esa.li...@varma.fi');>> wrote:

It is 5:17 AM in Finland and I already have two good answers. Thank
you David and Pascal!
It seems that I haven't been using Compose either :) . But at least
I knew that this is the place to be.
Thanks again,
Esa
-Original Message-
From:  < <mailto:programming-boun...@forums.jsoftware.com>
mailto:programming-boun...@forums.jsoftware.com>

   <mailto:programming-boun...@forums.jsoftware.com> 
programming-boun...@forums.jsoftware.com [mailto:

< <mailto:programming-boun...@forums.jsoftware.com>
mailto:programming-boun...@forums.jsoftware.com>

   <mailto:programming-boun...@forums.jsoftware.com>
programming-boun...@forums.jsoftware.com] On Behalf Of David Lambert

Sent: perjantaina 4. joulukuuta 2015 5.14
To: programming < < <mailto:programm...@jsoftware.com>
mailto:programm...@jsoftware.com>

   <mailto:programm...@jsoftware.com> programm...@jsoftware.com>

Subject: Re: [Jprogramming] My first J conjuction I expect you'll
get many of the same response.  Your conjunction is fine, however
this particular case is so frequent there's a built in conjunction.
Read "but first",
x f y
or
x f&:g y
the difference being rank.  Add but first square:
  4 +&: *: 5
41
On 12/03/2015 10:05 PM,

< <mailto:programming-requ...@forums.jsoftware.com> 
mailto:programming-requ...@forums.jsoftware.com>
   <mailto:programming-requ...@forums.jsoftware.com> 
programming-requ...@forums.jsoftware.com wrote:

Date: Fri, 4 Dec 2015 03:05:50 +
From: Lippu Esa< < <mailto:esa.li...@varma.fi> mailto:esa.li...@varma.fi>  
<mailto:esa.li...@varma.fi> esa.li...@varma.fi> To:"

< <mailto:programm...@jsoftware.com> mailto:programm...@jsoftware.com>  
<mailto:programm...@jsoftware.com> programm...@jsoftware.com"

< < <mailto:programm...@jsoftware.com>
mailto:programm...@jsoftware.com>
<mailto:programm...@jsoftware.com> programm...@jsoftware.com>
Subject: [Jprogramming] My first 

  1   2   3   >