Categories

# MATLAB Eigenvalues

Aneigenvalue is a special set of scalar factors which changes the eigenvector or characteristic vector of a linear transformation and gets associated with a linear system of equations or to a matrix. The eigenvalue approach is to find out the solution to an equation in the form of:

``Mv = λv``

Where M is an n-by-n input matrix, ‘v’ is a column vector having a length of size ‘n’, and λ is a scalar factor. The values corresponding to λ that satisfy the equation specified in the above form, are counted as eigenvalues. The values of v corresponding to that satisfy the equation are counted as the right eigenvectors.

## Syntax

Below awe will understand the syntax with description:

## Note:

1. If the parameter ‘algorithm’ is excluded from the command, the functioneigchoosesthe algorithm depending on the properties of P and Q.

By default, the selected algorithm is ‘chol’. This algorithm also supports solving the eigenvalue problem where matrix ‘P’ is symmetric (Hermitian) and ‘Q’ is symmetric (Hermitian) positive definite.

2. Irrespective of the algorithm being specified, eig() function always applies the QZ algorithm where P or Q is not symmetric.

3. The eigenvalue option supports two values as ‘vector’ or ‘matrix’ that decides the form of Eigenvalues is a column vector or a diagonal matrix. The behavior also depends on the number of outputs being specified

• Case1: Single output, i.e e = eig(M), then the return form of eigenvalues is a column vector.
• Case2: multiple outputs, such as [V,D] = eig(M), then the return form ofeigenvalues is a diagonal matrix, D.

## How do Eigenvalue works?

As we have discussed earlier, eigenvalue(s) for a given input matrix ‘M’ satisfies the equation of :

• M·v=λ·v

Where v is an n-by-1 non-zero vector and λ is a scalar factor. The set of values that can replace for λ and the above equation results a solution, is the set of eigenvalues or characteristic values for the matrix M. The vector corresponding to an Eigenvalue is called an eigenvector.

The eigenvalue equation can also be stated as:

• M·v-λ·v=0
• M·v-λ·I·v=0
• (M-λ·I)·v=0

When v is non zero vector then the equation will have a solution only when

• |M-λ·I|=0

The above equation is coined as the characteristic equation of the input matrix ‘M’, and which is a nth order polynomial in λ with n roots.  These roots are called the eigenvalues of A.  We will only deal with the case of n distinct roots, though they may be repeated.

Thus Eigenvectors are generated with respect to each eigenvalue for which the eigenvalue equation mentioned above is true.

## Code:

``````M = gallery('lehmer',5)
e = eig(M)``````

## Example 2:

The below code snippet solves the Eigenvalues resulting right Eigenvector.

## Code:

``````M = gallery('circul',3)
[Er,D] = eig(M)``````

## Sorted Eigenvalues and Eigenvectors

The functionsort() can be used to arrange the eigenvalues in ascending order accordingly to the corresponding Eigenvectors as well.

## Example

The below set of command solves the eigenvalue for the given input matrix ‘M’ and rearrange the resultant matrix in ascending order.

## Code:

``````M= magic(5)
[Er,D_sorted] = eig(M)
[dm,ind] = sort(diag(D_sorted))
D_sorted = D_sorted(ind,ind)
Er_sorted = Er(:,ind)``````

## LeftEigenvectors

Left eigenvector is nothing but the eigenvector derived where the column vector that satisfies the eigenvalue equation is placed in the left side if the input matrix.

• v.M = λ·v

## Code:

``````M = [10 17 23; 32 19 12; 25 22 17];
[El,D,Mf] = eig(M);
Mf'*M - D*Mf'``````

## Eigenvalues of Defective or Non-diagonalizable matrix

When the input matrix has repeated eigenvalues and the eigenvectors are dependent by nature, then the input matrix is said to be a not diagonalizable and is, thus marked as defective.

In this case, eigenvalue decomposition does not satisfy the equation exactly.

## Code:

``````M = [30 10 0; 0 30 10; 0 0 30];
[Er,D] = eig(M);
M*Er - Er*D``````

## Output:

The difference between M*Er andEr*D is not exactly zero.

## Calculating Eigenvalue for Singular Matrix

If the matrices P and Q result in (P/Q)=Inf, it is recommended to calculate the eigenvalues for both matrices separately.

## Code:

`P = eye(2);Q = [3 6; 4 8];[V,D] = eig(P)[V,D] = eig(Q)`