# eig

Eigenvalues and eigenvectors

### d = eig(A)

• A is a square matrix.
• It returns a vector d containing eigenvalues of A.

Example 1: Finding eigenvalues of a random matrix and then group them in conjugate pairs.

a=rand(10);
cplxpair(eig(a))

ans =
-0.4109130 - 0.6592851i
-0.4109130 + 0.6592851i
0.1072426 - 0.2233978i
0.1072426 + 0.2233978i
0.4336722 - 0.6942055i
0.4336722 + 0.6942055i
-0.3721263 + 0.0000000i
-0.1895444 + 0.0000000i
0.5893938 + 0.0000000i
5.6223728 + 0.0000000i


### [V, D] = eig(A)

• A is a square matrix.
• It returns a diagonal matrix D containing eigenvalues of A. Columns of matrix V are the right eigenvectors such that A * V = V * D.

Example 2: For the random matrix A, the second eigenvalue is d(2,2) and the corresponding right eigenvector is V(:,2). Here A*V(:,2) and D(2,2)*V(:,2) give approximately the same values.

A=rand(4);
[V,D]=eig(A);
A*V(:,2)
D(2,2)*V(:,2)

ans = 1e-1 ×
-2.3628584 + 1.3160677i
1.1303095 - 1.2702069i
1.1515366 + 2.1725013i
-0.0463397 - 1.7423500i

ans = 1e-1 ×
-2.3628584 + 1.3160677i
1.1303095 - 1.2702069i
1.1515366 + 2.1725013i
-0.0463397 - 1.7423500i


### [V, D,W] = eig(A)

• It returns a diagonal matrix D containing eigenvalues of A. Columns of matrix V are the right eigenvectors such that A * V = V * D, and columns of matrix W are the left eigenvectors such that W' * A = D * W'.

Example 3: For the random matrix A, the second eigenvalue is d(2,2) and the corresponding left eigenvector is W(:,2). Here W(:,2)'*A and D(2,2)*W(:,2)' give approximately the same values.

A=rand(4);
[V,D,W]=eig(A);
W(:,2)'*A
D(2,2)*W(:,2)'

ans = 1e-2 ×
0.7739085  -0.3822298   0.0919348  -1.4037180

ans = 1e-2 ×
0.7739085  -0.3822298   0.0919348  -1.4037180