I was able to reproduce, not without some difficulties, the first couple of
tables in that page following a pedestrian approach; but apparently there
is a (theoretical based?) shortcut to define the gs function (see
https://tromp.github.io/pearls.html  ).  Maybe, one of the Haskell literate
members of the forum can transcribe it to J.

If still of interest. Here's a J version:

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=])

e.g.

   2 G"0 i.4
2 3 5 7
   3 G"0 i.13
3 4 5 7 9 11 15 19 23 63 159 383 2047

As an aside: in general n G i.k

can be replaced for the first n^2 terms with

Gdiff=:+/\@(,}.@($~#2^i.))

e.g.

   Gdiff 3
3 4 5 7 9 11 15 19 23


-Arie


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

Reply via email to