[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Zero or not?
From: |
Matthias Brennwald |
Subject: |
Re: Zero or not? |
Date: |
Mon, 23 Jul 2007 15:31:38 +0200 (CEST) |
User-agent: |
SquirrelMail/1.4.4 |
Dear Franceso and James
Thanks for you replies. I've got a few more comments:
"Francesco Potorti`" <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?
>
> 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))...
"James Sherman Jr." <address@hidden> wrote:
> 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.
Ok, that makes sense to me. In fact, I've found the following:
octave:36> 1e20+8.197e3-1e20
ans = 16384
octave:37> 1e20+8.196e3-1e20
ans = 0
However:
octave:39> 8.196e3/1e20
ans = 8.1960e-17
This is much less than eps, which is:
octave:41> eps
ans = 2.2204e-16
So, maybe your estimate is still on the conservative side? Or am I missing
something here?
Matthias
- Zero or not?, Matthias Brennwald, 2007/07/21
- Re: Zero or not?, Jordi GutiƩrrez Hermoso, 2007/07/21
- Re: Zero or not?, Matthias Brennwald, 2007/07/21
- Re: Zero or not?, Ben Abbott, 2007/07/21
- Re: Zero or not?, Matthias Brennwald, 2007/07/22
- Re: Zero or not?, James Sherman Jr., 2007/07/22
- Re: Zero or not?,
Matthias Brennwald <=
- Re: Zero or not?, Francesco Potorti`, 2007/07/23
- Re: Zero or not?, James Sherman Jr., 2007/07/23
- Re: Zero or not?, Miroslaw Kwasniak, 2007/07/23
- Re: Zero or not?, Francesco Potorti`, 2007/07/24
- Re: Zero or not?, kensmith, 2007/07/24
- Re: Zero or not?, Przemek Klosowski, 2007/07/24
- Re: Zero or not?, kensmith, 2007/07/24
- Re: Zero or not?, Francesco Potorti`, 2007/07/22
- Re: Zero or not?, Miroslaw Kwasniak, 2007/07/23
- Re: Zero or not?, Francesco Potorti`, 2007/07/23