Sympy function evaluation
By : Christopher Kroll
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I may be wrong, but I don't think you can make it yell that way, because that's a scientific library so it is made for supporting imaginary numbers, but you can change it a bit: code :
x=Symbol('x', real=True)
v = sqrt(1x).subs(x, 9).evalf()
if not v.is_real:
raise ValueError, "math domain error"
def assert_real(v):
if not v.is_real:
raise ValueError, "math domain error"
return v
x = Symbol('x', real=True)
v = assert_real(sqrt(1x).subs(x, 9).evalf())

Sympy  Comparing expressions
By : Todd Scopio
Date : March 29 2020, 07:55 AM
help you fix your problem From the SymPy documentation code :
>>> from sympy import simplify
>>> from sympy.abc import x,y
>>> vers1 = (x+y)**2
>>> vers2 = x**2 + 2*x*y + y**2
>>> simplify(vers1vers2) == 0
True
>>> simplify(vers1+vers2) == 0
False

Pickle and evaluation of sympy expressions
By : Mx Dep
Date : March 29 2020, 07:55 AM
Any of those help The comment by user2357112 answers the question. code :
>>>with evaluate(False) : x = atan(sqrt(3))
>>>x
atan(sqrt(3))
>>> y = pickle.dumps(x)
>>> with evaluate(False) : z = pickle.loads(y)
>>> z
atan(sqrt(3))

Sympy  comparing equivalent expressions with equal (=) sign
By : user1343413
Date : March 29 2020, 07:55 AM
I wish this help you What makes these equations equivalent is that they have the same solution set or that they are the same when solved for x. Have sympy solve them and compare the solutions: code :
from sympy import *
x, y = symbols('x y')
a = Eq(2*x,6)
b = Eq(x,3)
print(solve(a) == solve(b)) #True
a = Eq(x*(y+1),6)
b = Eq(2*x*y + 2*x, 12)
print(solve(a)) # [{x: 6/(y + 1)}]
print(solve(b)) # [{x: 6/(y + 1)}]
print(solve(a) == solve(b)) # True

Avoid evaluation of multiplication by 1 in sympy
By : KM Yadav
Date : March 29 2020, 07:55 AM
With these it helps This is being worked on in https://github.com/sympy/sympy/pull/13188. Currently, 1 (for Muls) and 0 (for Adds) are automatically removed even if evaluate=False. If you just want to parse something as (number, foo) you can use expr.as_coeff_Mul(), e.g. (1+x).as_coeff_Mul() > (1, 1 + x).

