Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111483
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: math.frexp |
| Date | Sat, 16 Jul 2016 02:44:45 +1000 |
| Lines | 27 |
| Message-ID | <mailman.23.1468601093.2307.python-list@python.org> (permalink) |
| References | <5788cb76$0$1599$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmq=wGopxP_49b6CEjU-N8YbyGeWF85YW+5pe+T_Lsycpg@mail.gmail.com> <mailman.16.1468583297.2307.python-list@python.org> <5789101c$0$1615$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmp2CgWtrgT273mP52oLGEm4T+M0JVXPdDfJPuSqwX8gAw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de aPjefPU/UF4FnJZI5U+b4At7FB0AokGHeXP1s21PIPOg== |
| 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; '16,': 0.03; 'float': 0.05; 'memory.': 0.05; 'overflow': 0.07; 'scaling': 0.07; 'cc:addr :python-list': 0.09; 'appropriate': 0.14; 'intermediate': 0.15; 'result.': 0.15; '2016': 0.16; 'accuracy,': 0.16; 'effect,': 0.16; 'exponent': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mean,': 0.16; 'overflow.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'basically': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'prevent': 0.20; '64-bit': 0.22; 'am,': 0.23; '(or': 0.23; 'elements': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; '3.0': 0.27; 'convert': 0.29; "i'm": 0.30; "d'aprano": 0.33; 'impression': 0.33; 'right?': 0.33; 'steven': 0.33; 'values.': 0.33; 'received:google.com': 0.35; 'could': 0.35; 'something': 0.35; 'but': 0.36; 'too': 0.36; 'should': 0.36; 'needed': 0.36; 'subject:: ': 0.37; 'doing': 0.38; 'end': 0.39; 'rather': 0.39; 'some': 0.40; 'protection': 0.60; 'close': 0.61; 'back': 0.62; 'course': 0.62; 'combining': 0.66; 'jul': 0.72; 'chrisa': 0.84; 'float,': 0.84; 'maximize': 0.84; 'mistaken': 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; bh=a6tJkgeqJMh0rK1ZOuJzjpSnDq1fdMk48XEbkL6qYLU=; b=d3jx3LaAqgiG8um0GCMPQF3X3wnybIFRJ29i0b2x/R6b7UrM4kYEGSkxJwghNBTHOF IbBQhc2zuXBS9mN/v82ZnROGUklxuID6b7U1OYfm8iKGkvkYb7wANAaYicCilt0F7qYW X4wEcyyzrRsE5TsrBBWIEKjroCajU41RA8sLwmPcb/NUVVXW/y2rmceVqUDmM93OL43r Wbg2pg6yPXB7KyBQ2XbN6aFgEUNFsTCQ2NJXYBAqib6E9H6TV8Fe1XCrNwI3exrhgIYW ewRW/hxTHdNJYUN8hFF2ZPiR0VzDHIO/PEXKOST7keuxGhge9AK+VMcZcl4yFho6KNs+ LJvw== |
| 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; bh=a6tJkgeqJMh0rK1ZOuJzjpSnDq1fdMk48XEbkL6qYLU=; b=EIYhn86Rub9YDsyuvZMSxUIL3dqhpVnVGxz7Z2nnSHM+EKsxocz0vGFDyyJdwN+XV5 wqj5sLGV5RMQqNWAHkcgv0kb0gSojwSyyeKiI6AyRPBbRn2rgSdsngNWPlFTlWIYHz48 jR38ULAxT2LQC7LCxA70xTRkTAOV91QbobeIDeQenUzoY5++pTACHeUKBBhFeWtJDk+G VMyxB8dRk7dKIarO7Wo3tt7ueuZVAJ8ywAxVANoGpO6Gkyuj9sKXb2T+XnpSr0GAPp1i Gpmee8zfqqDCfusyUnow2WYxhysEYr04TXVZ6s/g8EGy6hs7/+Bw+dduuOmTlC5crgEe J/5g== |
| X-Gm-Message-State | ALyK8tIa9t9f+MRoW+kUJ8LXI5A2LDjBZieUTZrSzFVpqXwdGe2ERB7HMrCfLmwzNcc7gJIkD7VF9J+/y54jtw== |
| X-Received | by 10.28.44.131 with SMTP id s125mr23445744wms.61.1468601085766; Fri, 15 Jul 2016 09:44:45 -0700 (PDT) |
| In-Reply-To | <5789101c$0$1615$c3e8da3$5496439d@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 | <CAPTjJmp2CgWtrgT273mP52oLGEm4T+M0JVXPdDfJPuSqwX8gAw@mail.gmail.com> |
| X-Mailman-Original-References | <5788cb76$0$1599$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmq=wGopxP_49b6CEjU-N8YbyGeWF85YW+5pe+T_Lsycpg@mail.gmail.com> <mailman.16.1468583297.2307.python-list@python.org> <5789101c$0$1615$c3e8da3$5496439d@news.astraweb.com> |
| Xref | csiph.com comp.lang.python:111483 |
Show key headers only | View raw
On Sat, Jul 16, 2016 at 2:32 AM, Steven D'Aprano <steve@pearwood.info> wrote: > If the result is too big to be represented as a float at the end of the > product, then of course it will overflow. But this can give some protection > against overflow of intermediate values. Consider multiplying: > > 2.0, 1e200, 1e200, 1e-200, 1e-200, 3.0 > > > Mathematically, the answer should be 6. In principle, by rescaling when > needed to prevent overflow (or underflow), product() should be able to get > something very close to 6, if not exactly 6. I was under the impression that appropriate reordering of the elements could prevent over/underflow and maximize accuracy, but that may be a mistaken memory. However... > But I'm not actually writing a general product() function. I'm doing this > for geometric mean, so I return the scaling exponent and the mantissa[1] > separately, and then take the nth-root of them individually, before > combining them into the final result. ... this makes a lot of sense. In effect, I *think*, you're basically doing the multiplication on something rather larger than a 64-bit IEEE float, then taking the nth-root, and then combine them and convert back to float. Is this about right? ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
math.frexp Steven D'Aprano <steve@pearwood.info> - 2016-07-15 21:39 +1000
Re: math.frexp Chris Angelico <rosuav@gmail.com> - 2016-07-15 21:48 +1000
Re: math.frexp Steven D'Aprano <steve@pearwood.info> - 2016-07-16 02:32 +1000
Re: math.frexp Chris Angelico <rosuav@gmail.com> - 2016-07-16 02:44 +1000
Re: math.frexp Random832 <random832@fastmail.com> - 2016-07-15 14:28 -0400
Re: math.frexp Paul Rubin <no.email@nospam.invalid> - 2016-07-15 13:24 -0700
Re: math.frexp Steven D'Aprano <steve@pearwood.info> - 2016-07-16 20:21 +1000
Re: math.frexp Paul Rubin <no.email@nospam.invalid> - 2016-07-16 12:49 -0700
Re: math.frexp Nobody <nobody@nowhere.invalid> - 2016-07-15 17:39 +0100
Re: math.frexp Vlastimil Brom <vlastimil.brom@gmail.com> - 2016-07-17 01:18 +0200
csiph-web