help-octave
[Top][All Lists]
Advanced

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

Re: Zero or not?


From: James Sherman Jr.
Subject: Re: Zero or not?
Date: Sun, 22 Jul 2007 13:44:43 -0400

I don't know if this is even possible to quantify absolutely.  take for example:

octave:55> 1e20+0.1-1e20
ans = 0

Because underflow happens when you add 1e20 and 0.1, the result is still 1e20.  So I believe the maximum offset for a set of numbers (worse case scenario) is something on the order  of:  (let N be the vector of numbers)
maximumOffset = length(N)*eps*max(abs(N));

Which would be like adding 0.1 to 1e20, N-1 times.  Note that this because eps is not an absolute value, but a relative one.

Though I'm sure someone more versed in the ways of floating point arithmetic will correct me if I'm wrong.

Hope this helps.

On 7/22/07, Matthias Brennwald <address@hidden> wrote:
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? I'd guess its N*eps, but I'm not sure.

Matthias



On 21.07.2007, at 19:14, Ben Abbott wrote:

> check out the function "eps"
>
> On Jul 21, 2007, at 12:45 PM, Matthias Brennwald wrote:
>
>> Ok. Is there a way to predict the expected offset? I need to test if
>> the sums across the columns of a matrix are zero, or at least within
>> the bounds expected from the IEEE arithmetic.
>>
>> Matthias
>>
>> On 21.07.2007, at 15:17, Jordi Gutiérrez Hermoso wrote:
>>
>>> On 21/07/07, Matthias Brennwald <address@hidden> wrote:
>>>> I expected the below code to yield only zeros, but it does not:
>>>
>>> That's just the way IEEE arithmetic works. When subtracting two
>>> numbers that are very close, you may not get zero, just machine
>>> epsilon. Try this, for fun: 0.3 - 0.2 - 0.1
>>>
>>> - Jordi G. H.
>>




-------
Matthias Brennwald
Lägernstrasse 6
CH 8037 Zürich
+41 (0)44 364 17 03
address@hidden



_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

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