Expected precision of Fortran FE constant evaluation

Toon Moene toon@moene.org
Mon Feb 11 21:44:00 GMT 2019


On 2/11/19 8:40 PM, Thomas König wrote:

> Hi Salvatore,
> 
>> Right, try this preprint
>> https://www.researchgate.net/publication/298896236_Remark_on_Algorithm_539_Carefully_Computing_the_Euclidean_Norm 
>>
>> Apart from typesetting to an older style it looks essentially the same
> 
> Interesting reading.
> 
> Regarding the algorithm the authors propose, I have one concern.
> The first part of their algorithm is (translating their pseudocode into
> Fortran, resulting errors are mine)
> 
>    real :: sm, s, t
> 
>    sm = 0.
>    s = 0.
>    do i=1, n
>       s = s + x(i)**2
>       t = sm
>       sm = t + s
>       s = s + (t-sm)
>    end do
>    norm2 = sqrt(sm)

Isn't this simply an application of Kahan summation ?

https://en.wikipedia.org/wiki/Kahan_summation_algorithm

...

-- 
Toon Moene - e-mail: toon@moene.org - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
At home: http://moene.org/~toon/; weather: http://moene.org/~hirlam/
Progress of GNU Fortran: http://gcc.gnu.org/wiki/GFortran#news



More information about the Fortran mailing list