From: Mark H Weaver <mhw@netris.org>
To: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: fix for expt bug
Date: Tue, 02 Nov 2010 15:19:03 -0400 [thread overview]
Message-ID: <87fwvjy1nc.fsf@yeeloong.netris.org> (raw)
In-Reply-To: <AANLkTim5SwwEtAArLdd5_BnoNAtQE79rrhLBBny=Ky1+@mail.gmail.com> (Ramakrishnan Muthukrishnan's message of "Tue, 2 Nov 2010 11:06:06 +0530")
Hi Ramakrishnan,
The code in your latest patch looks good to me, though the commit
message has some problems, and I'd add more test cases:
> * libguile/numbers.c: If base is negative, expt needs to find
> -x^n = (-1^n) * (|x|^n). We find x^n and then if n is odd, we
> also multiply the result with -1. These changes apply only for
> cases where n is an integer.
In the equation above, -x^n parses as -(x^n), but it should be (-x)^n.
Same problem with (-1^n). Also, the absolute value should be removed.
It is superfluous for the case you are handling (x>0), and for other
cases it is erroneous.
The equation above should be: (-x)^n = (-1)^n * x^n
Also, I would add a couple more test cases:
* Test the case from Ludovic's original bug report:
(expt -2742638075.5 2) should loosely equal
7.52206361318235e18
* Test that (expt -1 0.5) is loosely equal to +i.
(I believe this would have failed with your second patch)
Thanks,
Mark
next prev parent reply other threads:[~2010-11-02 19:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-31 18:12 fix for expt bug Ramakrishnan Muthukrishnan
2010-11-01 0:03 ` Mark H Weaver
2010-11-01 4:03 ` Ramakrishnan Muthukrishnan
2010-11-01 18:23 ` Ramakrishnan Muthukrishnan
2010-11-02 4:55 ` Mark H Weaver
2010-11-02 5:22 ` Ramakrishnan Muthukrishnan
2010-11-02 5:36 ` Ramakrishnan Muthukrishnan
2010-11-02 19:19 ` Mark H Weaver [this message]
2010-11-02 23:00 ` Ludovic Courtès
2010-11-03 2:10 ` Mark H Weaver
2010-11-03 9:41 ` Ramakrishnan Muthukrishnan
2010-11-03 15:32 ` Mark H Weaver
2010-11-03 16:41 ` Ramakrishnan Muthukrishnan
2010-11-03 16:22 ` Mark H Weaver
2010-11-03 17:53 ` Ramakrishnan Muthukrishnan
2010-11-03 18:25 ` Ramakrishnan Muthukrishnan
2010-11-03 23:27 ` Ludovic Courtès
2010-11-04 17:27 ` Mark H Weaver
2010-11-08 21:08 ` Ludovic Courtès
2010-11-20 21:49 ` Andy Wingo
2010-11-21 22:34 ` Ludovic Courtès
2010-11-05 2:18 ` [PATCH] Fix bugs in expt and integer-expt Mark H Weaver
2010-11-10 22:01 ` Ludovic Courtès
2011-01-20 22:47 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fwvjy1nc.fsf@yeeloong.netris.org \
--to=mhw@netris.org \
--cc=guile-devel@gnu.org \
--cc=vu3rdd@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).