Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39483
| References | (2 earlier) <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 | 2013-02-22 10:15 +1100 |
| Subject | Re: Confusing math problem |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2210.1361488528.2939.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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