The connection between the code by Arie Groeneveld and Louis de Forcrand
can be shown as follows,

   NB. Arie Groeneveld...

   S=: 1 :0
:
if. 0= y do. 0
  else. 'q r'=. (0,m) #: y
        ( r *(1+m) ^ (0 (m S) x)) + (1+x) m S q
end.
)

   G=:   (>:@[ $: _1+ 4 : '0 (x S)y')`[@.(0=])


   NB. Louis de Forcrand...


   hbi=: ([ (] +/ . * >:@[ ^ ($: i.@-@#)) #.^:_1)^:(*@])"0
   gs=:  , >:@# <:@hbi {:


   NB. Connection...

   G0=.  <:@:(2x&G"0)
   G1=.  (#@:(gs^:(0~:{:)^:_))"0@:x:

   (G0 -: G1) 1 2 3
1

   G1 1 2 3
2 4 6

This is the Goodstein function as per Wikipedia:

https://en.wikipedia.org/wiki/Goodstein%27s_theorem#Sequence_length_as_a_function_of_the_starting_value

Reportedly, it is a total function but unprovable in Peano arithmetic.  Of
course, neither G0 nor G1 can produce the result corresponding to the
argument 4.


> This bug (is it a bug?) is in j805

I do not know for sure if the crash is a bug; yet, certainly, it is a
change in behavior.  It seems that the issue can be shown also using gs,

   gs^:(0~:{:)(^:_) 2
|domain error: hbi
|       gs^:(0~:{:)(^:_)2
|[-0]

   gs^:(0~:{:)(^:4) 2
2 2 1 4.44089e_16 _1

Interestingly,

   gs^:(0~:{:)(^:_) 3
3 3 3 2 1 0

and likewise,

   2 G 3
7

yet 2 G 2 produces a crash (running on J805 and above).

Furthermore, I put some extra code in S to display y in the comparison 0=
y.  For 2 G 3 the display is identical, running on J804 and J806, and shows
only integers.  However, for 2 G 2, running on J804 shows, again, only
integers but on J806, in contrast,

   2 G 2
   2.000000000000000000000000000000000000000

   1.000000000000000000000000000000000000000

   0.000000000000000000000000000000000000000

   1.000000000000000000000000000000000000000

   0.000000000000000000000000000000000000000

   0.000000000000000000000000000000000000000

   0.000000000000000000000000000000000000000

   2.000000000000000400000000000000000000000

   0.000000000000000000000000000000000000000

   0.000000000000000000000000000000000000000

   1.000000000000000400000000000000000000000

   0.000000000000000000000000000000000000000

   0.000000000000000000000000000000000000000

   0.000000000000000444089209850062620000000

   0.000000000000000000000000000000000000000

   0.000000000000000000000000000000000000000

  _0.999999999999999560000000000000000000000

  _1.000000000000000000000000000000000000000

  _1.000000000000000000000000000000000000000

  _1.000000000000000000000000000000000000000

the numbers 2.000000000000000400000000000000000000000 and
1.000000000000000400000000000000000000000 show up before the number
mentioned by Arie Groeneveld (0.000000000000000444089209850062620000000).


On Wed, Apr 11, 2018 at 7:44 PM, 'Jon Hough' via Programming <
programm...@jsoftware.com> wrote:

> Must be due to  x ^ y returning floating datatypes, and losing precision.
>
> depth=:0
> S=: 1 :0
> :
> y=.<.y  NB.  <---------------------  floor of y
> if. 0= y do. 0
>   else.
> 'q r'=. (0,m) #: y
> ( r *(1+m) ^ (0 (m S) x)) + (1+x) m S q NB. <------------------ ^ returns
> floating
> end.
> )
>
> That will also fix it.
>
> This bug (is it a bug?) is in j805:
>    JVERSION
> Engine: j805/j64/darwin
> Release: commercial/2016-12-11T08:17:56
> Library: 8.05.14
> Qt IDE: 1.5.4s/5.6.2
> Platform: Darwin 64
> Installer: J805 install
>
>
>
> --------------------------------------------
> On Thu, 4/12/18, Arie Groeneveld <agroeneveld...@gmail.com> wrote:
>
>  Subject: Re: [Jprogramming] Goodstein Sequences and Hereditary base-n
> notation... CRASH!
>  To: programm...@jsoftware.com
>  Date: Thursday, April 12, 2018, 6:38 AM
>
>  I noticed it has to do with the
>  0=y testing in S. Instead of producing a
>  zero at a certain point it gives a small value
>  4.4....e_16 and then
>  starts filling the
>  stack.
>
>  Op 11-04-18 om 22:05
>  schreef Jose Mario Quintana:
>  > You might
>  like to look also at Arie Groeneveld's message,
>  >
>  > [Jprogramming] Crash
>  calculating large hyper operations
>  > http://www.jsoftware.com/pipermail/programming/2015-
> November/043351.html
>  >
>  > Unfortunately,
>  running on the latest stable release,
>  >
>  >     JVERSION
>  > Engine: j806/j64nonavx/windows
>  > Release: commercial/2017-11-06T10:01:33
>  > Library: 8.06.09
>  > Qt
>  IDE: 1.6.2/5.6.3
>  > Platform: Win 64
>  > Installer: J806 install
>  > InstallPath: j:/program files/j
>  > Contact: www.jsoftware.com
>  >
>  > the following,
>  >
>  > S=: 1 :0
>  > :
>  > if. 0= y do. 0
>  >    else. 'q r'=. (0,m) #: y
>  >          ( r *(1+m) ^ (0 (m S) x)) +
>  (1+x) m S q
>  > end.
>  >
>  )
>  >
>  > G=: (>:@[ $:
>  _1+ 4 : '0 (x S)y')`[@.(0=])
>  >
>  > 2 G"0 i.4
>  >
>  > now produces a crash ("J has stopped
>  working") instead of,
>  >
>  > 2 3 5 7
>  >
>  > As far as I can see, the code should run
>  on J804 but I do not know if it
>  > runs on
>  J805 (or on the latest and greatest j807).
>  >
>  > Anyway, in theory, 2
>  G"0 i.5 should include the additional number,
>  >
>  > _1 + 3 * 2 ^
>  402653211x
>  >
>  > in
>  practice, of course, it cannot (even trying to execute the
>  sentence _1 +
>  > 3 * 2 ^ 402653211x
>  produces a limit error).
>  >
>  >
>  >
>  >
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to