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


Groups > comp.lang.python > #39483

Re: Confusing math problem

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
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; 'algorithm': 0.03; 'versions,': 0.05; 'bug.': 0.07; 'python': 0.09; '22,': 0.09; 'calculates': 0.09; 'calculating': 0.09; "they've": 0.09; 'used)': 0.09; 'whichever': 0.09; 'bug': 0.10; 'times,': 0.13; 'library': 0.15; 'result.': 0.15; '(note,': 0.16; '*never*': 0.16; '53-bit': 0.16; 'fpu': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'how,': 0.16; 'nearest': 0.16; 'one-element': 0.16; 'stored.': 0.16; 'surprising': 0.16; 'wrote:': 0.17; 'documented': 0.17; 'integer': 0.17; 'processor': 0.17; '>>>': 0.18; 'feb': 0.19; 'math': 0.20; 'combination': 0.22; 'subject:problem': 0.22; "i'd": 0.22; "python's": 0.23; 'header :In-Reply-To:1': 0.25; 'values': 0.26; 'am,': 0.27; '(as': 0.27; 'set.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'chris': 0.28; 'case,': 0.29; 'that.': 0.30; 'fri,': 0.30; 'figure': 0.30; 'point': 0.31; 'gets': 0.32; 'impression': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'operations': 0.33; 'times.': 0.33; 'that,': 0.34; "can't": 0.34; 'received:google.com': 0.34; 'done': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; "wasn't": 0.36; 'possible': 0.37; 'does': 0.37; 'two': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'most': 0.61; 'between': 0.63; 'different': 0.63; 'more': 0.63; 'therefore': 0.65; 'total': 0.65; 'answer.': 0.71; 'power': 0.74; 'square': 0.75; '128,': 0.84; '2013': 0.84; 'before...': 0.84; 'calculations': 0.84; 'multiply': 0.84; 'multiplying': 0.84; 'resulted': 0.84; 'route': 0.84; 'angel': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=wAipTyMX649ZVCRbr7++qemuGPM4SIQgo61oZ1jco3s=; b=UTFOsMO6i9nB3ai5E3GKC9Mu5HE7S0OGui6kiKDqUQrzj/rthmLV0UA96pKU+R5L2j 3vs+0Xgr1zDW2T3DyPlfO6f27QaYvA2c3eplygYskOFTy77lNp4bucUN50x1JiJdjnoj 7XKz8TlKE9d1n/jWlT21BIX/SFwNDqoqqrnseb518COCUNM9/imNUtYWpDxBFoFGp7Uh ROBTIxvfoHSm+GtYFsQouFEJhW8TqDjwnXPNapVhVuExiAOwD6bo2HRodIViV473tZea DU8JJBXAIsiaYABqrjyvKksuTq+CeDN5lheauaOcafCQDK1UxJewiehHmlieeByG0ZD3 jQ/g==
MIME-Version 1.0
X-Received by 10.220.223.80 with SMTP id ij16mr13812285vcb.28.1361488517820; Thu, 21 Feb 2013 15:15:17 -0800 (PST)
In-Reply-To <5126A0D7.3080606@davea.name>
References <kg5sog$lfb$1@dont-email.me> <512682B3.8070909@davea.name> <51268867.1000800@davea.name> <mailman.2199.1361481815.2939.python-list@python.org> <aonjmqFqplbU1@mid.individual.net> <CAPTjJmoexWo4LcvqFQJmMUXSn+7+edgWm1kCXiYJ_su9ynPe=A@mail.gmail.com> <5126A0D7.3080606@davea.name>
Date Fri, 22 Feb 2013 10:15:17 +1100
Subject Re: Confusing math problem
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2210.1361488528.2939.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361488528 news.xs4all.nl 6974 [2001:888:2000:d::a6]:55121
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39483

Show key headers only | View raw


On Fri, Feb 22, 2013 at 9:33 AM, Dave Angel <davea@davea.name> wrote:
> On 02/21/2013 05:11 PM, Chris Angelico wrote:
>>
>>
>>>  <snip>
>>
>>
>> Note how, in each case, calculating three powers that have the same
>> real-number result gives a one-element set. Three to the sixtieth
>> power can't be perfectly rendered with a 53-bit mantissa, but it's
>> rendered the same way whichever route is used to calculate it.
>>
>
> But you don't know how the floating point math library (note, it's the
> machine's C-library, not Python's that used) actually calculates that.
>
> For example, if they were to calculate 2**64 by squaring the number 6 times,
> that's likely to give a different answer than multiplying by 2 63 times.
> And you don't know how the library does it.  For any integer power up to
> 128, you can do a combination of square and multiply so that the total
> operations are never more than 13, more or less.  But if you then figure a =
> a*a  and b = b/2, and do the same optimization, you might not do them
> exactly in the same order, and therefore might not get exactly the same
> answer.
>
> Even if it's being done in the coprocessor inside the Pentium, we don't have
> a documented algorithm for it.  Professor Kahn helped with the 8087, but I
> know they've tweaked their algorithms over the years (as well as repairing
> bugs).  So it might not be a difference between Python versions, nor between
> OS's, but between processor chips.

I was under the impression that, on most modern FPUs, calculations
were done inside the FPU with more precision than the 53-bit that gets
stored. But in any case, I'd find it _extremely_ surprising if the
calculation actually resulted in something that wasn't one of the two
nearest possible representable values to the correct result. And I'd
call it a CPU/FPU bug.

Of course, as we know, Intel's *never* had an FPU bug before...

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 19:33 +0000
  Re: Confusing math problem Dave Angel <davea@davea.name> - 2013-02-21 15:25 -0500
    Re: Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 22:39 +0000
      Re: Confusing math problem Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-21 22:53 +0000
        Re: Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 23:41 +0000
          Re: Confusing math problem Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-22 00:04 +0000
          Re: Confusing math problem Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-21 17:19 -0700
    Re: Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 23:39 +0000
  Re: Confusing math problem Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-21 13:42 -0700
  Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 07:46 +1100
    Re: Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 22:44 +0000
      Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 11:29 +1100
      Re: Confusing math problem Dave Angel <davea@davea.name> - 2013-02-21 21:19 -0500
  Re: Confusing math problem Dave Angel <davea@davea.name> - 2013-02-21 15:49 -0500
  Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 08:23 +1100
    Re: Confusing math problem Peter Pearson <ppearson@nowhere.invalid> - 2013-02-21 21:59 +0000
      Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 09:11 +1100
      Re: Confusing math problem Dave Angel <davea@davea.name> - 2013-02-21 17:33 -0500
      Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 10:15 +1100
    Re: Confusing math problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-22 09:16 +0000
      Re: Confusing math problem Serhiy Storchaka <storchaka@gmail.com> - 2013-02-22 13:48 +0200
  Re: Confusing math problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-22 09:27 +0000

csiph-web