Runoob Tutorial ArchiveEnglish

Eigenvalues and eigenvectors — The fingerprint of a matrix

Eigenvalues and eigenvectors -- The fingerprint of a matrix

When a matrix acts on most vectors, it changes both their direction and length.

But there are always some "special directions" where the direction remains unchanged after the matrix acts, only the length changes. These are the eigenvectors, and the scaling factor is the eigenvalue.

Core formula: ( A\mathbf{v} = \lambda \mathbf{v} )

** \lambda > 0

Positive stretching/shortening

Direction remains unchanged

** λ < 0

Negative stretching/shortening

Complete reversal of direction

An n×n matrix has at most n linearly independent eigenvectors.

The eigenvalues of a symmetric matrix are always real—this is one of the reasons why symmetric matrices are so important.


Real-life examples

**Membrane stretching

A membrane stretched 2 times in the horizontal direction, while the vertical direction remains unchanged.

The arrow in the horizontal direction (e.g., (1,0)) is stretched to (2,0), but the direction remains unchanged—it is an eigenvector, $\lambda=2$.

The arrow in the vertical direction (e.g., (0,1)) remains completely unchanged—it is also an eigenvector, $\lambda=1$.

The tilted arrow (e.g., (1,1)) changes direction—it is not an eigenvector.


Mathematical definition

[ A\mathbf{v} = \lambda \mathbf{v} \quad \Leftrightarrow \quad (A - \lambda I)\mathbf{v} = 0 ]

Condition for the existence of non-zero solutions: ( \det(A - \lambda I) = 0 ) (characteristic equation).


Python hands-on practice

Example

import

numpy

as

np

A

=

np.

array

(

[

[

2

,

0

]

,

[

0

,

1

]

]

)

 

Horizontal stretch by 2, vertical unchanged

eigenvalues

,

eigenvectors

=

np.

linalg

.

eig

(

A

)

print

(

"Eigenvalues:"

,

eigenvalues

)

     

[2. 1.]

print

(

"Feature vectors (columns):\n"

,

eigenvectors

)

Verify Av = λv

for

i

in

range

(

2

)

:

    v

=

eigenvectors

[

:

,

i

]

lam

=

eigenvalues

[

i

]

   

print

(

f

"Verify feature vector {i+1}:"

)

   

print

(

f

" A @ v = {A @ v}"

)

   

print

(

f

" λ * v = {lam * v}"

)

   

print

(

f

" equality: {np.allclose(A @ v, lam * v)}"

)

Eigenvalues of a symmetric matrix are all real numbers

S

=

np.

array

(

[

[

1

,

4

]

,

[

4

,

2

]

]

)

print

(

f

"\nEigenvalues of the symmetric matrix S: {np.linalg.eigvals(S)} (all real)"

)

Original prompt (Chinese, left untranslated)



特征值: [2. 1.]

特征向量 (列):

 [[1. 0.]

 [0. 1.]]

验证特征向量1: A@v=[2. 0.], λv=[2. 0.], 相等: True

对称矩阵 S 的特征值: [ 5. -2.](全实数)

Interactive eigenvector demonstration

Drag the blue vector v and observe its transformation by the matrix A = [[2,0],[0,1]], Av (red dashed line).

When v is in the horizontal or vertical direction, Av is collinear with v—this is the direction of the eigenvector:


Application Scenarios in AI

PCA Dimensionality Reduction

Calculate the eigenvalues and eigenvectors of the data covariance matrix. The eigenvectors corresponding to the largest k eigenvalues are the k directions with the largest data variance (principal components). By projecting the data onto these directions, directions with small variance are discarded, achieving dimensionality reduction. Reducing a 784-dimensional MNIST image to 50 dimensions can still retain about 90% of the information.

Spectral Normalization

In GAN training, the discriminator's weight matrix is spectrally normalized at each step: W ← W / \sigma_{max}(W), where \sigma_{max} is the largest singular value (or the absolute value of the largest eigenvalue for a square matrix). This ensures the discriminator is 1-Lipschitz, stabilizing training and reducing mode collapse.

Spectral Methods of Graph Neural Networks

The eigenvalues and eigenvectors of the graph Laplacian matrix L = D - A (where D is the degree diagonal matrix and A is the adjacency matrix) define the Fourier transform on the graph. GCN (Graph Convolutional Network) performs convolution in this spectral domain—although modern GCNs more often use spatial domain methods, spectral methods form the theoretical foundation.