On Nov 19, 2007 2:23 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > OK, I tried mpmath again, and to my surprise, it went well! > > =================================== > #!/usr/bin/env python > #coding=utf-8 > from mpmath import * > mpf.dps = 50 > n = 1 > k = 0 > prod = mpf(1) > while k < 100000: > k += 1 > term = exp(1.0/n)/exp(1.0/(n+1)) > prod *= term > n += 2 > print prod, term > ====================================== > Output: > 1.9999950000187499635016028080844735182389158683797 > 1.0000000000250001250004074790133889386806610626172
You're getting slightly wrong results, though, because 1.0/n and 1.0/(n+1) just performs regular float division with ~16-digit precision when n is a Python int. You should convert either 1.0 or n to an mpf before dividing. Fredrik -- http://mail.python.org/mailman/listinfo/python-list