I have a FiniteSet and a symbol with which I want to associate a Relation such that the symbol is in the FiniteSet, is it possible with sympy? symbol in FiniteSet
does not return an expression, but instead evaluates it:
>>> from sympy import *
>>> s = FiniteSet(range(0,3))
>>> x = symbols('x')
>>> x in s
False
>>> Eq(x,s)
x == {0, 1, 2}
>>> In(x,s)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'In' is not defined
Edit: Thanks to ohe for telling me about Contains
. I updated my version of sympy, by the way the syntax of FinitSet also changed in the update. I give the small example that I expected to work in the first place for the record:
>>> from sympy import *
>>> x = symbols('x')
>>> s = FiniteSet(*range(0,3))
>>> init_printing()
>>> Contains(x,s)
x ∈ {0, 1, 2}