数值分析作业 - 矩阵特征值的数值解法
数值分析Problem 1

- 幂迭代: 找出绝对值最大的特征值, 为
- 逆向幂迭代: 找出离
最近的特征值, 为 - 幂迭代的线性收敛率满足
; 逆向幂迭代先平移为 再取倒数 此时 , 则有 , 逆向幂迭代收敛更快.
Problem 2

约化第一列
约化第二列
则有
Problem 3

使用 PyTorch 实现
幂迭代
1 | from typing import List, Tuple |
逆幂迭代
1 | def inverse_power_method(A: torch.Tensor, x0: torch.Tensor, limit: int, tol=1e-6) -> List[Tuple[float, torch.Tensor]]: |
运行算法求解矩阵
1 | A = torch.tensor([[8, -8, -4], [12, -15, -7], [-18, 26, 12]], dtype=torch.float64) |
输出
1 | Using the power method: |
接近理论结果.
Problem 4

QR 分解
1 | def qr_decomposition_full(A: torch.Tensor, eps=1e-8) -> Tuple[torch.Tensor, torch.Tensor]: |
QR 算法
1 | def qr_method(A: torch.Tensor, limit: int) -> Tuple[torch.Tensor, torch.Tensor]: |
运行求解
1 | print("Using the QR method:") |
输出:
1 | Using the QR method: |
注意到只有特征值