How To Restrict Sympy FiniteSet Containing Symbol
I am fairly new to sympy. I tried to solve a system of linear equations with linsolve(). This yields a solution which can be reproduced with the two following lines. d = symbols('d
Solution 1:
I think something along these lines will do it, with a little extra magic from you.
>>> from sympy import *
>>> var('d')
d
>>> solution = sets.FiniteSet((d+1,-d+4,-d+5,d))
>>> list(list(solution)[0])
[d + 1, -d + 4, -d + 5, d]
>>> from sympy.solvers.inequalities import reduce_inequalities
>>> reduce_inequalities([0<=d + 1, 0<=-d + 4, 0<=-d + 5, 0<=d],[d])
And(0 <= d, d <= 4)
I am indebted to https://stackoverflow.com/users/1879010/dietrich for a comment that I have been forgetting to read until I saw your question.
Post a Comment for "How To Restrict Sympy FiniteSet Containing Symbol"