To find the eigenvalues of a matrix, use eigenvals . eigenvals returns a dictionary of eigenvalue: algebraic_multiplicity pairs (similar to the output of roots).
Consider a square matrix n × n. If X is the non-trivial column vector solution of the matrix equation AX = λX, where λ is a scalar, then X is the eigenvector of matrix A and the corresponding value of λ is the eigenvalue of matrix A.
Matrix is created from appropriately sized List objects. You can also obtain a matrix by distributing list items in specified number of rows and columns. Matrix is a mutable object. The matrices module also provides ImmutableMatrix class for obtaining immutable matrix.
I want to calculate the eigenvectors x from a system A by using this: A x = λ x
The problem is that I don't know how to solve the eigenvalues by using SymPy.
Here is my code. I want to get some values for x1 and x2 from matrix A
from sympy import *
x1, x2, Lambda = symbols('x1 x2 Lambda')
I = eye(2)
A = Matrix([[0, 2], [1, -3]])
equation = Eq(det(Lambda*I-A), 0)
D = solve(equation)
print([N(element, 4) for element in D]) # Eigenvalus in decimal form
print(pretty(D)) # Eigenvalues in exact form
X = Matrix([[x1], [x2]]) # Eigenvectors
T = A*X - D[0]*X # The Ax = %Lambda X with the first %Lambda = D[0]
print(pretty(solve(T, x1, x2)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With