From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ramakrishnan Muthukrishnan Newsgroups: gmane.lisp.guile.devel Subject: Re: fix for expt bug Date: Mon, 1 Nov 2010 09:33:27 +0530 Message-ID: References: <8762whnc4d.fsf@yeeloong.netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1288584247 20675 80.91.229.12 (1 Nov 2010 04:04:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 1 Nov 2010 04:04:07 +0000 (UTC) Cc: guile-devel To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Nov 01 05:04:03 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PClcp-0008LM-9E for guile-devel@m.gmane.org; Mon, 01 Nov 2010 05:04:03 +0100 Original-Received: from localhost ([127.0.0.1]:45515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PClco-0007wX-6f for guile-devel@m.gmane.org; Mon, 01 Nov 2010 00:04:02 -0400 Original-Received: from [140.186.70.92] (port=39519 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PClch-0007wQ-9e for guile-devel@gnu.org; Mon, 01 Nov 2010 00:04:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PClcb-0004Te-VS for guile-devel@gnu.org; Mon, 01 Nov 2010 00:03:55 -0400 Original-Received: from mail-gx0-f169.google.com ([209.85.161.169]:34955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PClcb-0004Ta-Pj for guile-devel@gnu.org; Mon, 01 Nov 2010 00:03:49 -0400 Original-Received: by gxk2 with SMTP id 2so1829343gxk.0 for ; Sun, 31 Oct 2010 21:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=5EkOzPG3p4SGwzotXj9Mc+ULhY7By6h/KF4+rA+xgBg=; b=r9Vc5nDJEWmumxrY8TsA/XlrhbKQ2PQIvYZLIqmcSSogZpgdTlWKnrcyINd+gLAJJO 94SFmjp/gKr2X3FJCYuFos07viM8lkNWAJv1oNXZF8wq/9TPdSWMnXmCgT5Z4z+1+MeH 8LWiJsoQXuJkqpT3M7YPQjm1fnMY35QqdJygQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=qni8rYV5o2gJtTe/ablD7gXdupyQtg3hSYCajiUJRPNKmZWVtsx1+DpXDKvXLkzG6X 9wCfJwqEfT0U7WelFUvnpLhjYb3d9GoLgqI5MsM3DzQl0sCwC/m0aIree7Ifd8cTa7lX qskgdrR234HGDCFn3kYrM027bEOzvIRHW6ez8= Original-Received: by 10.229.183.8 with SMTP id ce8mr14521452qcb.288.1288584228988; Sun, 31 Oct 2010 21:03:48 -0700 (PDT) Original-Received: by 10.229.40.147 with HTTP; Sun, 31 Oct 2010 21:03:27 -0700 (PDT) In-Reply-To: <8762whnc4d.fsf@yeeloong.netris.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11095 Archived-At: On Mon, Nov 1, 2010 at 5:33 AM, Mark H Weaver wrote: > Ramakrishnan, > > Your fix is incorrect. =C2=A0You have assumed that (-a)^b =3D -(a^b), Mark, Yes, you are right. Not sure what I was thinking when I made the patch. :-( > The reported bug is simply due to roundoff error. =C2=A0You must know > something about complex numbers and specifically complex exponentials to > understand what's happening here. =C2=A0The spurious imaginary part is > actually quite miniscule compared with the real part. =C2=A0If one looks = at > these results in polar form, the complex argument (angle) should ideally > be an exact zero, but is instead an inexact number very close to 0 > (about 2.45e-16 radians in this case). > > The most straightforward solution to this bug is to support a few > special cases, such as: > > =C2=A0(-a)^b =3D -(a^b) =C2=A0 (where a is positive real and b is an odd = integer) > =C2=A0(-a)^b =3D =C2=A0 a^b =C2=A0 =C2=A0(where a is positive real and b = is an even integer) Thanks. I will take a dig at doing this solution. --=20 =C2=A0 Ramakrishnan