0. The following is a shorter equivalent for "newton":
   newton=:1 : '- u % u d. 1'

1. Showing convergents:

   (_2+*:) newton^:(i.8) 2
2 1.5 1.41667 1.41422 1.41421 1.41421 1.41421 1.41421
   2 - *: (_2+*:) newton^:(i.8) 2
_2 _0.25 _0.00694444 _6.0073e_6 _4.51061e_12 _4.44089e_16 4.44089e_16 
_4.44089e_16

2. Rational numbers:

   (_2+*:) newton^:(i.8) 2x
2 3r2 17r12 577r408 665857r470832 886731088897r627013566048 ...
   0j_40 ": ,. (_2+*:) newton^:(i.8) 2x
2.0000000000000000000000000000000000000000e0
1.5000000000000000000000000000000000000000e0
1.4166666666666666666666666666666666666667e0
1.4142156862745098039215686274509803921569e0
1.4142135623746899106262955788901349101166e0
1.4142135623730950488016896235025302436150e0
1.4142135623730950488016887242096980785697e0
1.4142135623730950488016887242096980785697e0

   2 - *: (_2+*:) newton^:(i.8) 2x
_2 _1r4 _1r144 _1r166464 _1r221682772224 _1r393146012008229658338304 ...
   0j_5 ": 2 - *: (_2+*:) newton^:(i.8) 2x
_2.00000e0 _2.50000e_1 _6.94444e_3 _6.00730e_6 _4.51095e_12 _2.54358e_24 
_8.08727e_49 _8.17550e_98



----- Original Message -----
From: John Randall <[EMAIL PROTECTED]>
Date: Saturday, October 13, 2007 15:32
Subject: [Jgeneral] Brief example
To: [email protected]

> I want to use Newton's method as a very brief example that
> demonstrates several distinctive features of J.
> 
> So far I have
> 
>    newton=:1 : '-(u % u d. 1)'
>    (_2+*:) newton^:_ ] 2
> 1.41421
>    1&o. newton^:_ i.7
> 0 0 3.14159 3.14159 3.14159 9.42478 6.28319
> 
> Does anyone have suggestions for improving the adverb or the examples?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to