Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:verizon.net': 0.07; 'terry': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:python': 0.11; 'am,': 0.12; 'float': 0.13; 'reedy': 0.16; 'values:': 0.16; 'zero,': 0.16; 'this:': 0.16; 'wrote:': 0.16; 'jan': 0.19; 'assume': 0.22; 'header:In-Reply-To:1': 0.22; 'fairly': 0.30; 'important,': 0.30; 'usual': 0.31; 'error': 0.32; 'error.': 0.32; 'to:addr:python-list': 0.33; 'header:User- Agent:1': 0.34; 'header:X-Complaints-To:1': 0.35; 'subject:skip:m 10': 0.37; 'received:org': 0.38; 'steven': 0.38; 'subject:: ': 0.39; 'enough': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'square': 0.67; 'exact': 0.68; 'increases': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Floating point multiplication in python Date: Wed, 07 Sep 2011 05:37:32 -0400 References: <2204592.egLE2XKegd@PointedEars.de> <4e66f843$0$29969$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 In-Reply-To: <4e66f843$0$29969$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315388323 news.xs4all.nl 2462 [2001:888:2000:d::a6]:42988 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12891 On 9/7/2011 12:51 AM, Steven D'Aprano wrote: > So given a float x, when you square it you get this: > > Exact values: a*a = a**2 > > Float values: x*x = (a+e)(a+e) > = a**2 + 2*a*e + e**2 > > So the error term has increased from e to (2*a*e+e**2). It is usual to > assume that e**2 is small enough that it underflows to zero, so we have the > error term e increasing to 2*a*e as a fairly simple estimate of the new > error. And the relative error, which is what is often important, increases from e/a to 2e/a. -- Terry Jan Reedy