Linda, here's a pretty good Newton's method adverb: newt =: 1 : 0 t =. y h =. 1 % 512 whilst. t ~: s do. s =. t t =. s - +: h * (u s) % (u s + h) - u s - h h =. h % 2 end. t )
(2 - *:) newt 1 NB. function on left, first root guess on right 1.414213562 --Kip Sent from my iPad > On Feb 25, 2014, at 12:44 AM, "Linda Alvord" <lindaalv...@verizon.net> wrote: > > I've been trying to remember Newton's Method and I came upon this: > > f=: 13 :'(A=:1 + ] - *:)N^:y]1' > f > 3 : '(A=:1 + ] - *:)N^:y]1' > > f 4 > 1597r987 > A 4 > _11 > > _11 N^:4]1 > |nonce error: N > | -u% u d.1 > > It has been such a long time since I have seen a nonce error that I thought > it was worth sharing! > > Linda > > -----Original Message----- > From: programming-boun...@forums.jsoftware.com > [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Nimp O > Sent: Monday, February 24, 2014 8:08 AM > To: programm...@jsoftware.com > Subject: Re: [Jprogramming] A Tale Without End > > Another nice way to get a lot of digits from the golden ratio is using > Newton's Method. > > In : http://www.jsoftware.com/jwiki/Essays/Newton%27s%20Method > N=: 1 : '- u % u d. 1' > > correct50 =: '1.61803398874989484820458683436563811772030917980576' > 0j50 ": (1 + ] - *:) N^:7 ] 1 > 1.61803398874989484820458683436563811772030917980576 > correct50 -: 0j50 ": (1 + ] - *:) N^:7 ] 1 > 1 > > > # correct1000 =: > '1.6180339887498948482045868343656381177203091798057628621354486227...' > 1002 > > correct1000 -: 0j1000 ": (1 + ] - *:) N^:12 ] 1 > 1 > You can get 50 correct digits in 7 iterations and 1000 digits in 12! > > > > > >> Here are the first 100 digits using this J function: >> >> 0j101 ":B > 1.61803398874989484820458683436563811772030917980576286213544862270526046281 >> 890244970720720418939113748 >> >> Linda > > > ---------------------------------------------------------------------- > 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