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