public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Paul Zimmermann <Paul.Zimmermann@inria.fr>
To: andoni.arregui@gtd-gmbh.de
Cc: newlib@sourceware.org
Subject: Re: [PATCH 2/2] Add a missing default case in lgamma
Date: Thu, 10 Feb 2022 18:29:45 +0100	[thread overview]
Message-ID: <mwee4ad3zq.fsf@tomate.loria.fr> (raw)
In-Reply-To: <196bfdd68bf758c566a466e27dd9ded817a50b44.camel@gtd-gmbh.de> (message from Andoni Arregi on Thu, 10 Feb 2022 17:12:40 +0100)

       Dear Andoni,

unless I did a mistake, I still get the same error (7.50e+06 ulps)
than before this patch (after applying the other one), when I do an
exhaustive search on all binary32 inputs:

Using RedHat newlib
MPFR library: 4.1.0       
MPFR header:  4.1.0 (based on 4.1.0)
Checking function mylgammaf with MPFR_RNDN
libm wrong by up to 7.50e+06 ulp(s) [7497618] for x=-0x1.3a7fcap+1
mylgamma      gives -0x1p-24
mpfr_mylgamma gives -0x1.e4cf24p-24
Total: errors=509423944 (11.91%) errors2=11684280 maxerr=7.50e+06 ulp(s)

What result do you get for x=-0x1.3a7fcap+1?

Best regards,
Paul

> From: Andoni Arregi <andoni.arregui@gtd-gmbh.de>
> Date: Thu, 10 Feb 2022 17:12:40 +0100
> 
> The missing default case leads to large errors for |x| in range
> [2.0, 3.0[.
> In case of i=2, i.e., in the range between [2,3[, the computation
> "r += logf(z)" is not performed and hence the result was wrong.
> The added default case resolves this issue.
> (Courtesy of Andreas Jung, ESA)
> ---
>  newlib/libm/math/er_lgamma.c  | 1 +
>  newlib/libm/math/erf_lgamma.c | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/newlib/libm/math/er_lgamma.c b/newlib/libm/math/er_lgamma.c
> index 5c88548fb..65727c6ab 100644
> --- a/newlib/libm/math/er_lgamma.c
> +++ b/newlib/libm/math/er_lgamma.c
> @@ -302,6 +302,7 @@ static double zero=  0.00000000000000000000e+00;
>  	   case 5: z *= (y+4.0);	/* FALLTHRU */
>  	   case 4: z *= (y+3.0);	/* FALLTHRU */
>  	   case 3: z *= (y+2.0);	/* FALLTHRU */
> +      default:
>  		   r += __ieee754_log(z); break;
>  	   }
>      /* 8.0 <= x < 2**58 */
> diff --git a/newlib/libm/math/erf_lgamma.c b/newlib/libm/math/erf_lgamma.c
> index 84d02159b..e7311cacf 100644
> --- a/newlib/libm/math/erf_lgamma.c
> +++ b/newlib/libm/math/erf_lgamma.c
> @@ -238,6 +238,7 @@ static float zero=  0.0000000000e+00;
>  	   case 5: z *= (y+(float)4.0);	/* FALLTHRU */
>  	   case 4: z *= (y+(float)3.0);	/* FALLTHRU */
>  	   case 3: z *= (y+(float)2.0);	/* FALLTHRU */
> +      default:
>  		   r += __ieee754_logf(z); break;
>  	   }
>      /* 8.0 <= x < 2**58 */
> -- 
> 2.35.1

  reply	other threads:[~2022-02-10 17:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-05  6:38 regression in Newlib 4.2.0 (lgammaf) Paul Zimmermann
2022-02-09 16:28 ` [PATCH 1/2] Improve lgammaf range for very small cases Andoni Arregi
2022-02-10 14:58   ` Corinna Vinschen
2022-02-10 16:07     ` [PATCH 0/2] Fix lgammaf and lgamma for small ranges and in [2, 3[ Andoni Arregi
2022-02-10 16:10     ` [PATCH 1/2] Improve lgammaf range for very small cases Andoni Arregi
2022-02-10 16:21       ` Paul Zimmermann
2022-02-10 16:12     ` [PATCH 2/2] Add a missing default case in lgamma Andoni Arregi
2022-02-10 17:29       ` Paul Zimmermann [this message]
2022-02-11 11:14         ` Andoni Arregi
2022-02-10 16:16     ` [PATCH 1/2] Improve lgammaf range for very small cases Andoni Arregi
2022-02-11 11:19     ` Andoni Arregi
2022-02-09 16:30 ` [PATCH 2/2] Add a missing default case in lgamma Andoni Arregi
2022-02-09 16:49 ` regression in Newlib 4.2.0 (lgammaf) Andoni Arregi
2022-02-11 11:16 ` [PATCH] Improve lgammaf range for very small cases Andoni Arregi
2022-02-14 13:46   ` Corinna Vinschen

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=mwee4ad3zq.fsf@tomate.loria.fr \
    --to=paul.zimmermann@inria.fr \
    --cc=andoni.arregui@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).