Main Content

eig

Eigenvalues and eigenvectors of symbolic matrix

Description

example

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

example

[V,D] = eig(A) returns matrices V and D. The columns of V present eigenvectors of A. The diagonal matrix D contains eigenvalues. If the resulting V has the same size as A, then the matrix A has a full set of linearly independent eigenvectors that satisfy A*V = V*D.

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

example

lambda = eig(B) returns numeric eigenvalues of the square variable-precision matrix B. To convert a symbolic matrix A to variable-precision, use B = vpa(A).

[V,D] = eig(B) also returns numeric eigenvectors.

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 eigenvalues and eigenvectors for one of the MATLAB® test matrices.

A = sym(gallery(5))
A = 

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

[v,lambda] = eig(A)
v = 

(021256-711289732561)

lambda = 

(0000000000000000000000000)

Input Arguments

collapse all

Square matrix, specified as a symbolic matrix.

Square variable-precision matrix, specified as a numeric matrix. To convert a symbolic matrix A to variable-precision, use B = vpa(A).

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 whose columns are the right eigenvectors of A.

Eigenvalues, returned as a symbolic diagonal matrix with the eigenvalues of A on the main diagonal.

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

Limitations

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.

Compatibility Considerations

expand all

Behavior changed in R2021b

See Also

| | |

Introduced before R2006a