## SymPy – 22 – matrici – 2 Continuo da qui, copio qui.

Metodi avanzati
determinante
To compute the determinant of a matrix, use `det`. reduced row echelon form (RREF)
To put a matrix into reduced row echelon form, use `rref`. `rref` returns a tuple of two elements. The first is the reduced row echelon form, and the second is a tuple of indices of the pivot columns. Note: The first element of the tuple returned by `rref` is of type `Matrix`. The second is of type list.

`nullspace`
To find the nullspace of a matrix, use `nullspace`. `nullspace` returns a list of column vectors that span the nullspace of the matrix. `columnspace`
To find the columnspace of a matrix, use `columnspace`. `columnspace` returns a list of column vectors that span the columnspace of the matrix. aurovalori, autovettori e diagonalizzazione
To find the eigenvalues of a matrix, use `eigenvals`. `eigenvals` returns a dictionary of `eigenvalue:algebraic multiplicity pairs` (similar to the output of `roots`). This means that `M` has eigenvalues -2, 3, and 5, and that the eigenvalues -2 and 3 have algebraic multiplicity 1 and that the eigenvalue 5 has algebraic multiplicity 2.

To find the eigenvectors of a matrix, use `eigenvects`. `eigenvects` returns a list of tuples of the form (`eigenvalue:algebraic multiplicity, [eigenvectors]`). This shows us that, for example, the eigenvalue 5 also has geometric multiplicity 2, because it has two eigenvectors. Because the algebraic and geometric multiplicities are the same for all the eigenvalues, `M` is diagonalizable.

To diagonalize a matrix, use `diagonalize`. `diagonalize` returns a tuple `(P,D)`, where `D` is diagonal and `M=PDP−1`. Note that since `eigenvects` also includes the eigenvalues, you should use it instead of `eigenvals` if you also want the eigenvectors. However, as computing the eigenvectors may often be costly, `eigenvals` should be preferred if you only wish to find the eigenvalues.

If all you want is the characteristic polynomial, use `charpoly`. This is more efficient than `eigenvals`, because sometimes symbolic roots can be expensive to calculate.

Quick Tip: `lambda` is a reserved keyword in Python, so to create a Symbol called `λ`, while using the same names for SymPy Symbols and Python variables, use `lamda` (without the `b`). It will still pretty print as `λ`. (Unicode per λ: 955 0x3bb).  Posta un commento o usa questo indirizzo per il trackback.