7

I want to use the jacobDN function in sympy, so I download it and python setup.py install it, successfully.

When I want to use it as in the documentation does:

>>> from sympy.mpmath import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mpmath
>>> 

Import everything from sympy is successful:

>>> from sympy import *
>>> 

Then I installed mpmath individually, then I can use the ellipfun from mpmath. However an annoying mpf is shown:

>>> from mpmath import *
>>> ellipfun('dn',0.5,0.5)
mpf('0.94297242577738571')
>>> 

Question is how to use ellipfun under sympy.mpmath? How to check my install flaws?

The solution to the above is the best! If can't, how can I use ellipfun in mpmath just as using the normal functions?

evidence of the successful installation of sympy

-> ~$ pip show sympy
---
Name: sympy
Version: 0.7.7.dev
Location: /usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev-py2.7.egg
Requires: mpmath

-> ~$ pip install --upgrade sympy
Requirement already up-to-date: sympy in /usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev-py2.7.egg
Requirement already up-to-date: mpmath>=0.19 in /usr/local/lib/python2.7/dist-packages/mpmath-0.19-py2.7.egg (from sympy)
Cleaning up...
Anton Protopopov
  • 30,354
  • 12
  • 88
  • 93
an offer can't refuse
  • 4,245
  • 5
  • 30
  • 50
  • What's wrong with showing `mpf`? – leewz Dec 11 '15 at 03:21
  • @leewangzhong If I want to do the following :x= np.arange(0,10,0.1) mp.ellipfun('dn',x,0.5) plt.plot(x,y) I'll get the error:cannot create mpf from array – an offer can't refuse Dec 11 '15 at 03:22
  • Would have helped if you said that it was giving the error in the second part. That means you can't pass an array as the second argument to `ellipfun`. – leewz Dec 11 '15 at 03:28
  • @leewangzhong Yes, but I think `ellipfun` under `sympy.mpmath` should do this fine. So I asked the question. – an offer can't refuse Dec 11 '15 at 03:30
  • I've been trying to hack it to make it work for almost an hour. `mpmath` isn't ready for `ndarray`. Just use a loop on ellipfun. – leewz Dec 11 '15 at 04:23

2 Answers2

5

In the development version of SymPy, which is what you have installed, sympy.mpmath has been removed. mpmath is now an external library, so you need to install and import it separately, as you have done.

The two versions are exactly the same (there haven't been any mpmath releases in a while).

mpmath doesn't support numpy arrays, as far as I know. You need to use scipy.special if you want to do that. You should only use mpmath if you are interested in multiprecision floats (beyond machine precision). If you are interested in that, you can also use sympy.Float, which is a wrapper around mpf which plays nicely with SymPy objects.

asmeurer
  • 86,894
  • 26
  • 169
  • 240
1

I would recommend using the non-development version. SymPy 0.7.6 is the last version that will have mpmath packaged with SymPy. In the future it will be a dependency. Since you installed the development version you have to install mpmath independently.

moorepants
  • 1,813
  • 2
  • 22
  • 23
  • Why recommend using an older version instead of just installing mpmath? – leewz Dec 15 '15 at 13:23
  • SymPy 0.7.6 is the latest version. – moorepants Dec 16 '15 at 14:57
  • The development version, paradoxically, is a newer version than the latest version. Future versions will not have the behavior. Why rely on it when you can simply install `mpmath`? Why write code that will have to be updated later, when there's an easier solution? – leewz Dec 17 '15 at 11:00