From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30278 invoked from network); 10 Mar 2022 17:36:52 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 10 Mar 2022 17:36:52 -0000 Received: (qmail 9378 invoked by uid 550); 10 Mar 2022 17:36:50 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 9340 invoked from network); 10 Mar 2022 17:36:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Ok+YoiWbA68TUQw39AwRSJsTZZGZ2n9U+jWatnkbeMU=; b=WKYz3WKJnu9DJ/4Jdw2ST1YyjOJozfVSM769wDH/jGP7mln24wvqy+7ZL9qpOU5Lbf f92GPgTNtbCQ+XUB+0bWA7onP1yFPcAPPwglJSrdK8TgYXZQln51P4WCLNJoJ8gVqI/F lN0lMrO6rOgGucdzuSfMCpogz9jcAzDTDicbu/9wWoNkJsYeOqHdfTv7KDf/JX7LG4Qk Hlk7vFeDXoaESTCXubBrs198AxamI7y/BUxGAXi2kmA/fUkhCcs73Y8QWV4lPXxFUbB+ Ctcr3vlqv0AWcwj3ZqXqHov3fN4DCwF1Cf/dlkdk3eXgP3ZwLX9psYJUBUSrAY1lH16X t9SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Ok+YoiWbA68TUQw39AwRSJsTZZGZ2n9U+jWatnkbeMU=; b=LzRwAv4kQjFQoZeYLYqvT/6Xld9UZ2lWPT464NjEwU9NvD9F5pVorzIz2ZxqS59nL6 jjda0g5UKkCv17/cwUJP0l7SjrLsm2vRcHdvghhctk3n+Vw55azC9DQtj7pFeQAHwD10 N5jl8g6orMyHsyMx6d17k8ZY+9ql26EXBbWH81LpjoiDu/a46quj5f74a9E+pBHHDHtO qzHKN35VU+vEWF4z0K8kyDzJ2X0N2XGxzFN+sSHzKlbv3dWDfufrf4sUICoBHl7SvWMZ BanEzd5RRpGtsbC1ii9y2KmOtvRm72/iRSmeQF9zt6fNFep4LI2sgierHMt7RaHocMR+ xlHQ== X-Gm-Message-State: AOAM530bOJ4WT/8nxoS/b4s2XK/j9MHD7m4t462f2VKyGmT6cw7yDF3v S0/0xhIkcmZw3VA2JEm56hQg1EzSi3twh2P7Sdo= X-Google-Smtp-Source: ABdhPJxoKmxhDsgAY3o4anHd541jgKzu7GtarUekUs4aT2tkju9uLwj+yCxlzSFbbNtUhph4mfGwCQTXy71K+B9k84M= X-Received: by 2002:aca:eb58:0:b0:2d9:deea:2014 with SMTP id j85-20020acaeb58000000b002d9deea2014mr10069397oih.83.1646933796759; Thu, 10 Mar 2022 09:36:36 -0800 (PST) MIME-Version: 1.0 References: <20220310170531.GV7074@brightrain.aerifal.cx> In-Reply-To: <20220310170531.GV7074@brightrain.aerifal.cx> From: Norbert Lange Date: Thu, 10 Mar 2022 18:36:25 +0100 Message-ID: To: Rich Felker Cc: musl@lists.openwall.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] asinf pulls in sqrt (double version) Am Do., 10. M=C3=A4rz 2022 um 18:05 Uhr schrieb Rich Felker : > > On Thu, Mar 10, 2022 at 04:44:37PM +0100, Norbert Lange wrote: > > Hello, > > > > pulled some of the math routines for a float-only project, > > what I found is that asinf pulls in sqrt, and I cant tell whether this > > is necessary because of precision. > > > > The line is in src/math/asinf.c: > > s =3D sqrt(z); > > It looks like it's intentional -- s has type double and is used in an > expression where the additional precision would make a difference: > > x =3D pio2 - 2*(s+s*R(z)); > > I suspect it would be more work (and slower) to get suitable precision > without the double intermediate here, but I have not done the analysis > myself. the extended precision is necessary *if* "2*(s+s*R(z))" is close to pio2, *or* s is close to -1 * s*R(z), so that it would cancel out several of the highest bits. Given that this block results in 1 > |x| >=3D 0.5, which is atleast 0.5 away from pio2 and 0, my gut tells me that this is not the case. So my argument would be that sqrtf might be viable without affecting the result at all or more than one ulp. I know that this doesn't mean much without a proof. Any hints where the algorithm is coming from? Norbert