Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Before Xerox, five carbons were the maximum extension of anybody's ego.


devel / comp.lang.python / RE: Precision Tail-off?

RE: Precision Tail-off?

<mailman.1849.1676656018.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21723&group=comp.lang.python#21723

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From:
Newsgroups: comp.lang.python
Subject: RE: Precision Tail-off?
Date: Fri, 17 Feb 2023 12:46:52 -0500
Lines: 197
Message-ID: <mailman.1849.1676656018.20444.python-list@python.org>
References: <CAP=-cKVbQ6yj_QuwykJ_WifJfnSggowPDwYtnfvQ6FyF2w5b_g@mail.gmail.com>
<CAHVvXxTFqgurjCHHDpBRU_bGJ3fzXB=p7NY0tiGSJv5ng=fYkg@mail.gmail.com>
<mailman.1817.1676373454.20444.python-list@python.org>
<k57132F3e1U1@mid.individual.net>
<CAP=-cKVgqutG=GufPYA4+4Frzcma9g_A9t+hDNf1S39C53PyGg@mail.gmail.com>
<001a01d942f7$d1ff38e0$75fdaaa0$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de rvn5GyxWsJmAcETOfjeLSQkeLEdkzt0HpuEJMhAeOikA==
Return-Path: <avi.e.gross@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=WcPgIkd5;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '17,': 0.04; 'absolute':
0.05; 'fairly': 0.05; '2023': 0.07; 'all!': 0.07; 'cpu': 0.07;
'string': 0.07; 'suggestion': 0.07; 'byte': 0.09; 'comparison':
0.09; 'computing': 0.09; 'effectively': 0.09; 'float': 0.09;
'floating': 0.09; 'idle': 0.09; 'infinite': 0.09; 'language,':
0.09; 'meant': 0.09; 'methods,': 0.09; 'operators': 0.09;
'realistic': 0.09; 'received:108': 0.09; 'received:209.85.219':
0.09; 'shift': 0.09; 'spanish': 0.09; 'supplied': 0.09;
'terminal': 0.09; 'steps': 0.11; 'log': 0.12; 'url:mailman': 0.15;
'memory': 0.15; 'supported': 0.15; '(1.0': 0.16; '(yes': 0.16;
'[snip]': 0.16; 'arguments': 0.16; 'arithmetic': 0.16; 'base.':
0.16; 'behaviour': 0.16; 'bits': 0.16; 'calculations': 0.16;
'char': 0.16; 'decimal': 0.16; 'division': 0.16; 'efficiently.':
0.16; 'gigantic': 0.16; 'indeed': 0.16; 'integer': 0.16;
'integer,': 0.16; 'iso': 0.16; 'linearly': 0.16; 'mathematical':
0.16; 'measure,': 0.16; 'ones.': 0.16; 'planet': 0.16; 'primes.':
0.16; 'relatively': 0.16; 'somewhat': 0.16; 'standard,': 0.16;
'standards,': 0.16; 'things,': 0.16; 'together?': 0.16; 'wrote:':
0.16; 'python': 0.16; 'larger': 0.17; 'feb': 0.17; 'probably':
0.17; 'message-id:@gmail.com': 0.18; 'solve': 0.19; 'uses': 0.19;
'16,': 0.19; 'hardware': 0.19; 'thu,': 0.19; 'tue,': 0.19;
'to:addr:python-list': 0.20; 'all,': 0.20; 'language': 0.21;
'languages': 0.22; 'focused': 0.22; 'purposes': 0.22; 'teach':
0.22; 'version': 0.23; 'skip:- 10': 0.25; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'programming': 0.25; 'url-ip:188.166/16':
0.25; 'space': 0.26; 'brought': 0.26; 'friday,': 0.26; 'leave':
0.27; 'old': 0.27; 'done': 0.28; '>>>': 0.28; 'expect': 0.28;
'computer': 0.29; 'it,': 0.29; 'error': 0.29; 'approach': 0.31;
'url-ip:188/8': 0.31; 'result,': 0.69; 'skip:1 40': 0.69;
'standards': 0.69; 'types,': 0.69; 'times': 0.69; 'within': 0.69;
'solutions': 0.70; 'you.': 0.71; 'knowing': 0.71; 'attention':
0.71; 'addition': 0.71; 'relevant': 0.73; 'skip:4 10': 0.75;
'features': 0.75; 'near': 0.76; 'features.': 0.76; 'languages,':
0.76; 'limits': 0.76; 'star': 0.76; 'vary': 0.76; 'yes': 0.76;
'sent:': 0.78; 'field': 0.78; 'significant': 0.78; 'happens':
0.84; 'practical': 0.84; 'again:': 0.84; 'asian': 0.84; 'billion':
0.84; 'billions': 0.84; 'body)': 0.84; 'deficiency': 0.84;
'diameter': 0.84; 'measurement': 0.84; 'oscar': 0.84; 'stressed':
0.84; 'striving': 0.84; 'type.': 0.84; 'consisting': 0.91;
'doing.': 0.91; 'flexible': 0.91; 'holds': 0.91; 'largely': 0.91;
'retain': 0.91; 'tend': 0.91; 'yours.': 0.91; 'unlimited': 0.93;
'agreed': 0.95; 'storage': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=GN7map6KGiCy5OPgGNWEZUlAkPLVMbLflnl76Oc4m0c=;
b=WcPgIkd52tJyRjtD6NgOfm0lDQmEXlyf54mkRj3HezEU+5C5x20qQDyVd/cnQAPakR
n88CBzey8vFGu2C5KJtzh7JZGUMiaIT9ry2jQsx+4S0gcWGLLff1kRW1lAXutME7sBjT
Yp4g2Tjhgb2czSlHK4zsrRAfTivnHdPEFGW5om6yNGn2vIlHmN7JWNqRpySpQpS/7PcV
vlLCROazyzPzDdH5gJ9gkPMxzMrgRFCBnPdJdWLsHpK1/sOt0QJmm3jlqgypw/iO6OGZ
De8sdh7udEJLh2sW+Id9EJZLQdi0sqC5rBSESnhLuzO4usX8nabZ9TtRsLsYxDEZHYaR
iBUQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=GN7map6KGiCy5OPgGNWEZUlAkPLVMbLflnl76Oc4m0c=;
b=xL5YZYAo0XNEJ5YuunmLR5GjlYBCPWdrQWMN/zZdWGW1Y99uXqEFD/YaCBMeIczxFD
/8A33V23iK+b7uYnEpKPN2pbMR4P3O0UUPjJO8sCVYWyh8zUlf90A4xLpWyOjvXGa2fX
4r2mJKWnsRdTlE/VmNCqcmIj+4b1PTEVuk1X2PH1u0x9RB/9kx4MciZHu5+eRhYKk6m/
P4YT2mWu8av09i+hHKbpjxJqqQYUIZ/skLJ6ISznlV70l9OKSlr7j8Aa/DNNZ7YK5k0l
ynb5iEuIuQ5hNZw8oFyGq/2Df8xrAtOj6664RbUCuQR+m44Fw3+twFFdvZvEvGP+Ol9X
M9Ww==
X-Gm-Message-State: AO0yUKXY3G6MejdZP6b8c8ecX99Ir4OCyOOFX8RoxYCofAJDIlR1es/3
7HHQoPC5rb2PyG2HRaxhELgSd/F8Eto=
X-Google-Smtp-Source: AK7set9StE5JKl17AJuzqe4BNcdzBl5yIFUqeiPku91Htj0T2vlQdQzQGOVTI+ApJybBv8/ZvgiV9w==
X-Received: by 2002:a05:6214:d62:b0:56e:a0eb:9b28 with SMTP id
2-20020a0562140d6200b0056ea0eb9b28mr2444042qvs.3.1676656015598;
Fri, 17 Feb 2023 09:46:55 -0800 (PST)
In-Reply-To: <CAP=-cKVgqutG=GufPYA4+4Frzcma9g_A9t+hDNf1S39C53PyGg@mail.gmail.com>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQH6ec1uYweKrVEFuuZGJT6ZdsxNQwJvfpEQAoJ30ewBOPwa6QEZlbdUrlbK+bA=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <001a01d942f7$d1ff38e0$75fdaaa0$@gmail.com>
X-Mailman-Original-References: <CAP=-cKVbQ6yj_QuwykJ_WifJfnSggowPDwYtnfvQ6FyF2w5b_g@mail.gmail.com>
<CAHVvXxTFqgurjCHHDpBRU_bGJ3fzXB=p7NY0tiGSJv5ng=fYkg@mail.gmail.com>
<mailman.1817.1676373454.20444.python-list@python.org>
<k57132F3e1U1@mid.individual.net>
<CAP=-cKVgqutG=GufPYA4+4Frzcma9g_A9t+hDNf1S39C53PyGg@mail.gmail.com>
 by: - Fri, 17 Feb 2023 17:46 UTC

Stephen,

What response do you expect from whatever people in the IEEE you want?

The specific IEEE standards were designed and agreed upon by groups working
in caveman times when the memory and CPU time were not so plentiful. The
design of many types, including floating point, had to work decently if not
perfectly so you stored data in ways the hardware of the time could process
it efficiently.

Note all kinds of related issues about what happens if you want an integer
larger than fits into 16 bits or 32 bits or even 64 bits. A Python integer
was designed to be effectively unlimited and uses as much storage as needed.
It can also get ever slower when doing things like looking for gigantic
primes. But it does not have overflow problems.

So could you design a floating point data type with similar features? It
would be some complex data structure that keeps track of the number of
bit/bytes/megabytes currently being used to store the mantissa or exponent
parts and then have some data structure that holds all the bits needed. When
doing any arithmetic like addition or division or more complex things, it
would need to compare the two objects being combined and calculate how to
perhaps expand/convert one to match the other and then do umpteen steps to
generate the result in as many pieces/steps as needed and create a data
structure that holds the result, optionally trimming off terminal parts not
needed or wanted. Then you would need all relevant functions that accept
regular floating point to handle these numbers and generate these numbers.

Can that be done well? Well, sure, but not necessarily WELL. Some would
point you to the Decimal type. It might take a somewhat different tack on
how to do this. But everything comes with a cost.

Perhaps the response from the IEEE would be that what they published was
meant for some purposes but not yours. It may be that a group needs to
formulate a new standard but leave the old ones in place for people willing
to use them as their needs are more modest.

As an analogy, consider the lowly char that stored a single character in a
byte. II mean good old ASCII but also EBCDIC and the ISO family like ISO
8859-1 and so on. Those standards focused in on the needs of just a few
languages and if you wanted to write something in a mix of languages, it
could be a headache as I have had time I had to shift within one document to
say ISO 8859-8 to include some Hebrew, and ISO 8859-3 for Esperanto and so
on while ISO8859-1 was fine for English, French, German, Spanish and many
others. For some purposes, I had to use encodings like shift JIS to do
Japanese as many Asian languages were outside what ISO was doing.

The solutions since then vary but tend to allow or require multiple bytes
per character. But they retain limits and if we ever enter a Star Trek
Universe with infinite diversity and more languages and encodings, we might
need to again enlarge our viewpoint and perhaps be even more wasteful of our
computing resources to accommodate them all!

Standards are often not made to solve ALL possible problems but to make
clear what is supported and what is not required. Mathematical arguments can
be helpful but practical considerations and the limited time available (as
these darn things can take YEARS to be agreed on) are often dominant.
Frankly, by the tie many standards, such as for a programming language, are
finalized, the reality in the field has often changed. The language may
already have been supplanted largely by others for new work, or souped up
with not-yet-standard features.

I am not against striving for ever better standards and realities. But I do
think a better way to approach this is not to reproach what was done but ask
if we can focus on the near-future and make it better.

Arguably, there are now multiple features out there such as Decimal and they
may be quite different. That often happens without a standard. But if you
now want everyone to get together and define a new standard that may break
some implementations, ...

As I see it, many computer courses teach the realities as well as the
mathematical fantasies that break down in the real world. One of those that
tend to be stressed is that floating point is not exact and that comparison
operators need to be used with caution. Often the suggestion is to subtract
one number from another and check if the result is fairly close to zero as
in the absolute value is less than an IEEE standard number where the last
few bits are ones. For more complex calculations where the errors can
accumulate, you may need to choose a small number with more such bits near
the end.

Extended precision arithmetic is perhaps cheaper now and can be done for a
reasonable number of digits. It probably is not realistic to do most such
calculations for billions of digits, albeit some of the calculations for the
first googolplex digits of pi might indeed need such methods, as soon as we
fin a way to keep that many digits in memory give the ten to the 80th or so
particles we think are in our observable universe. But knowing pi to that
precision may not be meaningful if an existing value already is so precise
that given an exact number for the diameter of something the size of the
universe (Yes, I know this is nonsense) you could calculate the
circumference (ditto) to less than the size (ditto) of a proton. Any errors
in such a measurement would be swamped by all kinds of things such as
uncertainties in what we can measure, or niggling details about how space
expands irregularly in the area as we speak and so on.

So if you want a new IEEE (or other such body) standard, would you be
satisfied with a new one for say a 16,384 byte monstrosity that holds
gigantic numbers with lots more precision, or hold out for a relatively
flexible and unlimited version that can be expanded until your computer or
planet runs out of storage room and provides answers after a few billion
years when used to just add two of them together?

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Stephen Tucker
Sent: Friday, February 17, 2023 5:27 AM
To: python-list@python.org
Subject: Re: Precision Tail-off?

Thanks, one and all, for your reponses.

This is a hugely controversial claim, I know, but I would consider this
behaviour to be a serious deficiency in the IEEE standard.

Consider an integer N consisting of a finitely-long string of digits in base
10.

Consider the infinitely-precise cube root of N (yes I know that it could
never be computed unless N is the cube of an integer, but this is a
mathematical argument, not a computational one), also in base 10. Let's call
it RootN.

Now consider appending three zeroes to the right-hand end of N (let's call
it NZZZ) and NZZZ's infinitely-precise cube root (RootNZZZ).

The *only *difference between RootN and RootNZZZ is that the decimal point
in RootNZZZ is one place further to the right than the decimal point in
RootN.

None of the digits in RootNZZZ's string should be different from the
corresponding digits in RootN.

I rest my case.

Perhaps this observation should be brought to the attention of the IEEE. I
would like to know their response to it.

Stephen Tucker.

On Thu, Feb 16, 2023 at 6:49 PM Peter Pearson <pkpearson@nowhere.invalid>
wrote:

> On Tue, 14 Feb 2023 11:17:20 +0000, Oscar Benjamin wrote:
> > On Tue, 14 Feb 2023 at 07:12, Stephen Tucker
> > <stephen_tucker@sil.org>
> wrote:
> [snip]
> >> I have just produced the following log in IDLE (admittedly, in
> >> Python
> >> 2.7.10 and, yes I know that it has been superseded).
> >>
> >> It appears to show a precision tail-off as the supplied float gets
> bigger.
> [snip]
> >>
> >> For your information, the first 20 significant figures of the cube
> >> root
> in
> >> question are:
> >> 49793385921817447440
> >>
> >> Stephen Tucker.
> >> ----------------------------------------------
> >> >>> 123.456789 ** (1.0 / 3.0)
> >> 4.979338592181744
> >> >>> 123456789000000000000000000000000000000000. ** (1.0 / 3.0)
> >> 49793385921817.36
> >
> > You need to be aware that 1.0/3.0 is a float that is not exactly
> > equal to 1/3 ...
> [snip]
> > SymPy again:
> >
> > In [37]: a, x = symbols('a, x')
> >
> > In [38]: print(series(a**x, x, Rational(1, 3), 2))
> > a**(1/3) + a**(1/3)*(x - 1/3)*log(a) + O((x - 1/3)**2, (x, 1/3))
> >
> > You can see that the leading relative error term from x being not
> > quite equal to 1/3 is proportional to the log of the base. You
> > should expect this difference to grow approximately linearly as you
> > keep adding more zeros in the base.
>
> Marvelous. Thank you.
>
>
> --
> To email me, substitute nowhere->runbox, invalid->com.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list

SubjectRepliesAuthor
o Re: Precision Tail-off?

By: Oscar Benjamin on Tue, 14 Feb 2023

23Oscar Benjamin
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor