[Tutor] math question

William Rance rantek at pacific.net.sg
Sun Apr 25 00:29:59 EDT 2004

These type of problems surfaced over 30 years ago when introducing digital
LCD readouts to replace the analogue.
The analogue precision was such that if for example you are reading a
temperature visually, if you could read within 0.5degc you were doing pretty
good, also two people would probably give it a different reading. Along came
the digital LCD with reading to two deciaml places and expectations were
magnified, even if your sensor was only accurate to with 1degC.This stiil
true today.
And so it is with programming. We now expect perfection, why? Just because
we believe the computer should be; it is man made remember. For floating
point arithmetic computation IEEE standard applies.
I also cannot understand the eduction system which insists on absolute
correctness; to me (a professional engineer) the method is more
important-tell a 9 year old that water always boils at 100degC and he
believes you, tell a mature student and he will laugh -knowing pressure and
other factors come into the equation?
Unfortunately I also find (in general)a female's mind works differently
/they seem to expect absoluteness/perfection -whereas a male is much more
tolerant looking more at the overall problem (mind you I can't recall any
female Noble Prize winner in maths/physics).
And so life goes on.....
Bill Rance

----- Original Message -----
From: "Chris Lott" <chris at chrislott.org>
To: <tutor at python.org>
Sent: Friday, April 23, 2004 11:53 PM
Subject: Re: [Tutor] math question

Karl Pflästerer wrote:

> Here are several problems:
> (a) sqrt(2) can't be written as exact value (neither base 10 nor base
>     2).  So Python uses a floating point approximation
> (b) you see the internal representation of the numbers (repr())
> (c) most floating point numbers can't be represented exactly in the way
>     Python stores them
> A very good explanation of the problems with floating point numbers can
> be found in the Python tutorial in the official documentation.  You
> should read it.
> A simple example from it which shows the problem:

I understand and I don't understand. I've read that section in the
tutorial. I understand that the sqrt(2) can't be written as an exact
value. But the sqrt(2)^2 certainly can be written in an exact value. It
seems strange to me (I'm no mathematician and I suspect this is a
philosophy question rather than a Python question) that the language
can't figure this out-- similarly, if I add up 1/3 + 1/3 + 1/3 there is
no reason (to my layperson's mind) that it doesn't come out to 1,
regardless of the individual values. I guess it seems like something
should see the code and know a difference between adding .33 + .33 +
.333 and 1/3 + 1/3 + 1/3

I can't conceive of why it would *matter* in anything I do, but I had a
hard time explaining to my daughter when I was helping her with a
math/geometry problem and showed her how to use the Python shell as a
kind of calculator and was demonstrating to her and got 2.000000004 here :)

Chris Lott

Tutor maillist  -  Tutor at python.org

More information about the Tutor mailing list