[Jprogramming] Extended precision question
'Mike Day' via Programming
programming at jsoftware.com
Thu Apr 21 22:02:50 UTC 2022
One way to obtain high precision roots is to use, say, Newton’s solution to
y = x^2 - a :
Given an estimate x(n-1), the next estimate is
xn = x(n-1) - y/(dy/dx), in Maths notation.
In J, (J701 on this iPad),
rt =: -:@] + (% +:) NB. x is number whose root is required, y an initial guess
2 rt ^:_] 1. NB. Normal float
1.41421
2 rt ^:(i.5)1x NB. Extended to rational...
1 3r2 17r12 577r408 665857r470832
I forget how I solved this Euler Problem!
Mike
>>> On 4/21/2022 12:43 PM, Ed Gottsman wrote:
>>> Hello.
>>> I’m working on the Project Euler “Diophantine equation” problem (#66) and using J’s extended precision facilities. I’ve run into behavior that confuses me. Boiled down (and overusing x: just to be sure):
>>> x: %: x: 1 + x: *: x: 999999999
>>> 999999999
>>> That is (if my syntax is right), the square root of (one plus the square of a really large n) is n. I’m apparently misunderstanding something about extended precision. I’ve tried it with a variety of uses of x: but to no avail, and as I read the x: documentation…this is an odd result.
>>>
>>> Any help would be much appreciated.
>>> (J901 on iPadOS, for which sincere kudos to Ian Clark.)
>>> Many thanks.
>>> Ed
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list