Using the sympy.Matrix () method. Diagonalize () we can diagonalize the matrix. diagonalize () returns a tuple , where diagonally and ,
Syntax: Matrix (). Diagonalize ()
Returns: Returns a tuple of matrix where the second element represents the diagonal of the matrix.
Example # 1:
|
Exit:
Matrix: Matrix ([[3, -2, 4, -2], [5, 3, -3, -2], [5, -2, 2, -2], [5, -2, -3, 3]])
Diagonal of a matrix: Matrix ([[- 2, 0, 0, 0], [0, 3, 0, 0], [0, 0, 5, 0], [0, 0, 0, 5]])
Example # 2:
|
Exit:
Matrix: Matrix ([[1 , -3, 3], [3, -5, 3], [6, -6, 4]])
Diagonal of a matrix: Matrix ([[- 2, 0, 0], [0, -2, 0], [0, 0, 4]])