On Nov 19, 2007 2:03 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > At 04:26 PM 11/18/2007, Fredrik Johansson wrote: > >On Nov 19, 2007 1:05 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > >Hi Dick, I recognize you from python-list, where you had a question > >about mpmath. > > > >Your code still won't work if you convert the numbers to Floats > >because the Float type in sympy.numerics does not implement ** for > >fractional numbers. You could use the exp function in > >sympy.numerics.functions instead to compute e**x. > > Thanks, Fredrik, but I get the same error using either exp or power: > ============================ > from __future__ import division > from sympy import * > from sympy import Rational as R > from sympy.numerics import * > from sympy.numerics.functions import power, exp > > prec = 50 > Float.setdps(prec) > e = evalf(E) > n = 1 > m = n + 1 > k = 0 > n = evalf(R(n,1)) > m = evalf(R(m,1)) > prod = evalf(R(1,1)) > prec = 50 > Float.setdps(prec) > e = evalf(E) > n = 1 > k = 0 > prod = evalf(R(1,1)) > while k < 1000: > k += 1 > n = evalf(R(n,1)) > term = (exp(1/n))/(exp(1/(n+1))) > prod *= term > n += 2 > print prod, term > ============================= > term = (exp(1/n))/(exp(1/(n+1))) > TypeError: unsupported operand type(s) for /: 'int' and 'Float' > > And also if I use sympy.numerics.functions.power in that line, as > term = power(e,(1/n))/power(e,(1/(n+1))) > > I get: > > term = power(e,(1/n))/power(e,(1/(n+1))) > TypeError: unsupported operand type(s) for /: 'int' and 'Float'
Try not using "from __future__ import division". Also, n = evalf(R(n,1)) won't work, because the arguments to Rational must be ints. Fredrik -- http://mail.python.org/mailman/listinfo/python-list