The MATLAB function used to compute the eigenvalues of a matrix is eig
.
Computing Eigenvalues in MATLAB
Eigenvalues and eigenvectors are fundamental concepts in linear algebra, representing special scalars and vectors associated with a linear transformation (or a matrix). They describe directions along which the linear transformation acts by simply stretching or compressing the vector, without changing its direction. Computing them is crucial in many fields like physics, engineering, and data science.
The eig
Function
In MATLAB, the standard function for finding the eigenvalues, and optionally the eigenvectors, of a square matrix is eig
. This function is versatile and can handle both numeric and symbolic matrices.
Using eig
to Find Eigenvalues (Numeric and Symbolic)
The eig
function calculates the eigenvalues of a matrix A
. The data type of the output (numeric or symbolic) generally matches the data type of the input matrix A
.
Obtaining Only Eigenvalues
To compute only the eigenvalues of a square matrix A, you use the syntax:
E = eig(A)
The output E
is a column vector containing the eigenvalues of A
. If A
is a numeric matrix, E
will be numeric. If A
is a symbolic matrix (created using syms
or sym
), E
will contain symbolic expressions for the eigenvalues.
As mentioned in the reference, for a symbolic matrix A
, the command E = eig(A)
computes the symbolic eigenvalues.
Obtaining Eigenvalues and Eigenvectors
To compute both the eigenvalues and their corresponding eigenvectors for a square matrix A, you use the syntax:
[V,E] = eig(A)
In this case, the output E
is a diagonal matrix where the diagonal elements are the eigenvalues of A
. The output V
is a matrix where the columns are the corresponding eigenvectors. The $j$-th column of V
is the eigenvector corresponding to the $j$-th diagonal element of E
.
Similarly, the command [V,E] = eig(A)
computes both the symbolic eigenvalues (E
) and the corresponding symbolic eigenvectors (V
) for a symbolic matrix A
.
Variable-Precision Computation
When working with symbolic matrices and you need numerical results with a specific number of digits beyond standard double-precision, you can use variable-precision arithmetic provided by the vpa
function.
For variable-precision computations, especially with symbolic matrices, you can use vpa(A)
within the eig
function. The reference states this is done using E = eig(vpa(A))
for eigenvalues and [V,E] = eig(vpa(A))
for both eigenvalues and eigenvectors. This converts the symbolic matrix A
into a variable-precision floating-point number representation before computing eigenvalues and eigenvectors.
Syntax Overview
Here is a summary of the common ways to use the eig
function based on the input type and desired output:
Input Matrix A Type |
Syntax | Output E |
Output V (Optional) |
Description | Reference Source |
---|---|---|---|---|---|
Numeric | E = eig(A) |
Numeric column vector | N/A | Numeric eigenvalues | - |
Numeric | [V,E] = eig(A) |
Numeric diagonal matrix | Numeric matrix | Numeric eigenvalues (E) and eigenvectors (V) | - |
Symbolic | E = eig(A) |
Symbolic column vector | N/A | Symbolic eigenvalues | Included |
Symbolic | [V,E] = eig(A) |
Symbolic diagonal matrix | Symbolic matrix | Symbolic eigenvalues (E) and eigenvectors (V) | Included |
Symbolic (VPA) | E = eig(vpa(A)) |
Variable-precision column vector | N/A | Variable-precision symbolic eigenvalues | Included |
Symbolic (VPA) | [V,E] = eig(vpa(A)) |
Variable-precision diagonal matrix | Variable-precision matrix | Variable-precision symbolic eigenvalues (E) and eigenvectors (V) | Included |
Practical Applications
Eigenvalue computations are essential for:
- Stability Analysis: Determining the stability of systems (e.g., in control theory or differential equations).
- Principal Component Analysis (PCA): Reducing dimensionality in data analysis by finding directions of maximum variance.
- Quantum Mechanics: Solving Schrödinger's equation for energy levels.
- Structural Engineering: Analyzing vibrations and stability of structures.
- Graph Theory: Understanding properties of graphs via the eigenvalues of their adjacency or Laplacian matrices.