Sujet : Re: Continuations
De : terje.mathisen (at) *nospam* tmsw.no (Terje Mathisen)
Groupes : comp.archDate : 23. Jul 2024, 17:22:39
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v7olcf$19cc0$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.18.2
Michael S wrote:
On Tue, 23 Jul 2024 14:35:20 +0200
Terje Mathisen <terje.mathisen@tmsw.no> wrote:
Michael S wrote:
On Fri, 19 Jul 2024 20:55:47 +0200
Terje Mathisen <terje.mathisen@tmsw.no> wrote:
MitchAlsup1 wrote:
On Fri, 19 Jul 2024 14:16:01 +0000, Terje Mathisen wrote:
Back when I first looked at Invsqrt(), I did so because an
Computation Fluid Chemistry researcher from Sweden asked for help
speeding up his reciprocal calculations
(sqrt(1/(dx^2+dy^2+dz^2))), I found that by combining the 1/x and
the sqrt and doing three of them pipelind together (all the water
molecules having three atoms), his weeklong simulation runs ran
in half the time, on both PentiumPro and Alpha hardware.
>
I, personally, have found many Newton-Raphson iterators that
converge faster using 1/SQRT(x) than using the SQRT(x)
equivalent.
>
Yeah, that was eye-opening to me as well, to the level where I
consider the invsqrt() NR iteration as a mainstay, it can be useful
for both sqrt and 1/x as well. :-)
>
Terje
>
What is this "SQRT(x) equivalent" all of you are talking about?
I am not aware of any "direct" (i.e. not via RSQRT) NR-like method
for SQRT that consists only of multiplicationa and additions.
If it exists, I will be very interested to know.
>
sqrt(x) <= x/sqrt(x) <= x*rsqrt(x)
>
I.e. calculate rsqrt(x) to the precision you need and then do a
single fmul?
>
Terje
>
That much I know.
I knew that! :-)
When precise rounding is not required, I even know slightly better
"combined" method:
1. Do N-1 iterations for RSQRT delivering r0 with 2 or 3 more
significant bits than n/2
2. Calculate SQRT estimate as y0 = x*r0
3. Do last iteration using both y0 and r0 as y = y0 + (x-y0*y0)*0.5*r0.
That would give max. error of something like 0.51 ULP.
A similar combined method could be useful for sw calculation of
correctly rounded quad-precision sqrt as well. In this case it serves
as 'conditionally last step' rather than 'absolutely last step'.
I was hoping that you'll tell me about NR formula for SQRT itself that
can be applied recursively.
The only formula that I know is y = (y*y + x)/(y*2). Obviously, when
speed matters this formula is not useful.
Sorry, no, I have not found anything approaching the rsqrt() NR for sqrt().
Terje
-- - <Terje.Mathisen at tmsw.no>"almost all programming can be viewed as an exercise in caching"