Back to topic
Optional
Power iteration: dominant eigenvalue
Run power iteration; match |λ| to np.linalg.eigvalsh/eig.
- Version
- v1
- Minutes
- ~20
- Evidence
- Self-check in the notebook
Until platform auto-check exists, compare cell output with the expected numbers in the notebook. This is not a debt and does not affect mastery.
Download the notebook and run it locally. Its environment requirements are listed inside.
Notebook contents
Readable on your phone. The code below has not been executed in the browser; download the notebook to run it.
Math · Степенной метод / Power iteration
Activity version: 1 · Seed: n/a · Данные: .
Ожидаемые числа
| Quantity | Value | Tolerance |
|---|---|---|
| dominant | abs ≤ 1e-6 | |
| abs ≤ 1e-9 |
Самопроверка в ноутбуке
Не влияет на mastery.
import numpy as np
A = np.array([[2.0, 1.0], [1.0, 2.0]])
v = np.array([1.0, 0.0])
for _ in range(40):
w = A @ v
v = w / np.linalg.norm(w)
lam = float(v @ A @ v)
print("lambda", lam, "v", v)
assert abs(lam - 3.0) < 1e-6
assert abs(np.linalg.norm(v) - 1.0) < 1e-9
print("OK: power iteration")