jal
jal

Reputation: 73

Access to mpmath module in sympy (python)

I am new to sympy and still naive about python.... I wanted to solve a trigonometric equation, to find its zeroes. (Once I have syntax, then I will use a more complex function.)

I cannot find the right syntax yet. Here is what I tried at the iPython console in Spyder (Python 2.7):

from sympy.solvers import solve
from sympy import Symbol
x = Symbol('x')
solve(sin(x), x)

I got this error:

Traceback (most recent call last):

File "", line 1, in solve(sin(x), x)

NameError: name 'sin' is not defined

OK, so I need to have the correct reference to the sine function.

According to the sympy documentation, I thought this was in mpath, but this did not work:

from mpmath import *
Traceback (most recent call last):

  File "<ipython-input-7-8dcdd12d9679>", line 1, in <module>
    from mpmath import *

ImportError: No module named mpmath

How do I load/access mpmath or some other way to get the sine function?

Upvotes: 3

Views: 1333

Answers (2)

anonymousGCCnoobie
anonymousGCCnoobie

Reputation: 11

To access mpmath do this

    from sympy.mpmath import *

Upvotes: 1

jal
jal

Reputation: 73

This fixed it:

from sympy import sin

Upvotes: 1

Related Questions