octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #43492] warning: division by zero for some nth


From: Rik
Subject: [Octave-bug-tracker] [bug #43492] warning: division by zero for some nthroots of zero
Date: Thu, 30 Oct 2014 15:21:29 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0

Follow-up Comment #4, bug #43492 (project octave):

The division by zero *warning* is the title and focus of the bug report.  This
warning is only emitted for division by a scalar zero.  Division by a vector
or matrix that contains zero does not produce a warning, so there is no code
change required.

The existing isfinite code catches any 0/0 divisions in a vector/matrix
combination because this operation will produce NaN which is not finite.

For why scalar division produces a warning and vector does not you could ask
on the Octave maintainers list.  I suspect the answer is that checking a
single scalar for being equal to zero is cheap, but checking an NxN matrix
would require N^2 operations which would quickly grow cumbersome.  Octave also
probably just forwards on to BLAS any matrix/matrix or matrix/vector
operations and BLAS does not emit a warning for division by zero since the
result is defined as either Inf (value != 0) or NaN (0 / 0). 

If you want to solve the different problem of actually preventing a division
by zero entirely, you could search the y vector for non-zeros and then perform
the Newton correction only on those entries.  Benchmarking would be required
to make sure this isn't slower.

As to why (2^12)^(1/6) does not equal exactly 4, that is probably running into
precision issues because the numbers are so different in size.  You can use
eps() to see the machine precision for each number, and they differ by about 3
orders of magnitude.


eps (2^12)
ans =    9.0949e-13
eps (1/6)
ans =    2.7756e-17


On the other hand, when calculating 2^(log2(2^12)/6), you are dealing with the
numbers 12 and 6 for which the machine precision is just about the same. 


eps (12)
ans =    1.7764e-15
eps (6)
ans =    8.8818e-16




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?43492>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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