I know that sympy in python can set assumptions on variables, such as x is positive, negative, real, complex, etc. I was wondering if sympy can set assumptions on variables relative to other variables. For example, if I have variables x and y, can I set sympy to assume that x > y in its solutions. Or, alternatively, if I have two variables, a and B, can I set sympy to assume that a + 2B < 1? These sorts of assumptions would possibly help sympy simplify complicated solutions to solve() and eigenvectors.
I've looked all over and haven't found information pertaining to setting these kinds of assumptions in sympy.
I ask because I'm attempting to find the eigenvectors of a particular matrix
a,b = symbols('a,b', nonnegative=False)
M = Matrix([ [1-a-2*b, a, b, b],
[a, 1-a-2*b, b, b],
[b, b, 1-a-2*b, a],
[b, b, a, 1-a-2*b] ])
Sympy finds the eigenvalues correctly
M.eigenvals()
which I've confirmed via MATLAB and WolframAlpha, which all give the same results. However, the eigenvectors are a mess
M.eigenvects()
MATLAB and WolframAlpha both return eigenvectors of [1,1,1,1] [-1,-1,1,1] [0,0,-1,1] [-1,1,0,0], which are the correct eigenvectors. I haven't even tried to simplify sympy's results because they're incredibly long and complex. I suspect it has to do with assumptions on the variables, like specifying that a+2b < 1, but I'm not sure.
See Question&Answers more detail:
os