From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 075DC1F5AE for ; Tue, 28 Jul 2020 10:50:31 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1981E3865488; Tue, 28 Jul 2020 10:50:30 +0000 (GMT) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sourceware.org (Postfix) with ESMTPS id 246EC385702E for ; Tue, 28 Jul 2020 10:50:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 246EC385702E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=inria.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Paul.Zimmermann@inria.fr X-IronPort-AV: E=Sophos;i="5.75,406,1589234400"; d="scan'208";a="461618978" Received: from tomate.loria.fr (HELO tomate) ([152.81.10.51]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jul 2020 12:50:20 +0200 Date: Tue, 28 Jul 2020 12:50:20 +0200 Message-Id: From: Paul Zimmermann To: Andreas Schwab In-reply-to: <87wo2oxahr.fsf@igel.home> (message from Andreas Schwab on Tue, 28 Jul 2020 11:19:28 +0200) Subject: Re: fix inaccuracy of j0f for x >= 2^127 when sin(x)+cos(x) is tiny References: <87wo2oxahr.fsf@igel.home> X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libc-alpha@sourceware.org, joseph@codesourcery.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Dear Andreas, yes thanks. Sorry my english is not perfect. Paul >From 6b731f36b1a5badf4704645d0dda40957cedd0db Mon Sep 17 00:00:00 2001 From: Paul Zimmermann Date: Mon, 27 Jul 2020 19:01:18 +0200 Subject: [PATCH 1/3] fix inaccuracy of j0f for x >= 2^127 when sin(x)+cos(x) is tiny --- sysdeps/ieee754/flt-32/e_j0f.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sysdeps/ieee754/flt-32/e_j0f.c b/sysdeps/ieee754/flt-32/e_j0f.c index c89b9f2688..f85d8a59e0 100644 --- a/sysdeps/ieee754/flt-32/e_j0f.c +++ b/sysdeps/ieee754/flt-32/e_j0f.c @@ -56,6 +56,22 @@ __ieee754_j0f(float x) if ((s*c)From 44124c42fe519c7dcac829160181ba0bb6c8751c Mon Sep 17 00:00:00 2001 From: Paul Zimmermann Date: Tue, 28 Jul 2020 10:05:38 +0200 Subject: [PATCH 2/3] use hex float constants as advised by Joseph Myers --- sysdeps/ieee754/flt-32/e_j0f.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdeps/ieee754/flt-32/e_j0f.c b/sysdeps/ieee754/flt-32/e_j0f.c index f85d8a59e0..883a1a4d13 100644 --- a/sysdeps/ieee754/flt-32/e_j0f.c +++ b/sysdeps/ieee754/flt-32/e_j0f.c @@ -61,15 +61,15 @@ __ieee754_j0f(float x) is very near from 0, and use the identity sin(x-x0) = sin(x)*cos(x0)-cos(x)*sin(x0) to get sin(x) + cos(x) with extra accuracy */ - float x0 = 3.153646966e+38f; + float x0 = 0xe.d4108p+124f; float y = x - x0; /* exact */ /* sin(y) = sin(x)*cos(x0)-cos(x)*sin(x0) */ z = __sinf (y); - float eps = 8.17583368e-8f; + float eps = 0x1.5f263ep-24f; /* cos(x0) ~ -sin(x0) + eps */ z += eps * __cosf (x); /* now z ~ (sin(x)-cos(x))*cos(x0) */ - float cosx0 = -0.707106740f; + float cosx0 = -0xb.504f3p-4f; cc = z / cosx0; } /* -- 2.27.0 >From 409781259c5d150ec62079e608ea94b520eafa58 Mon Sep 17 00:00:00 2001 From: Paul Zimmermann Date: Tue, 28 Jul 2020 12:47:31 +0200 Subject: [PATCH 3/3] fixed typo (thanks Andreas Schwab) --- sysdeps/ieee754/flt-32/e_j0f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/ieee754/flt-32/e_j0f.c b/sysdeps/ieee754/flt-32/e_j0f.c index 883a1a4d13..66249d2812 100644 --- a/sysdeps/ieee754/flt-32/e_j0f.c +++ b/sysdeps/ieee754/flt-32/e_j0f.c @@ -58,7 +58,7 @@ __ieee754_j0f(float x) } else { /* we subtract (exactly) a value x0 such that cos(x0)+sin(x0) - is very near from 0, and use the identity + is very near to 0, and use the identity sin(x-x0) = sin(x)*cos(x0)-cos(x)*sin(x0) to get sin(x) + cos(x) with extra accuracy */ float x0 = 0xe.d4108p+124f; -- 2.27.0 > From: Andreas Schwab > Date: Tue, 28 Jul 2020 11:19:28 +0200 > > On Jul 28 2020, Paul Zimmermann wrote: > > > + /* we subtract (exactly) a value x0 such that cos(x0)+sin(x0) > > + is very near from 0, and use the identity > > Did you mean "near to"? > > Andreas. > > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 > "And now for something completely different."