help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zero or not?


From: Francesco Potorti`
Subject: Re: Zero or not?
Date: Mon, 23 Jul 2007 16:07:05 +0200

>>>Ok, that's a start. If I calculate the sum of N numbers, what is the
>>>maximum 'offset' of the numerical result to mathematically correct
>>>result?
>>
>> Not a numerical expert, but the error magnitude should be bounded by
>> eps*sum(abs(x[1:N])).
>
>Are you sure this is what you intended to write? For example:
>
>octave:5> eps
>ans =  2.2204e-16
>octave:6> x = [ 1E5 -1E5 ]; N = length(x);
>octave:7> eps*sum(abs(x(1:N)))
>ans =  4.4409e-11
>
>I just hope (pray) that Octave can do better than this when calculating
>the sum of the values in x (i.e. sum(x))...

How possibly could it?  You get a result of 1e5 and an error of 4e-11.
This is the machine precision, so you cannot get better than this as a
worst case.  Certainly, depending on the precise numbers you sum up you
will generally get smaller errors, or even 0, but the error bound cannot
be smaller.

-- 
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa         Email: address@hidden
Web: http://fly.isti.cnr.it/           Key:   fly.isti.cnr.it/public.key


reply via email to

[Prev in Thread] Current Thread [Next in Thread]