Moving from continued fraction to continued square root, I arrived at this:
NB. modelling gr=. rt(1+rt(1+rt(1+rt(1+...))))
gr=. monad define
ps=. +
rt=. %:
v=. y $ 1
r=. 1-~ (ps&rt)/ v
)
gr 10
1.61798
gr 13
1.61803
Q1:
What would be (more elegant and/or concise) ways to do this,
especially the line with the return value (r)..?
Q2:
What should I do to get higher precision (more digits) in the result
(and still having a floating point number); does that need a "foreign"..?
(I'm sure that I have seen this before, but can't remember where.)
Thanks
-M
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm