# Nakafa Learning Content

> For AI agents: use [llms.txt](https://nakafa.com/llms.txt) for the site index. Markdown versions are available by appending `.md` to content URLs or sending `Accept: text/markdown`.

URL: https://nakafa.com/en/subjects/ai-ds/linear-methods/all-eigenvalues-calculation
Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/material/lesson/ai-ds/linear-methods/all-eigenvalues-calculation/en.mdx

Learn the QR method for calculating all eigenvalues through iterative matrix decomposition. Learn convergence properties and diagonal elements.

---

## QR Method for All Eigenvalues

Using the QR method, you can calculate all eigenvalues of matrix $$A$$. This process is carried out through iterations that gradually change the matrix form, like sharpening a knife repeatedly until it's sharp. Each iteration round makes the matrix increasingly approach a form that makes it easier for us to read its eigenvalues.

Visible text: Using the QR method, you can calculate all eigenvalues of matrix . This process is carried out through iterations that gradually change the matrix form, like sharpening a knife repeatedly until it's sharp. Each iteration round makes the matrix increasingly approach a form that makes it easier for us to read its eigenvalues.

## QR Algorithm

1. **Initial step** is to set $$A_0 := A$$ and $$k := 0$$

2. **Iteration process** that is repeated continuously. In each round, perform QR decomposition on matrix $$A_k$$

   <MathContainer>
   
   
   ```math
   Q_k \cdot R_k = A_k
   ```

   </MathContainer>

   After that, construct a new matrix by multiplying $$R_k$$ and $$Q_k$$ in reverse order

   <MathContainer>
   
   
   ```math
   A_{k+1} := R_k \cdot Q_k
   ```

   </MathContainer>

   Add one to the value of $$k$$ and check whether the iteration has reached a stable state

   <MathContainer>
   
   
   ```math
   \max_{j=1,\ldots,n} |(A_k)_{jj} - (A_{k-1})_{jj}| \leq \text{tolerance}
   ```

   </MathContainer>

   The iteration stops when the largest change in diagonal elements is already very small.

Visible text: 1. **Initial step** is to set and 

2. **Iteration process** that is repeated continuously. In each round, perform QR decomposition on matrix 

 <MathContainer>
 
 

 </MathContainer>

 After that, construct a new matrix by multiplying and in reverse order

 <MathContainer>
 
 

 </MathContainer>

 Add one to the value of and check whether the iteration has reached a stable state

 <MathContainer>
 
 

 </MathContainer>

 The iteration stops when the largest change in diagonal elements is already very small.

## Similarity Properties in Iteration

Every matrix $$A_k$$ that appears in the QR iteration has similar properties to the initial matrix $$A$$. This means the eigenvalues do not change during the iteration process.

Visible text: Every matrix that appears in the QR iteration has similar properties to the initial matrix . This means the eigenvalues do not change during the iteration process.

Like assembling the same puzzle in different ways. The puzzle pieces remain the same, but their arrangement can change. Likewise with our matrix, its mathematical content remains the same even though its structural form changes.

## Diagonal Element Convergence

If the condition $$|\lambda_1| > |\lambda_2| > \cdots > |\lambda_n|$$ holds, then the elements on the main diagonal of matrix $$A_k$$ will approach the corresponding eigenvalues

Visible text: If the condition holds, then the elements on the main diagonal of matrix will approach the corresponding eigenvalues

Component: MathContainer
Children:

```math
\lim_{k \to \infty} (A_k)_{jj} = \lambda_j, \quad j = 1, 2, \ldots, n
```

This process is like water flowing to the lowest place. The eigenvalues "fall" and occupy their respective diagonal positions according to their magnitude order.

## Non-Diagonal Element Convergence

If matrix $$A$$ is symmetric, all elements outside the main diagonal will approach zero when $$k \to \infty$$.

Visible text: If matrix is symmetric, all elements outside the main diagonal will approach zero when .

Conversely, if the matrix is not symmetric, only the elements below the main diagonal approach zero, while those above do not. Imagine it like organizing a closet. If the closet is symmetric, all items can be neatly arranged. But if it's not symmetric, some parts remain messy.