Main Content

eig

Eigenvalues and eigenvectors of symbolic matrix

Description

example

lambda = eig(A) returns the eigenvalues of the square symbolic matrix A as a symbolic vector.

example

[V,D] = eig(A) returns the eigenvectors and eigenvalues of A as symbolic matrices V and D. The columns of V present eigenvectors of A. The main diagonal of D present eigenvalues of A.

  • If V is the same size as A, then the matrix A has a full set of linearly independent eigenvectors that satisfy A*V = V*D.

  • If V has fewer columns than A, then the matrix A is defective. In this case, at least one of the eigenvalues λ has an algebraic multiplicity m > 1 with fewer than m linearly independent eigenvectors associated with λ.

example

[V,D,p] = eig(A) also returns a vector of indices p. The length of p is equal to the number of linearly independent eigenvectors, so A*V = V*D(p,p).

Examples

collapse all

Compute eigenvalues for the magic square of order 5.

A = sym(magic(5));
lambda = eig(A)
lambda = 

(656252-531452531452+6252-6252-531452-531452+6252)

Compute numeric eigenvalues for the magic square of order 5 using variable-precision arithmetic.

A = magic(5);
lambda = eig(vpa(A))
lambda = 

(65.021.27676547147379553062642669797413.126280930709218802525643085949-13.126280930709218802525643085949-21.276765471473795530626426697974)

Create a 5-by-5 symbolic matrix from the magic square of order 6. Compute the eigenvalues of the matrix using eig.

M = magic(6);
A = sym(M(1:5,1:5));
lambda = eig(A)
lambda = 

(root(σ1,z,1)root(σ1,z,2)root(σ1,z,3)root(σ1,z,4)root(σ1,z,5))where  σ1=z5-100z4+134z3+66537z2-450198z-1294704

The eig function cannot find the exact eigenvalues in terms of symbolic numbers. Instead, it returns them in terms of the root function.

Use vpa to numerically approximate the eigenvalues.

lambdaVpa = vpa(lambda)
lambdaVpa = 

(-2.1810323649846951083546927010659.8395828502812312578803604206392-25.13164166979989160726758463919226.34161761027586903546571650580691.131473574227486422276200413812)

Compute the exact eigenvalues and eigenvectors for one of the MATLAB® test matrices that is defective.

A = sym(gallery(5))
A = 

(-911-2163-25270-69141-4211684-575575-11493451-138013891-38917782-23345933651024-10242048-614424572)

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

(021256-711289732561)

D = 

(0000000000000000000000000)

The output V is a 5-by-1 column vector with five-fold eigenvalues of 0. This result means that the matrix A has an eigenvalue of 0 with algebraic multiplicity 5 and geometric multiplicity 1.

Compute the exact eigenvalues and eigenvectors of a 4-by-4 symbolic matrix. Return a vector of indices that relate the eigenvalues to their linearly independent eigenvectors.

syms c
A = [c 1 0 0; 0 c 0 0; 0 0 3*c 0; 0 0 0 3*c];
[V,D,p] = eig(A)
V = 

(100000010001)

D = 

(c0000c00003c00003c)

p = 1×3

     1     3     4

The matrix A has two eigenvalues, c and 3c, where each eigenvalue occurs twice. Meanwhile, there are three linearly independent eigenvectors. The vector of indices p shows that:

  • p(1) = 1, so the first eigenvector (the first column of V) corresponds to the first diagonal element of D with eigenvalue c.

  • p(2) = 3, so the second eigenvector (the second column of V) corresponds to the third diagonal element of D with eigenvalue 3c.

  • p(3) = 4, so the third eigenvector (the third column of V) corresponds to the fourth diagonal element of D with eigenvalue 3c.

This result means the eigenvalue c that occurs twice has only one linearly independent eigenvector (the eigenvalue c has algebraic multiplicity 2 and geometric multiplicity 1). The eigenvalue 3c that occurs twice has two linearly independent eigenvectors (the eigenvalue 3c has algebraic multiplicity 2 and geometric multiplicity 2).

Show that the matrix A*V is equal to V*D(p,p).

A*V
ans = 

(c0000003c0003c)

V*D(p,p)
ans = 

(c0000003c0003c)

tf = isequal(A*V,V*D(p,p))
tf = logical
   1

Input Arguments

collapse all

Square matrix, specified as a symbolic matrix.

Output Arguments

collapse all

Eigenvalues, returned as a symbolic column vector or column vector of symbolic numbers.

Right eigenvectors, returned as a square symbolic matrix. The columns of V are the right eigenvectors of A.

Eigenvalues, returned as a symbolic diagonal matrix. The eigenvalues of A are on the main diagonal of D.

Vector of indices, returned as a symbolic row vector. The length of p is the total number of linearly independent eigenvectors of A.

Tips

  • Matrix computations involving many symbolic variables can be slow. To increase the computational speed, reduce the number of symbolic variables by substituting the given values for some variables.

  • Calling eig for numeric matrices that are not symbolic objects (not created by sym, syms, or vpa) invokes the MATLAB® eig function.

  • The symbolic eig function does not support solving the generalized eigenvalue problem (with two input arguments). To solve the generalized eigenvalue problem, use the MATLAB eig function instead by converting the input matrices to a MATLAB numeric type.

Version History

Introduced before R2006a

expand all

See Also

| | |