What exactly is "exact" (was Clean Singleton Docstrings)

Rustom Mody rustompmody at gmail.com
Mon Jul 18 00:16:18 EDT 2016


On Saturday, July 16, 2016 at 3:16:48 PM UTC+5:30, Steven D'Aprano wrote:
> On Sat, 16 Jul 2016 04:53 pm, Random832 wrote:
> 
> > Eliminate both of them. Move to a single abstract numeric type* a la
> > Scheme, with an "inexact" attribute (inexact numbers may or may not be
> > represented by a float, or by the same bigint/decimal/rational types as
> > exact ones with a flag set to mark them as inexact.)
> 
> 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
Here are the first couple of hits it gives (me) for “scheme exact number”


| Scheme integers can be exact and inexact. For example, a number
| written as 3.0 with an explicit decimal-point is inexact, but it
| is also an integer. The functions integer? and scm_is_integer
| report true for such a number, but the functions exact-integer?…
| only allow exact integers and thus report
| false. Likewise, the conversion functions like
| scm_to_signed_integer only accept exact integers.
|  
| The motivation for this behavior is that the inexactness of a number
| should not be lost silently. If you want to allow inexact integers,
| you can explicitly insert a call to inexact->exact or to its C
| equivalent scm_inexact_to_exact. (Only inexact integers will be
| converted by this call into exact integers; inexact non-integers 
| will become exact fractions.)

https://www.gnu.org/software/guile/manual/html_node/Integers.html

| All numbers are complex numbers. Some of them are real numbers, and
| all of the real numbers that can be represented are also rational
| numbers, except for +inf.0 (positive infinity), +inf.f
| (single-precision variant), -inf.0 (negative infinity), -inf.f
| (single-precision variant), +nan.0 (not-a-number), and +nan.f
| (single-precision variant). Among the rational numbers, some are
| integers, because round applied to the number produces the same
| number.
|  
| Orthogonal to those categories, each number is also either an exact
| number or an inexact number. Unless otherwise specified, computations
| that involve an inexact number produce inexact results. Certain
| operations on inexact numbers, however, produce an exact number, such
| as multiplying an inexact number with an exact 0. Operations that
| mathematically produce irrational numbers for some rational arguments
| (e.g., sqrt) may produce inexact results even for exact arguments.

https://docs.racket-lang.org/reference/numbers.html

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 ⅓

2. Measurement and observation produces numbers.  These are inexact inherently.

Scheme's notion of exact is towards capturing the second notion.
According to which
“There were 20,000 people in the stadium” would be an inexact integer
[Yeah note Inexact INTEGER]
whereas
√2, e, π are all exact.  Just that they dont have finite decimal/continued
fraction and of course float representations.

In short one could think of inexact and exact — in scheme's intended
semantics — as better called scientific (or science-ic) and mathematic
numbers.

Or if you prefer more philosophic jargon: analytic numbers and synthetic numbers:

The fact that analytic/mathematic and synthetic/science-ic domains at all 
correspond is at the least surprising.  
Famous article calling it “unreasonable” starts with this:

| THERE IS A story about two friends, who were classmates in high
| school, talking about their jobs. One of them became a statistician
| and was working on population trends. He showed a reprint to his
| former classmate. The reprint started, as usual, with the Gaussian
| distribution and the statistician explained to his former classmate
| the meaning of the symbols for the actual population, for the average
| population, and so on. His classmate was a bit incredulous and was not
| quite sure whether the statistician was pulling his leg. "How can you
| know that?" was his query. "And what is this symbol here?" "Oh," said
| the statistician, "this is pi." "What is that?" "The ratio of the
| circumference of the circle to its diameter." "Well, now you are
| pushing your joke too far," said the classmate, "surely the population
| has nothing to do with the circumference of the circle."
| https://www.dartmouth.eduh/~matc/MathDrama/reading/Wigner.html

But the match while strong is not quite perfect:

Physical length (unlike math numbers) may have a ‘least count’
https://en.wikipedia.org/wiki/Planck_length

Likewise time

https://en.wikipedia.org/wiki/Planck_time

And of course all this is highly speculative; ie it may be 
https://en.wikipedia.org/wiki/Chronon

At the more mundane level when I read off 2 volts on a voltmeter
- May be reading wrong by seeing from a wrong angle
- Meter may be miscalibrated
- Or broken
- Or the range setting was not 0-10 as I imagined but 0-500
- And so on

IOW numbers picked off from the real world are just naturally wrong

And that's nothing to do with math operations like floating point
introducing errors



More information about the Python-list mailing list