Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39008
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!hq-usenetpeers.eweka.nl!81.171.88.250.MISMATCH!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <davea@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'algorithm': 0.03; '*not*': 0.07; 'bits': 0.07; 'closest': 0.09; 'curve': 0.09; 'modulo': 0.09; 'rounding': 0.09; 'rules.': 0.09; 'zero.': 0.09; 'subject:python': 0.11; 'result.': 0.15; '*never*': 0.16; 'division,': 0.16; 'language)': 0.16; 'nearest': 0.16; 'reasonably': 0.16; 'wrote:': 0.17; 'feb': 0.19; 'math': 0.20; 'addition,': 0.21; 'error.': 0.21; 'meant': 0.21; 'machine.': 0.22; 'subject:problem': 0.22; 'programming': 0.23; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'common': 0.26; 'values': 0.26; '[1]': 0.27; 'ago': 0.27; 'am,': 0.27; 'checking': 0.27; 'rules': 0.27; '(as': 0.27; '[2]': 0.27; "doesn't": 0.28; 'correct': 0.28; 'actual': 0.28; 'arithmetic': 0.29; 'closer': 0.29; 'decimal': 0.29; 'gary': 0.29; 'mode.': 0.29; 'fri,': 0.30; 'error': 0.30; 'point': 0.31; 'point,': 0.33; 'to:addr:python- list': 0.33; 'equal': 0.33; 'expected': 0.35; 'there': 0.35; 'but': 0.36; 'should': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'apply': 0.39; 'received:192': 0.39; 'little': 0.39; 'received:192.168': 0.40; 'real': 0.61; 'first': 0.61; 'distance': 0.62; 'necessarily': 0.63; 'different': 0.63; 'subject': 0.66; 'combining': 0.71; 'contrary': 0.71; 'realized': 0.71; 'received:74.208': 0.71; 'pleasure': 0.75; '2013': 0.84; 'calculations': 0.84; 'degrees,': 0.84; 'multiplying': 0.84; 'received:74.208.4.194': 0.84; 'slope': 0.84; 'typically,': 0.84; 'imagine': 0.96 |
| Date | Sat, 16 Feb 2013 13:24:22 -0500 |
| From | Dave Angel <davea@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: python math problem |
| References | <kfm2t8$9ru$1@ger.gmane.org> <mailman.1841.1360957660.2939.python-list@python.org> <pan.2013.02.16.13.55.31.206000@nowhere.com> |
| In-Reply-To | <pan.2013.02.16.13.55.31.206000@nowhere.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:weOrjtHLJ43rANvdYi4zZM0Cl87DFe5iM3g4nbn9XHh cybOMb5fxZCwsMSVXbzsdroriwMlOETpIdId4TYbIdWMSk7nBU tzft0i8jGCPjTwqVB6OrvqQXn84JQ7RstukqtwzAbDmEgxsxRU VT0JM5j3wzc1WkyGXQDvxLNqNSIxuQZQB/nO3W2CwlYkZLkT6d Z2OZYZh/zRPb7A+mEEGJnElzkDCw6ueNjZ1eKyEpTUIgJEBFLl Oa37ZazQAXuQjU52RjsrVXktCR8eHfNkfe5ZzGwchD6aqxwZZQ yraxoujAbxuXzMeXEhlyasLtR7qdU85Hn0T2CSp40DxZ3HqHw= = |
| 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.1876.1361039085.2939.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361039085 news.xs4all.nl 6868 [2001:888:2000:d::a6]:44478 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39008 |
Show key headers only | View raw
On 02/16/2013 08:55 AM, Nobody wrote: > On Fri, 15 Feb 2013 11:47:33 -0800, Gary Herron wrote: > >> Floating point calculations on a computer (ANY computer, and ANY >> programming language) can *never* be expected to be exact! > > "never" is incorrect. There are many floating-point calculations > which can reasonably be expected be exact[2]. > > However, multiplying by pi (as in math.radians) isn't such a > calculation[1], so radians(90) isn't exactly equal to pi/2 and so > cos(radians(90)) isn't exactly equal to zero. > > [1] It's not so much that the calculation isn't exact, but that the > calculation has to use an inexact approximation to pi to start with. > > [2] In particular, any addition, subtraction, multiplication, division, > modulo or square-root calculation for which the correct answer is exactly > representable should actually produce the correct answer, exactly. > > Furthermore, any such calculation for which the correct answer isn't > exactly representable should produce the same result as if the correct > answer had been calculated to an infinite number of digits then rounded to > the nearest representable value according to the current rounding mode. > > This doesn't apply to transcendental functions (trig, log, exponential), > which are subject to the "table maker's dilemma". Typically, the actual > result will be one of the two closest representable values to the correct > answer, but not necessarily *the* closest. > > IOW: floating-point arithmetic is deterministic. It follows rules. Not the > same rules as real arithmetic, but rules nonetheless. Contrary to > common superstition, the least-significant bits are *not* taken from > /dev/random. > Combining two of those rules: Many years ago I microcoded the decimal math package for a machine. Upon checking the value for sin(pi), I was considering whether using a different reduction algorithm might get an answer closer to zero. The system used a 13 decimal digit mantissa. Imagine my pleasure when I realized that the *second* 13 digits of pi were what I was seeing for a result. (Actually, with a negative sign) The quantization error of representing pi meant that I was a little distance away from 90 degrees, and since the slope of the curve is -1 at that point, abs(result) was the first 13 digits of that error. -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: python math problem Gary Herron <gherron@digipen.edu> - 2013-02-15 11:47 -0800
Re: python math problem Nobody <nobody@nowhere.com> - 2013-02-16 13:55 +0000
Re: python math problem Chris Angelico <rosuav@gmail.com> - 2013-02-17 01:30 +1100
Re: python math problem Roy Smith <roy@panix.com> - 2013-02-16 09:32 -0500
Re: python math problem Dave Angel <davea@davea.name> - 2013-02-16 13:24 -0500
csiph-web