On Tue, Nov 24, 2020 at 08:32:21AM +1100, Chris Angelico wrote:
> On Tue, Nov 24, 2020 at 8:26 AM Wes Turner <[email protected]> wrote:
> >
> > Is there a different IEEE spec or CAS that distinguishes between 1/x and
> > 2/x where x=0?
> >
> > assert 1/0 != 2/0 != math.inf/0
> >
>
> No, why should there be? There is absolutely no difference between
> them mathematically.
If we are talking about the standard real number system that we all know
and love, there certainly is.
Under the Reals, it is meaningless to say that 1/0 even exists. So we
have to be talking about limits for the question to even make sense.
2/x is always twice the size of 1/x regardless of what x is, so there is
always a difference between them:
2/x = 1/x * 2 # always holds, regardless of x
So there is that difference. How about the limits?
We can't say that it is "infinity" because infinity isn't a real number.
In the real numbers, "the limit is infinity" is nonsense. Admittedly it
is commonly said nonsense, but if we want to be correct and precise, we
should say that it "increases without limit".
If you take the limit of 1/x as x approaches zero, we get a
discontinuity:
- as x approaches zero from below, 1/x is *negative*, with magnitude
increasing without limit;
- but as x approaches zero from below, 1/x is *positive*, with magnitude
increasing without limit.
So the two limits are not only different, but they are as different as
it is possible to get. They are as far apart as it is possible to get!
So even if we count "infinity" as a value, there is still no single
value that could represent the limit of 1/x as x approaches 0.
We should consider that the IEEE-754 result for division by zero
represents the case of the denominator underflowing to zero, but is
"really" a microscopically tiny positive or negative value, then the
result overflows to the appropriately signed infinity.
There's no way in IEEE-754 to perform 1/0 where the 0 represents actual
zero (rather than a quantity that underflowed to 0), which should give a
NAN.
--
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/VIBF7PA3GJEVYM2LFIXOU4YS55AVEUI5/
Code of Conduct: http://python.org/psf/codeofconduct/