Python fails on math

Grant Edwards invalid at invalid.invalid
Tue Feb 22 20:42:03 CET 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:
>
> http://www.proofwiki.org/wiki/Real_Multiplication_Distributes_over_Addition

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!
                                  at               
                              gmail.com            



More information about the Python-list mailing list