Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #110297

Re: Unexpected NANs in complex arithmetic

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Unexpected NANs in complex arithmetic
Date Wed, 22 Jun 2016 16:30:49 +1000
Lines 32
Message-ID <mailman.28.1466577051.11516.python-list@python.org> (permalink)
References <5769fc9b$0$1622$c3e8da3$5496439d@news.astraweb.com> <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>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de gC8d0V8M7MN2YqbA/fwTzgs8MUMxeACY+M8zrNr7ltCQ==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'cc:addr:python-list': 0.09; '22,': 0.09; 'tends': 0.09; 'way:': 0.09; 'python': 0.10; 'wed,': 0.15; 'wednesday': 0.15; '-inf': 0.16; '2016': 0.16; 'evaluates': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inf': 0.16; 'infinity': 0.16; 'opposite': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'tending': 0.16; 'wrote:': 0.16; 'why.': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '(or': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'said,': 0.27; 'arithmetic': 0.29; 'dan': 0.29; 'sensible': 0.29; 'such.': 0.29; "i'm": 0.30; "we're": 0.30; "d'aprano": 0.33; 'steven': 0.33; 'received:google.com': 0.35; 'trouble': 0.35; 'should': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'received:209': 0.38; 'means': 0.39; 'why': 0.39; 'sure': 0.39; 'limit': 0.65; 'chrisa': 0.84; 'short- hand': 0.84; 'to:none': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc :content-transfer-encoding; bh=KlDHsNtVovstKJJ1WEQuw9piXdZb+/UqPPe/0VlZOnQ=; b=nhFCY7yaR3y6+tKsNtTHZGkTQzNclXU5qBhz2QkCeOCj8qfISA5lPCM1B9m4ztgJoj eu8kEXKT+F2UgwTOsaXbt44yjZwmDb9lMvBhlF42TDRJFPEnlxu98Qbr4DD98Ma2VRRE n6hI1lHhQGZvnJnBKFAKW/vmek3uX+SqJ8y58GjpWzxOWbihb3mPWiJxtZwfoetSGv02 xq/KSjfqvLSb4LxdO86lmjbAjj4fo61WbUOkzpzAQ99Ju247t2Pl26TMlNIP6+yad2PD JBgs7BaFS7YPkRPN0xEFwuzgDT07K70LryoQdwsaQuDg2uZEGLXWX/kcCyNb/SiC3QOE yKlw==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc:content-transfer-encoding; bh=KlDHsNtVovstKJJ1WEQuw9piXdZb+/UqPPe/0VlZOnQ=; b=DOR/+vfDrJprpMSG1k8bJOQBOnJYkRp+4hx6f7VlhR/4FIaghfPW2aSGI8+nT4oYVF 5JbEtz/Ovkcegste0/HVv+NjYw2WIPgZVUcuyXouPS85nLroxu2pcrhpSisQlFZZQqlS p2dfWUepOOw5umvdKCM8uhVqWGifMmviBtJG+9qrbvr3flHloE9+9VgZAiO7KDLibrd2 2rntmqEKPMctxx68xKYGakA545whGFoNCTLu7MxuS0FXfV5XSytruSSVn2MY6vQpZF9B 5dBV3fR1YXUuBYz0BiTOdGuhKwteKTMXYCbXYwvnI8MHnge0TcbGNYswaBvTfzy3zTyO cWXg==
X-Gm-Message-State ALyK8tJSAAQdm7FOQ4j1KDaFqtZt09U8ewh3W1lr/Z5AOVcFfo/e13LSvl5LQxOl1QaL9qH/lLWi6w/DmnxPbQ==
X-Received by 10.194.97.201 with SMTP id ec9mr22530475wjb.117.1466577049835; Tue, 21 Jun 2016 23:30:49 -0700 (PDT)
In-Reply-To <576a2d6d$0$11089$c3e8da3@news.astraweb.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAPTjJmrzYsciJW5FB7T_9xnbqT0f-BzfO__FHAMvGuOBo+6UyQ@mail.gmail.com>
X-Mailman-Original-References <5769fc9b$0$1622$c3e8da3$5496439d@news.astraweb.com> <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>
Xref csiph.com comp.lang.python:110297

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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