Hi,
Next time, please provide an example code so that people can do their own experiments.
I guess you did something like:
>>> from math import sqrt
>>> from sympy.abc import *
>>> sqrt(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sympy/core/expr.py", line 280, in __float__
raise TypeError("can't convert expression to float")
TypeError: can't convert expression to float
This happens because you used a function from the standard library, here math.sqrt, and you gave it a SymPy expression as an argument. The problem is that math.sqrt() is for numbers and doesn't understand expressions which are coming from a third party module. Here, it tried to convert your 'x' into a float (hence the message coming from a __float__ method) but SymPy told you that this expression can't be converted to a float because you gave no value to 'x'. Of course when you pass a number, the conversion to float succeeds.
So, just use the sqrt function provided by SymPy:
>>> from sympy import *
>>> from sympy.abc import *
>>> sqrt(x) # this is sympy's sqrt, not math's
sqrt(x)
The sqrt functions defined in the math module and in the SymPy library have the same name, and yet they are completely different because math.sqrt() acts on a real number and returns a real number, whereas sympy.sqrt acts on any number or expression and returns an expression -- which can later be evaluated, or printed, or derivated, and so on.
(Of course perhaps your problem is with a sin() or whatever but I used sqrt() for the demonstration.)
Regards,
Jean Abou Samra