From: Paul Zimmermann <Paul.Zimmermann@inria.fr>
To: Fabian Schriever <fabian.schriever@gtd-gmbh.de>
Cc: newlib@sourceware.org
Subject: Re: [PATCH] Fix error in powf for x close to 1 and large y
Date: Fri, 11 Dec 2020 18:02:47 +0100 [thread overview]
Message-ID: <mwmtyk1djc.fsf@tomate.loria.fr> (raw)
In-Reply-To: <20201211155735.2645-1-fabian.schriever@gtd-gmbh.de> (message from Fabian Schriever on Fri, 11 Dec 2020 16:57:35 +0100)
Dear Fabian,
that was fast! Thank you very much.
Paul
> From: Fabian Schriever <fabian.schriever@gtd-gmbh.de>
> Date: Fri, 11 Dec 2020 16:57:35 +0100
>
> This patch fixes the error found by Paul Zimmermann (see
> https://homepages.loria.fr/PZimmermann/papers/#accuracy) regarding x
> close to 1 and rather large y (specifically he found the case
> powf(0x1.ffffeep-1,-0x1.000002p+27) which returns +Inf instead of the
> correct value). We found 2 more values for x which show the same faulty
> behaviour, and all 3 are fixed with this patch. We have tested all
> combinations for x in [+1.fffdfp-1, +1.00020p+0] and y in
> [-1.000007p+27, -1.000002p+27] and [1.000002p+27,1.000007p+27].
> ---
> newlib/libm/math/ef_pow.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/newlib/libm/math/ef_pow.c b/newlib/libm/math/ef_pow.c
> index e3579f071..07b225f8c 100644
> --- a/newlib/libm/math/ef_pow.c
> +++ b/newlib/libm/math/ef_pow.c
> @@ -138,7 +138,7 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
> /* |y| is huge */
> if(iy>0x4d000000) { /* if |y| > 2**27 */
> /* over/underflow if x is not close to one */
> - if(ix<0x3f7ffff8) return (hy<0)? __math_oflowf(0):__math_uflowf(0);
> + if(ix<0x3f7ffff4) return (hy<0)? __math_oflowf(0):__math_uflowf(0);
> if(ix>0x3f800007) return (hy>0)? __math_oflowf(0):__math_uflowf(0);
> /* now |1-x| is tiny <= 2**-20, suffice to compute
> log(x) by x-x^2/2+x^3/3-x^4/4 */
> --
> 2.26.1.windows.1
>
next prev parent reply other threads:[~2020-12-11 17:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 5:51 huge powf error Paul Zimmermann
2020-12-11 15:57 ` [PATCH] Fix error in powf for x close to 1 and large y Fabian Schriever
2020-12-11 17:02 ` Paul Zimmermann [this message]
2020-12-11 21:02 ` Jeff Johnston
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mwmtyk1djc.fsf@tomate.loria.fr \
--to=paul.zimmermann@inria.fr \
--cc=fabian.schriever@gtd-gmbh.de \
--cc=newlib@sourceware.org \
/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).