Why use {.|.+`%/\1x,100#1 when +`%/101$1x is available?
On Mon, Mar 10, 2014 at 6:55 PM, Devon McCormick <[email protected]> wrote:
> NB. Show 50 digits of approximation of phi
> 0j50":{.|.+`%/\1x, 100#1
> 1.61803398874989484820350851924118133676198756188312
> 0j50":{.|.+`%/\1x, 200#1
> 1.61803398874989484820458683436563811772030781841854
> 0j50":{.|.+`%/\1x, 300#1
> 1.61803398874989484820458683436563811772030917980576
>
> NB. Generalize to x digits of y 1s approximation of phi
> nDigitsPhi=: ((0j1 * [) ": [: {. [: |. [: +`%`:3\ 1x , 1 $~ ])"0
> 50 nDigitsPhi 10 20
> 1.62500000000000000000000000000000000000000000000000
> 1.61797752808988764044943820224719101123595505617978
>
> NB. Where they first differ tells us how precise each approximation is:
> 2=/\50 nDigitsPhi 100*>:i.3
> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 1 0 0 0 0 1 0 0 0 0 0 0 0 0
> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
> 1 1 1 1 1 0 0 0 0 0 0 0 0 0
>
> 0 i.~"(0 1) 2=/\99 nDigitsPhi 100*>:i.5
> 22 43 64 85
> 2-~/\22 43 64 85
> 21 21 21
>
> NB. So, we get about 21 digits for each 100 ones.
>
>
> On Mon, Mar 10, 2014 at 9:34 PM, Roger Hui <[email protected]
> >wrote:
>
> > The best rational approximation to the golden ratio is the ratio of two
> > consecutive Fibonacci numbers.
> >
> >
> >
> > On Mon, Mar 10, 2014 at 6:31 PM, Linda Alvord <[email protected]
> > >wrote:
> >
> > > Thanks for your hints. I always wanted to get rational approximations
> > for
> > > the Golden Section.
> > >
> > > {.|.+`%/\1x, 300#1
> > > 26099748102093884802012313146549r16130531424904581415797907386349
> > >
> > > 32#'O'
> > > OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> > >
> > > {.|.+`%/\1x, 400#1
> > >
> > >
> >
> 734544867157818093234908902110449296423351r453973694165307953197296969697410
> > > 619233826
> > >
> > >
> > >
> > >
> >
> 734544867157818093234908902110449296423351%453973694165307953197296969697410
> > > 619233826
> > > 1.61803
> > >
> > > How can I get the best possible decimal approximation (I have 32 bit
> > > digits)?
> > >
> > > Linda
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: [email protected]
> > > [mailto:[email protected]] On Behalf Of EelVex
> > > Sent: Monday, March 10, 2014 7:12 PM
> > > To: Programming forum
> > > Subject: Re: [Jprogramming] Approximating e
> > >
> > > * Summing infinite series
> > >
> > > +/%!i.100x
> > > +/^ t. i.100x NB. Taylor coefficients
> > > %+/((_1&^)%!)i.100x
> > > etc
> > >
> > > * Taking an asymptotic
> > >
> > > (-^~1-%) 100x
> > > ((^~%~^~@>:) - (^~%^~@<:))100x
> > > etc
> > >
> > > * Continued fractions
> > >
> > > +`%/2 1,2#>:i.100x
> > > +`%/2, 2#2+i.100x
> > > (+%)/2 1, ,(1 1,~])"0 +:>:i.100x NB. canonical form
> > >
> > >
> > >
> > >
> > > On Mon, Mar 10, 2014 at 6:38 PM, km <[email protected]> wrote:
> > >
> > > > The rational 2721r1001 approximates e to six, almost seven
> decimal
> > > > places:
> > > >
> > > > 0j7 ": (^ 1) ,: 2721r1001
> > > > 2.7182818
> > > > 2.7182817
> > > >
> > > > I got 2721r1001 from a continued fraction. How would you look for
> > > > rational approximations to e ?
> > > >
> > > > --Kip Murray
> > > >
> > > > Sent from my iPad
> > > >
> ----------------------------------------------------------------------
> > > > For information about J forums see
> http://www.jsoftware.com/forums.htm
> > > >
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > >
> > > ----------------------------------------------------------------------
> > > 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
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm