Python fails on math
invalid at invalid.invalid
Tue Feb 22 14:42:03 EST 2011
On 2011-02-22, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Tue, Feb 22, 2011 at 9:54 AM, David C. Ullrich <dullrich at sprynet.com> wrote:
>> Anyway, I don't know why you're jumping to the conclusion that it's
>> Python that's wrong here. Could be the math you learned in school
>> is wrong. I mean you're assuming that
>> (*) ? ? ? a(b+c) = ab + ac
>> but what makes you so certain (*) is correct? Have you tried it with
>> every possible value of a, b, and c? Or do you just blindly believe
>> everything your teacher told you or what?
>> Seems to me you've stumbled on a counterexample to (*). I'm
>> gonna have to take this up with the mathematicians...
> Or you could, you know, just check the proof:
Except that Python (and computer languages in general) don't deal with
real numbers. They deal with floating point numbers, which aren't the
same thing. [In case anybody is still fuzzy about that.]
FP multiplication distributes over addition, close enough for most
purposes, except when it doesn't quite.
Grant Edwards grant.b.edwards Yow!
More information about the Python-list