It looks like the "sqrt" function on the wiki at
http://www.jsoftware.com/jwiki/Essays/Extended Precision Functions works for
the extended case (with some fiddling necessary to make it decimal):

DP=: 40        NB. 40 digits of precision.

sqrt=: DP&$: : (4 : 0) " 0
 assert. 0<:y
 %/ <....@%: (2 x: (2*x) round y)*10x^2*x+0>.>.10^.y
)

round=: DP&$: : (4 : 0)
 b %~ <.1r2+y*b=. 10x^x
)

   T=. 10000000000000306999999999997669x
   sqrt T
6324555320336855745921954256628698742902673933907667687147821604985701262525202059973r2000000000000000000000000000000000000000000000000000000000000000000000

   NB. Oh, you want it as a _decimal_ fraction?


x:6324555320336855745921954256628698742902673933907667687147821604985701262525202059973%2
3162277660168427874729612940583299986722926510279479157298130884847194278152739225600
   NB. Decimal      ^ point before this digit (between "427" and "874")

   NB. But this isn't quite right either (starting a few places after the
decimal
   NB. point.)  It's actually surprising that it's correct as far as it
goes.
   NB. And this isn't helpful:

6324555320336855745921954256628698742902673933907667687147821604985701262525202059973x%2x
6324555320336855745921954256628698742902673933907667687147821604985701262525202059973r2

   NB. This almost does it but loses some internal zeros:
   -:".&>(3 : 'y<;.1~1,}:(<"0 ''02468'') e.~ <"0 y')
'6324555320336855745921954256628698742902673933907667687147821604985701262525202059973'
3 16 2 27766 0 168 4 2787 296 977 1 28 3 1 4 3 49 37 1 45 1 3 3696695 38 3
38 4 357 39 1 8 0 2 49 285 6 3 1 26 26 0 1 0 29986.5

-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to