<<   >>

10. Newton’s Method

(2 ÷⍨ ⊢ + ÷)\ n⍴x

Convergents to the square root of x by Newton’s method [44].

The operand of \ is a fork, itself a composition of two forks (2÷⍨(⊢+÷)) and equivalent to {0.5×⍵+⍺÷⍵} .

   ⊢ t← (2 ÷⍨ ⊢ + ÷)\ 7⍴2
2 1.5 1.41667 1.41422 1.41421 1.41421 1.41421

   2 - t×t
¯2 ¯0.25 ¯0.00694444 ¯0.0000060073 ¯4.51061E¯12 
      4.44089E¯16 4.44089E¯16

Since the phrase uses only rational operations, it yields rational convergents when applied to rational arguments. The following results are computed in J:

   ] t=: (2 %~ ] + %)/ \ 7 $ 2x
2 3r2 17r12 577r408 665857r470832 886731088897r627013566048 
      1572584048032918633353217r1111984844349868137938112

   0j_6 ": 2 - t * t
_2.000000e0 _2.500000e_1 _6.944444e_3 _6.007305e_6 _4.510950e_12 
      _2.543584e_24 _8.087276e_49