Help with sympy, please

Fredrik Johansson fredrik.johansson at gmail.com
Sun Nov 18 19:26:37 EST 2007


On Nov 19, 2007 1:05 AM, Dick Moores <rdm at rcblue.com> wrote:
> At 03:42 PM 11/18/2007, Dennis Lee Bieber wrote:
> >On Sun, 18 Nov 2007 13:02:01 -0800, Dick Moores <rdm at rcblue.com>
> >declaimed the following in comp.lang.python:
> >
> > >
> > > This gets:
> > > Traceback (most recent call last):
> > >    File "E:\PythonWork\Untitled 5.py", line 20, in <module>
> > >      term = (e**(1/n))/(e**(1/(n+1)))
> > > TypeError: unsupported operand type(s) for /: 'int' and 'Float'
> > >
> >         Seems self-explanatory... try using 1.0 rather than 1
>
> term = (e**(1.0/n))/(e**(1.0/(n+1)))
> TypeError: unsupported operand type(s) for /: 'float' and 'Float'

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.

Basically, sympy.numerics is an old version of mpmath. The
sympy.numerics module is not very well integrated in SymPy, slower
than mpmath, and has a couple bugs that have subsequently been fixed
in mpmath. In sympycore (http://code.google.com/p/sympycore/), we're
using the latest version of mpmath and integrating it directly into
the symbolic engine; it will be much more robust and user-friendly. It
will hopefully not be long until we merge the improvements we've done
in the sympycore project with the main SymPy branch.

Fredrik



More information about the Python-list mailing list