Add chapter on determining EV/EWs programmatically
This commit is contained in:
parent
94057431f0
commit
f4eac0a144
1 changed files with 51 additions and 0 deletions
|
@ -68,6 +68,7 @@
|
|||
- [Eigenwerte und Eigenvektoren](#eigenwerte-und-eigenvektoren)
|
||||
- [Numerische Bestimmung von Eigenwerten und Eigenvektoren](#numerische-bestimmung-von-eigenwerten-und-eigenvektoren)
|
||||
- [Theorie](#theorie)
|
||||
- [$QR$-Verfahren](#qr-verfahren)
|
||||
- [Formelbuchstaben](#formelbuchstaben)
|
||||
- [Glossar](#glossar)
|
||||
|
||||
|
@ -1531,6 +1532,56 @@ eine Diagonalmatrix ist.
|
|||
|
||||
</div>
|
||||
|
||||
#### $QR$-Verfahren
|
||||
Das $QR$-Verfahren ist ein iteratives Verfahren zur Bestimmung von Eigenwerten einer Matrix $A$.
|
||||
|
||||
Der Vorgang ist dabei folgender:
|
||||
|
||||
1. $A_0 = A$
|
||||
2. $P_0 = I_n$
|
||||
3. Für $i = 0, 1, 2, \dots, \infin$:
|
||||
1. $QR$-Zerlegung durchführen: $A_i = Q_i \cdot R_i$
|
||||
2. $A_{i + 1} = R_i \cdot Q_i$
|
||||
3. $P_{i + 1} = P_i \cdot Q_i$
|
||||
4. $P_i$ zurückgeben
|
||||
|
||||
***Code-Beispiel:***
|
||||
|
||||
```py
|
||||
from numpy import array, identity, sign, sqrt, square, sum, zeros
|
||||
|
||||
def qr(A):
|
||||
A = array(A)
|
||||
n = A.shape[0]
|
||||
R = A.reshape((n, n))
|
||||
Q = identity(n)
|
||||
|
||||
for i in range(n - 1):
|
||||
I = identity(n - i)
|
||||
Qi = identity(n)
|
||||
e = zeros((n - i, 1))
|
||||
e[0][0] = 1
|
||||
a = R[i:,i:i + 1]
|
||||
v = a + sign(a[0]) * sqrt(sum(square(a))) * e
|
||||
u = (1 / sqrt(sum(square(v)))) * v
|
||||
H = I - 2 * u @ u.T
|
||||
Qi[i:,i:] = H
|
||||
R = Qi @ R
|
||||
Q = Q @ Qi.T
|
||||
R[i + 1:,i:i + 1] = zeros((n - (i + 1), 1))
|
||||
return [Q, R]
|
||||
|
||||
def EV(A, iterations):
|
||||
A = array(A)
|
||||
n = A.shape[0]
|
||||
P = identity(n)
|
||||
for i in range(iterations):
|
||||
[Q, R] = qr(A)
|
||||
A = R @ Q
|
||||
P = P @ Q
|
||||
return [A, P]
|
||||
```
|
||||
|
||||
## Formelbuchstaben
|
||||
<div class="letters">
|
||||
|
||||
|
|
Loading…
Reference in a new issue