From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14689 invoked by alias); 25 Feb 2012 16:06:45 -0000 Received: (qmail 14679 invoked by uid 22791); 25 Feb 2012 16:06:44 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 25 Feb 2012 16:06:25 +0000 From: "calixte.denizet@scilab-enterprises.com" To: glibc-bugs@sources.redhat.com Subject: [Bug math/706] pow() produces inaccurate results for base ~ 1.0, and large exponent on 32-bit x86 Date: Sat, 25 Feb 2012 16:06:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: math X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: calixte.denizet@scilab-enterprises.com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00471.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=706 --- Comment #9 from Calixte 2012-02-25 16:06:18 UTC --- Created attachment 6245 --> http://sourceware.org/bugzilla/attachment.cgi?id=6245 C code with a better algorithm Hi all, When the exponent is an integer, a fast exponentiation is used and when it is negative the base is inverted before (cf e_pow.S). So in this case the error induced by the inversion is cumulated in squaring several times. In the present case base=(2^53-1)*2^(-53), exponent=2^54 and 1/base=(2^52+1)*2^(-52), classical approximation shows that (1/base)^(2^54))~exp(4) and 1/(base^(2^54))~exp(2). So an easy way to avoid to cumulated error induced by inversion is to invert the result rather than invert the base. The attached code (in C) shows that clearly. I'm not able to fix the assembly code in e_pow.S, so I let experimented people do that. Thanks Calixte -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.