What exactly is "exact" (was Clean Singleton Docstrings)
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Jul 18 05:29:42 EDT 2016
On Monday 18 July 2016 14:16, Rustom Mody wrote:
> On Saturday, July 16, 2016 at 3:16:48 PM UTC+5:30, Steven D'Aprano wrote:
>> But that's *wrong*. Numbers are never inexact. (You can have interval
>> arithmetic using "fuzzy numbers", but they're ALWAYS inexact.) It is
>> calculations which are exact or inexact, not numbers. There's no a priori
>> reason to expect that 0.499999 is "inexact" while 0.5 is "exact", you need
>> to know the calculation that generated it:
>
> Heh! Did you check what scheme has to say about this before holding forth?
> I suggest a tool called google. It can make one seem profound
Emphasis on the "seem" rather than "actually be" *wink*
> Here are the first couple of hits it gives (me) for “scheme exact number”
[...]
> | The motivation for this behavior is that the inexactness of a number
> | should not be lost silently.
I appreciate the motivation, but I don't think the Scheme, er, scheme is well-
thought out or meaningful. "Exact" or "inexact" is too blunt an instrument to
be of much use. If you do a bunch of calculations, and get a result of 1.0, all
that tells you is that the "true" (i.e. infinitely precise) value is something
possibly centered at 1 with an unknown, not necessarily small, error.
So now you know that *at least one* calculation was inexact, but not which
ones, or the magnitude of the errors introduced.
The Scheme system is effectively the same as a really poor interval arithmetic
system, where numbers can be recorded in two forms:
x ± 0 # exact
x ± ∞ # inexact
and nothing in between.
> AIUI…
> There are two almost completely unrelated notions of exact
>
> 1. ⅓ in decimal cannot be exactly represented though 0.3 0.33 etc are
> approximations.
> We could call these inexact forms of ⅓
But 0.3 is an exact representation of 3/10, 0.1 + 0.2, 0.6/2, etc.
> 2. Measurement and observation produces numbers. These are inexact
> inherently.
>
> Scheme's notion of exact is towards capturing the second notion.
I don't see anything in the Guile documentation you linked to which supports
that interpretation.
> According to which
> “There were 20,000 people in the stadium” would be an inexact integer
> [Yeah note Inexact INTEGER]
Without a bound on the error ("between 0 and 7 billion people, but probably
20,000") that's of very little use.
> whereas
> √2, e, π are all exact. Just that they dont have finite decimal/continued
> fraction and of course float representations.
There are computer algebra systems capable of treating irrationals like √2, e
and π as exact numbers, but I'm pretty sure Guile is not one of them.
> In short one could think of inexact and exact — in scheme's intended
> semantics — as better called scientific (or science-ic) and mathematic
> numbers.
I don't think so. "Science" uses both experimentally-derived numbers (e.g. G,
c, the mass of the electron) and numbers known exactly (√2, e, π).
I think one could better think of Scheme's semantics as a poorly-thought out
hybrid between traditional numerics and a vague approximation to interval
arithmetic.
--
Steve
More information about the Python-list
mailing list