Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #110297
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Unexpected NANs in complex arithmetic |
| Date | 2016-06-22 16:30 +1000 |
| Message-ID | <mailman.28.1466577051.11516.python-list@python.org> (permalink) |
| References | (1 earlier) <CAPTjJmrHcHM9RT5jZ=zAJ-bPavTQ12Mnp4HpLB4KwQsrSZtLTw@mail.gmail.com> <mailman.23.1466564278.11516.python-list@python.org> <nkd25i$8cv$1@dont-email.me> <576a2d6d$0$11089$c3e8da3@news.astraweb.com> <CAPTjJmrzYsciJW5FB7T_9xnbqT0f-BzfO__FHAMvGuOBo+6UyQ@mail.gmail.com> |
On Wed, Jun 22, 2016 at 4:17 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Wednesday 22 June 2016 13:54, Dan Sommers wrote:
>
>> By the time Python returns a result for inf+3j, you're already in
>> trouble (or perhaps Python is already in trouble).
>
> I don't see why. It is possible to do perfectly sensible arithmetic on INFs.
Technically, arithmetic on INF is a short-hand for a limit. What is
inf+1? Well, it's the limit of x+1 as x tends toward +∞, which is ∞.
So inf+1 evaluates to inf.
>>> inf = float("inf")
>>> inf+1
inf
What's 5-inf? Same again - the limit of 5-x as x tends toward +∞.
That's tending in the opposite direction, so we get infinity the other
way:
>>> 5-inf
-inf
So it's not really "doing arithmetic on infinity", as such. That said,
I'm not entirely sure why "inf+3j" means we're already in trouble -
Dan, can you elaborate? ISTM you should be able to do limit-based
arithmetic, just the same.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unexpected NANs in complex arithmetic Steven D'Aprano <steve@pearwood.info> - 2016-06-22 12:48 +1000
Re: Unexpected NANs in complex arithmetic Chris Angelico <rosuav@gmail.com> - 2016-06-22 12:57 +1000
Re: Unexpected NANs in complex arithmetic Dan Sommers <dan@tombstonezero.net> - 2016-06-22 03:54 +0000
Re: Unexpected NANs in complex arithmetic Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-22 16:17 +1000
Re: Unexpected NANs in complex arithmetic Paul Rubin <no.email@nospam.invalid> - 2016-06-21 23:25 -0700
Re: Unexpected NANs in complex arithmetic Chris Angelico <rosuav@gmail.com> - 2016-06-22 16:30 +1000
Re: Unexpected NANs in complex arithmetic Dan Sommers <dan@tombstonezero.net> - 2016-06-22 22:54 +0000
Re: Unexpected NANs in complex arithmetic Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-22 16:58 +1000
Re: Unexpected NANs in complex arithmetic Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-22 17:05 +1000
Re: Unexpected NANs in complex arithmetic Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-06-22 09:14 +0200
Re: Unexpected NANs in complex arithmetic Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-06-22 10:18 +0100
csiph-web