On 7/4/2018 2:32 PM, Sven R. Kunze wrote:
Sorry for adding yet another mail. :-(

On 04.07.2018 10:54, Serhiy Storchaka wrote:
Sorry, this PEP was rewritten so many times that I missed your Appendix.

while total != (total := total + term):
    term *= mx2 / (i*(i+1))
    i += 2
return total


This very example here caught my eye.

Isn't total not always equal to total

Repeat response given elsewhere. No. Python has limited precision floats, not reals. Floats do not obey laws of real numbers.

>>> 1e50 + 1e34 == 1e50
True
>>> 1e50 + 1e35 == 1e50
False

Basic numerical analysis operation: approximate infinite sum of decreasing terms by summing terms until they become small enough that they can be ignored.


--
Terry Jan Reedy


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to