Skip to content Skip to sidebar Skip to footer

Sympy Error - Attributeerror: Sqrt

I am new to Python, and I keep getting the following error ..., line 27, in eq=(p**2+2)/p/sqrt(p**2+4) AttributeError: sqrt I tried to add math.sqrt or numpy

Solution 1:

sqrt is defined in the math module, import it this way. This should remove the errors!

from math import sqrt

Solution 2:

You are using a sympy symbol: either you wanted to do numerical sqrt (in which case use numpy.sqrt on an actual number) or you wanted symbolic sqrt (in which case use sympy.sqrt). Each of the imports replaces the definition of sqrt in the current namespace, from math, sympy or numpy. It's best to be explicit and not use "import *".

I suspect from the line which follows, you want sympy.sqrt here.

Post a Comment for "Sympy Error - Attributeerror: Sqrt"