Discussion:
Multiplication by 0: non-zero in versions 8 and 9
(too old to reply)
Sotirios Bonanos
2013-06-15 08:16:33 UTC
Permalink
Hello ,

I have noticed that in all Mathematica versions <8, multiplying a real or complex number by the integer 0 gives 0, but in versions 8 and 9

Times[0, 0.567] gives 0.

and

Times[1.23 + I 2.45, 0] gives 0. + 0. I

I don't know what prompted this change but it is definitely wrong: the zero property of multiplication holds for real and complex numbers also (see https://en.wikipedia.org/wiki/Multiplication#Properties) .

Sotirios Bonanos
http://www.inp.demokritos.gr/~sbonano/
Murray Eisenberg
2013-06-16 09:14:03 UTC
Permalink
In fact, the Mathematica behavior you observe in later versions, while
possibly disconcerting on strictly mathematical grounds, is reassuring
on software consistency grounds. Thus, the 9.0.1 documentation page
tutorial/ExactAndApproximateResults says:

"Whenever you give a number with an explicit decimal point,
Mathematica produces an approximate
numerical result [for a calculation involving that number]."

Personally, I would be unhappy if I did a calculation some of whose
numbers were approximate yet whose answer gave a misleading exact
answer.
On Jun 15, 2013, at 4:23 AM, Sotirios Bonanos
Post by Sotirios Bonanos
Hello ,
I have noticed that in all Mathematica versions <8, multiplying a real
or complex number by the integer 0 gives 0, but in versions 8 and 9
Post by Sotirios Bonanos
Times[0, 0.567] gives 0.
and
Times[1.23 + I 2.45, 0] gives 0. + 0. I
I don't know what prompted this change but it is definitely wrong: the
zero property of multiplication holds for real and complex numbers also
(see https://en.wikipedia.org/wiki/Multiplication#Properties) .
Post by Sotirios Bonanos
Sotirios Bonanos
http://www.inp.demokritos.gr/~sbonano/
---
Murray Eisenberg
***@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2838 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Richard Fateman
2013-06-16 09:09:39 UTC
Permalink
Post by Sotirios Bonanos
Hello ,
I have noticed that in all Mathematica versions <8, multiplying a
real or complex number by the integer 0 gives 0, but in versions 8
and 9
Times[0, 0.567] gives 0.
and
Times[1.23 + I 2.45, 0] gives 0. + 0. I
the zero property of multiplication holds for real and complex
numbers also (see
https://en.wikipedia.org/wiki/Multiplication#Properties) .
Sotirios Bonanos http://www.inp.demokritos.gr/~sbonano/
You appear to be making a distinction between "0" and "0."
and "0.+0.I". Yet for Mathematica, 0==0.+0.*I returns True.

You may have a valid objection to something that has been
changed in the program, but appealing to the wikipedia
article is not particularly significant.

After all,
Times[0,x] comes out as 0, but this is not what happens
for x being 0., Indeterminate, Infinity, Interval[{-1,1}],
and probably other stuff.

As Dorothy said, you are not in Kansas anymore.
http://en.wiktionary.org/wiki/not_in_Kansas_anymore
Bob Hanlon
2013-06-16 09:10:40 UTC
Permalink
Use of inexact numbers produces inexact results (which can be handled with
Rationalize or Chop). Use of exact numbers produes exact results.


Times[1.23 + I 2.45, 0] // Rationalize


0


Times[1.23 + I 2.45, 0] // Chop


0


Times[123/100 + I 245/100, 0]


0


Times[1.23 + I 2.45 // Rationalize, 0]


0



Bob Hanlon
Post by Sotirios Bonanos
Hello ,
I have noticed that in all Mathematica versions <8, multiplying a real or
complex number by the integer 0 gives 0, but in versions 8 and 9
Times[0, 0.567] gives 0.
and
Times[1.23 + I 2.45, 0] gives 0. + 0. I
I don't know what prompted this change but it is definitely wrong: the
zero property of multiplication holds for real and complex numbers also
(see https://en.wikipedia.org/wiki/Multiplication#Properties) .
Sotirios Bonanos
http://www.inp.demokritos.gr/~sbonano/
Daniel Lichtblau
2013-06-17 10:20:53 UTC
Permalink
Post by Sotirios Bonanos
Hello ,
I have noticed that in all Mathematica versions <8, multiplying a real or complex number by the integer 0 gives 0, but in versions 8 and 9
Times[0, 0.567] gives 0.
and
Times[1.23 + I 2.45, 0] gives 0. + 0. I
I don't know what prompted this change but it is definitely wrong: the zero property of multiplication holds for real and complex numbers also (see https://en.wikipedia.org/wiki/Multiplication#Properties) .
Sotirios Bonanoshttp://www.inp.demokritos.gr/~sbonano/
This is a sort of edge case. It is important (especially in say
matrix algebra) to have machine reals and complexes remain in that
class. Hence the importance of this change which, I agree, can be
disconcerting. But it allows the possibility to avoid unpacking
packed arrays just to handle some elements that have become
exact zeros.

In contrast, higher precision arithmetic behaves as you would expect.

In[7]:= 0*N[1, 20]

Out[7]= 0

What this is, really, is a balancing act in terms of maintaining type
(exact vs approximate), respecting the math (where exact zero times
most things usually does give exact zero), and not doing things that
would needlessly have a bad impact on speed and memory consumption.

Daniel Lichtblau
Wolfram Research

Loading...