eig

Eigenvalues and eigenvectors of a square matrix.

Category: Mathematics > Linear Algebra

Syntax

e = eig(A)

Returns a column vector with the eigenvalues of A.

[V, D] = eig(A)

Returns eigenvectors as the columns of V and eigenvalues on the diagonal of D, with A*V = V*D.

e = eig(A, B)

Solves the generalized problem A*v = lambda*B*v.

Description

An eigenvector of A keeps its direction when multiplied by A, and the eigenvalue is the factor by which its length changes. Eigenvalues are the roots of the characteristic polynomial det(A - lambda*I), but they are computed by iteration on the matrix itself, not by finding those roots.

A real nonsymmetric matrix can have complex eigenvalues, which come in conjugate pairs. Eigenvector signs and scaling are not unique, so compare results through the relation A*V = V*D rather than entry by entry.

Input arguments

A
Square matrix.
B
Square matrix of the same size, for the generalized problem.

Output arguments

e
Eigenvalues, real or complex. For a symmetric matrix they are real and in ascending order.
V
Eigenvector matrix; for symmetric A its columns are orthonormal.
D
Diagonal matrix of eigenvalues.

Example

Symmetric and general matrices

[V, D] = eig([2 1; 1 2])
eig([1 2; 3 4])
eig([2 0; 0 1], [1 0; 0 2])
Output
V = 2×2

    0.7071    0.7071
   -0.7071    0.7071
D = 2×2

    1.0000         0
         0    3.0000
ans = 2×1

   -0.3723
    5.3723
ans = 2×1

     1
     2

See also

eigs svd schur balance polyeig roots