# bug #54484: Difference in divide by zero warning

 Submitted by: Arnaud Delorme Submitted on: Thu 09 Aug 2018 09:31:28 PM UTC Category: Interpreter Severity: 1 - Wish Priority: 5 - Normal Item Group: Matlab Compatibility Status: Fixed Assigned to: None Originator Name: Open/Closed: Closed Release: 4.4.0 Operating System: Any

You are not logged in

## Discussion

Thu 21 Feb 2019 05:23:31 PM UTC, comment #7:

The "division by zero" warning has been completely removed on the default branch for Octave 6, closing this bug as fixed.

See bug #46650.

Mike Miller <mtmiller>
Tue 14 Aug 2018 01:18:34 AM UTC, comment #6:

I started investigating returning NaNs and found another issue with our unnecessary calculation of the 1-norm of matrices in a few places.  I checked in a change for that here (https://hg.savannah.gnu.org/hgweb/octave/rev/f5ea7511c405).

Rik <rik5>
Fri 10 Aug 2018 05:14:13 PM UTC, comment #5:

Very much agreed.

Philip Nienhuis <philipnienhuis>
Fri 10 Aug 2018 04:40:59 PM UTC, comment #4:

I don't think we need to have the exact same return matrix.  However, it might be useful to return all NaNs so that subsequent calculations are impossible.

Under Octave, someone might be do a division of a singular matrix in the midst of a chain of computations and an all zeros matrix might allow processing to continue.

Simple example:

x = ones (2);
y = zeros (2);
z = x / y;
z = z + 5

z =

5   5
5   5

If you are running a script in batch mode, or otherwise fail to see the warning message, then you might think the end result is correct.

Rik <rik5>
Fri 10 Aug 2018 04:34:51 PM UTC, comment #3:

Matlab r2018b prerel. gives a similar warning but returns

>> ones(2)/zeros(2)
Warning: Matrix is singular to working precision.

ans =
NaN   Inf
NaN   Inf

Philip Nienhuis <philipnienhuis>
Fri 10 Aug 2018 03:44:40 PM UTC, comment #2:

I can't remember exactly where, but this issue has been discussed.  I think the concensus was actually to remove the warning.  It is an extra step that Octave has to do to check the denominator argument and we would prefer simply to pass the division operation directly to BLAS and let it throw an error if it needs to.

@Marco: In Matlab, what is the warning for

ones(2)/zeros(2)

Under Octave, I get

warning: matrix singular to machine precision
ans =

0   0
0   0

Rik <rik5>
Fri 10 Aug 2018 06:49:53 AM UTC, comment #1:

@Arnaud: a division by zero must alarm uninformed used, imho. I think we already discussed it, but I cannot find the reference. Anyway, matlab already gives a warning for things like

ones(2)/zeros(2);
zeros(2)\ones(2);

So, I think octave is more consistent. As a teacher, I cannot support your proposal.

Marco Caliari <caliari>
Thu 09 Aug 2018 09:31:28 PM UTC, original submission:

1/0

generates a warning but Matlab 2018a (and to my knowledge earlier versions down to Matlab 5.3) do not.
This can be alarming to uninformed users.

Is it possible to disable that warning in traditional mode?

Arno

Arnaud Delorme <arnodelorme>

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

No files currently attached

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by rik5 (Posted a comment)
• -email is unavailable- added by caliari (Posted a comment)
• -email is unavailable- added by arnodelorme (Submitted the item)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only project members can vote.