Search code examples
pythonsymbolic-mathsage

equality between symbolic vectors in sagemath


I am trying to solve an equation of type

x = A x

where x is a vector and A is a matrix, using sagemath.

to do that, I wrote

A = matrix(QQ, [[0, 4, 4], 
                  [1, 2, 2],
                  [1, 2, 0]])  
x = vector([var("x_1"), var("x_2"), var("x_3")])

equation = x == A * x
equation
out : False

Expecting equation to be a vector of symbolic expressions.

My problem is that it was a boolean valued False instead of the system I expected.

Which function should I use to get the symbolic vector corresponding to the equality of the coordinates of x and A * x?


Solution

  • Here is a way:

    sage: vector([xi == yi for xi, yi in zip(x, A*x)])
    (x_1 == 4*x_2 + 4*x_3, x_2 == x_1 + 2*x_2 + 2*x_3, x_3 == x_1 + 2*x_2)