Spectral Decomposition

Overview


A symmetric {% n \times n %} matrix {% M %}, can be expressed as
{% M = \Gamma \Lambda \Gamma^{T} %}
Here {% \Gamma %} is an orthonormal matrix eigenvectors.
{% \Gamma = (\vec{q}_1,...,\vec{q}_n) %}
{% \Lambda %} is a diagonal matrix of eigenvalues.

In addition, we have the following
{% \Gamma^T \Gamma = I %}

Decomposition


Given an orthonormal basis {% \vec{q}_1, ... , \vec{q}_n %}, which are eigenvectors of the matrix {% M %} with eigenvalues {% \lambda_1,...,\lambda_n %}, then {% M %} can be written as
{% M = \lambda_1 \vec{q}_1 \vec{q}_1^T + ... + \lambda_n \vec{q}_n \vec{q}_n^T %}

Operator Formalism


{% M = \lambda_1 | q_1 \rangle \langle q_1| + ... + \lambda_n | q_n \rangle \langle q_n | %}
see spectral theory

Implementation


The following code calculates the eigenvectors/values of the given matrix using the linear algebra library.


let la = await import('/lib/linear-algebra/v1.0.0/linear-algebra.mjs');
                
let test = [
                [2,3,4,5,6],
                [4,4,5,6,7],
                [0,3,6,7,8],
                [0,0,2,8,9],
                [0,0,0,1,10]
            ];
let eig = la.eigenvectors(test);
					
Try it!