Deutsch   English   Français   Italiano  
<v13ao2$bv87$1@solani.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Michael S <already5chosen@yahoo.com>
Newsgroups: comp.lang.c,comp.arch
Subject: Re: Radians Or Degrees?
Date: Sun, 17 Mar 2024 11:34:58 +0200
Organization: A noiseless patient Spider
Lines: 102
Message-ID: <20240317113458.00000021@yahoo.com>
References: <ur5trn$3d64t$1@dont-email.me>
	<ur5v05$3ccut$1@dont-email.me>
	<20240222015920.00000260@yahoo.com>
	<ur69j9$3ftgj$3@dont-email.me>
	<ur86eg$1aip$1@dont-email.me>
	<ur88e4$1rr1$5@dont-email.me>
	<ur8a2p$2446$1@dont-email.me>
	<ur8ctk$2vbd$2@dont-email.me>
	<20240222233838.0000572f@yahoo.com>
	<3b2e86cdb0ee8785b4405ab10871c5ca@www.novabbs.org>
	<ur8nud$4n1r$1@dont-email.me>
	<936a852388e7e4414cb7e529da7095ea@www.novabbs.org>
	<ur9qtp$fnm9$1@dont-email.me>
	<20240314112655.000011f8@yahoo.com>
	<ut17ji$27n6b$1@dont-email.me>
	<ut2csb$2fe4u$1@dont-email.me>
	<87wmq32o26.fsf@nosuchdomain.example.com>
	<8de6385435bbdb0695a7ff213653f345@www.novabbs.org>
	<20240316190815.000005a2@yahoo.com>
	<dbfb682bf2abb9b84ce04c257a85c6d1@www.novabbs.org>
	<87o7bd3guo.fsf@nosuchdomain.example.com>
	<20240317110621.00005b30@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: dont-email.me; posting-host="fd62a22e31fcf9828d4eedf77229489a";
	logging-data="3610420"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19nnFf5o+TJsQXfdAikDtMpnDIAFIwgJB8="
Cancel-Lock: sha1:zqKqb1pbo5JT43IdV7B5LxlA/uw=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
Bytes: 5164

On Sun, 17 Mar 2024 11:06:21 +0200
Michael S <already5chosen@yahoo.com> wrote:

> On Sat, 16 Mar 2024 16:19:11 -0700
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>=20
> > mitchalsup@aol.com (MitchAlsup1) writes: =20
> > > Michael S wrote:   =20
> > >> On Sat, 16 Mar 2024 01:16:25 +0000
> > >> mitchalsup@aol.com (MitchAlsup1) wrote:   =20
> > >>> Keith Thompson wrote:   =20
> > >>> > I can see how computing sin(x) with high precision for
> > >>> > "reasonable" values of x would be useful, but does any of that
> > >>> > benefit from being able to compute sin(2^53) accurately?   =20
> > >>> Because accurate argument reduction reduces the burden on the
> > >>> programmer to remain within his sandbox.   =20
> > >   =20
> > >> Not really.   =20
> > >
> > > Say you are a programmer and you receive a value like 2^53 from an
> > > Input read and you wan the most accurate possible SIN( of that ).
> > >   =20
> >=20
> > I can't think of a scenario where that would be useful (other than
> > just doing it for the sake of doing it).
> >=20
> > If 2^53 represents a physical quantity, how likely is the actual
> > value to be known within =C2=B1=CF=80 (+/i pi for those who prefer ASCI=
I)?
> >=20
> > If you can get better precision without too much extra cost, that's
> > great.  I don't know enough to have an opinion about what the best
> > tradeoff is, but I presume it's going to be different depending on
> > the application.
> >=20
> > Here's a C program that shows how precise sin(2^53) can be for types
> > float, double, and long double (I used gcc and glibc).  The
> > nextafter functions are used to compute the nearest representable
> > number.  For long double, the value of sin() changes by about 1
> > part in 1600, which seems decent, but it's not nearly as precise as
> > for values around 1.0. For float and double, the imprecision of the
> > argument is enough to make the result practically meaningless.
> >=20

<snip>

> >  =20
>=20
> As written, your example does not emphasize that the problem has
> nothing to do with implementation of sinX() library routine.
> It's best illustrated by followup conversation with bart, IMHO 100%
> O.T.
> To make the point more clear I'd rather change it to following form:
>=20
<snip>
>=20


BTW, personally I'd prefer to illustrate futility of Payne-Hanek or
equivalent reduction with following example:

#include <math.h>
#include <stdio.h>
#include <limits.h>
#include <float.h>

void foo(long double x)
{
  const double y =3D (double)sinl(x);
  printf("%.20Le %25.16La %.17f\n", x, x, y);
}

int main(void) {
  const float a0 =3D 0x1p56;
  const float b0 =3D 11;
  {
    printf("%-12s (%3zu bits, %d mantissa bits) ",
     "float", CHAR_BIT * sizeof (float), FLT_MANT_DIG);=20
    const float a =3D a0;
    const float b =3D b0;
    const float x =3D a / b;
    foo(x);
  }
  {
    printf("%-12s (%3zu bits, %d mantissa bits) ",=20
     "double", CHAR_BIT * sizeof (double), DBL_MANT_DIG);=20
    const double a =3D a0;
    const double b =3D b0;
    const double x =3D a / b;
    foo(x);
  }
  {
    printf("%-12s (%3zu bits, %d mantissa bits) ",
     "long double", CHAR_BIT * sizeof (long double), LDBL_MANT_DIG);
    const long double a =3D a0;=20
    const long double b =3D b0;
    const long double x =3D a / b;
    foo(x);
  }
}