Thanks Devon -
I've experimented with extended precision in different contexts and
am able to reproduce your results here (which use the "continued
fraction" approach).
Using the "continued root" approach, and having set print precision
to 20 digits (which seems to be the maximum, as (9!:11 (21)) throws a
limit error) I get
(+&%:)/ 0 ,1000#1
1.6180339887498949
which shows less than 20 digits;
formatting this line shows where it breaks off
0j35": 1-~ (+&%:)/ 1000#1x
1.61803398874989490000000000000000000
I then tried (not knowing whether this makes any sense as the
implementation might be the same in the first place)
-- square root defined via the primitive:
rtp=. %:
-- square root defined via fractional exponent
rtf=. 1r2^~]
with the same result:
0j35": (+&rtp)/ 0 ,1000$1x
1.61803398874989490000000000000000000
0j35": (+&rtf)/ 0 ,1000$1x
1.61803398874989490000000000000000000
Comparing
9!:10 ''
6
0j35": (+&rtf)/ 0 ,1000$1x
1.61803398874989490000000000000000000
0j35": 1-~(+&rtf)/ 1000$1x
1.61803398874989490000000000000000000
0j35": (+`%)/ 1000$1x
1.61803398874989484820458683436563812
seems to indicate that the choice of print precision doesn't effect it.
That's where I got stuck ...
-M
At 2016-04-16 03:23, you wrote:
(+`%)/10$1 1.625 (+`%)/100$1 1.61803 (+`%)/100$1x
32951280099r20365011074 0j25":(+`%)/100$1x
1.6180339887498948482035085 0j25":(+`%)/1000$1x
1.6180339887498948482045868 0j55":(+`%)/1000$1x
1.6180339887498948482045868343656381177203091798057628621
0j55":(+`%)/2000$1x
1.6180339887498948482045868343656381177203091798057628621 On Thu,
Apr 14, 2016 at 7:02 PM, Martin Kreuzer <[email protected]>
wrote: > Thanks Raul, Kip -- > > (1) Am now comfortable (again)
with foreign print precision; just for the > record: > > def=.
6 > ext=. 13 > 9!:10 '' NB. check > 6 > 9!:11 (ext) NB.
set > > 9!:10 '' NB. check > 13 > 9!:11 ] def NB.
reset > > 9!:10 '' > 6 > > (2) The tacit version looks pretty
straight forward (and works fine). > > (3) Will follow up your
ideas/suggestions on "injection" and verb (cr) -- > fodder for the
weekend perhaps (no chance to stay with it on a regular > basis
yet, at least there's the habit of reading through the posts). > >
(4) Meanwhile, looking at your parameters of the (a cr b) call, I
did this > small modification, getting rid of the "cleanup"
(1-~): > > ] v=. 0 ,13#1 > 0 1 1 1 1 1 1 1 1 1 1 1 1
1 > (+&%:)/ v > 1.618033473928 > > -M > > At 2016-04-14 21:43,
you wrote: > >> The following is not simpler but invents a
"continued root" in which >> dyadic root %: plays the role
dyadic % plays in a continued fraction. >> Here is the picture of
a "continued root": a1
b0 + %: >> b1 + a2 %:
b2 + a3 >> %: b3
+ . >> .
. Verb cr >> below produces "convergents" which stop with a
"diagonal" element. The >> basic idea in verb cr belongs to Raul
Miller. cr =: {.@] , {.@] + [: ([: >> %:`+/ ,)\ [: |: [ ,: }.@] NB.
Usage a cr b (13#2) cr 0,13#1 NB. The 2 >> means square roots
are used 0 1 1.414213562 1.553773974 1.598053182 >> 1.611847754
1.616121207 1.617442799 1.617851291 1.617977531 1.618016542 >>
1.618028597 1.618032323 1.618033474 --Kip Murray On Thursday, April
14, >> 2016, Raul Miller <[email protected]> wrote: > One thing
you could >> do is get rid of the intermediate names in gr: > >
gr=: monad define > >> 1-~ (+&%:)/ y$1 > ) > > And you might want
to make this tacit, for example: >> > > 13 :'1-~ (+&%:)/ y$1' >
1 -~ [: +&%:/ 1 $~ ] > > Or, depending on >> your preferences, you
might want to use induction > rather than insertion: >> > >
gri=: 1-~(1+%:@])^:([-1:)&1 > > I guess it's really a matter
of >> what your idea of "elegance" is... > > Personally, when I am
fiddling with >> small expressions, I like to set > up a line that
evaluates and then tweak >> the expression and watch to > make sure
the result does not change. For >> this example, I'd have lines >
like: > > gr 10 > 1.61798 > >> 1-~(1+%:)^:9]1 > 1.61798 > 13
:'((+&%:)/ y$1) - 1' 10 > 1.61798 > >> (1-~(1+%:@])^:([-1:)&1) 10 >
1.61798 > > (with lots of other lines, >> including some errors,
mixed in) > > But the precision issue you are seeing >> is really
the print precision > global parameter. See > >>
http://www.jsoftware.com/help/dictionary/dx009.htm for how to
change > >> that. > > I hope this helps. > > -- > Raul > > On Thu,
Apr 14, 2016 at 3:13 >> PM, Martin Kreuzer <[email protected] >
<javascript:;>> wrote: > > >> 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 > >>
----------------------------------------------------------------------
> >> For information about J forums see
http://www.jsoftware.com/forums.htm >> -- Sent from Gmail Mobile >>
----------------------------------------------------------------------
For >> information about J forums see
http://www.jsoftware.com/forums.htm >> > >
----------------------------------------------------------------------
> For information about J forums see
http://www.jsoftware.com/forums.htm > -- 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