Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jakelevi1996/615c09214393f0fd8753a716f9d6c58b to your computer and use it in GitHub Desktop.
Save jakelevi1996/615c09214393f0fd8753a716f9d6c58b to your computer and use it in GitHub Desktop.
An impractical symmetric eigenvalue algorithm

An impractical symmetric eigenvalue algorithm

This Gist presents a conceptually straightforward (albeit practically sub-optimal) eigenvalue algorithm for a symmetric NxN matrix. It is inspired by "Chapter 7: Unsymmetric Eigenvalue Problems" of Matrix Computations, 4th Edition (Golub, Van Loan), and also uses Householder transformations/QR factorisation (see chapter 5 of Matrix Computations, or my earlier Gist), and the power method.

Let's say N = 5, and we want to find the eigenvalue decomposition for the 5x5 matrix A:

A =
[[ 9.776  2.782  2.048  0.418  3.66 ]
 [ 2.782  8.813  1.521  6.218  1.6  ]
 [ 2.048  1.521  3.848 -1.843  3.248]
 [ 0.418  6.218 -1.843  8.079 -2.016]
 [ 3.66   1.6    3.248 -2.016  3.564]]

That is, we want to find matrices U and D which satisfy A == U * D * U^T , where U is orthogonal (IE U * U^T equals the identity matrix) and D is diagonal; equivalently, these matrices satisfy A * U == U * D, and taking a single column of this matrix equation gives us the eigenvalue equation A * u == d * u, where u is a normalised eigenvector, and d is a scalar eigenvalue. Note that * is used to denote matrix or scalar multiplication (depending on the context), and ^T is used to denote the matrix transpose.

As a simple first step, we can use the power method to find the eigenvector corresponding to the largest eigenvalue, and this gives an eigenvalue of d = 16.004, and a corresponding normalised eigenvector u (which, as we know, satisfies the eigenvalue equation A * u == d * u):

u =
[[0.501]
 [0.68 ]
 [0.15 ]
 [0.475]
 [0.197]]

The challenge now is finding the remaining 4 eigenvalues and eigenvectors. The general approach used here for a given symmetric matrix A is as follows:

  1. Find an eigenvector u and associated eigenvalue d for the matrix A (EG using the power method)
  2. Find an orthogonal similarity transform represented by the matrix Q, which contains the known eigenvector u as a basis vector (in general this similarity transform will be non-unique, unless we restrict ourselves EG to a Householder transformation)
  3. Apply the similarity transform to the matrix A (IE calculate Q^T * A * Q) to transform it into a block-diagonal matrix with the same eigenvalues, which isolates the known eigenvalue and eigenvector while preserving the remaining unknown eigenvalues in a sub-matrix
  4. Recursively applying the same procedure to the isolated sub-matrix until it is a 1x1 matrix, at which point all of the eigenvalues are known, and all of the eigenvectors can be easily calculated

The trick used to convert A to block diagonal form can be seen as a generalisation of the observation that if U is the matrix of eigenvectors for A, then U^T * A * U == D, that is, if we apply a similarity transform to A, using the eigenvectors for A as the basis vectors of the similarity transform, then the result is a diagonal matrix, with eigenvalues on the diagonal.

Specifically, the trick (as described in Lemma 7.1.2 of Matrix Computations) is to realise that if we can find an invariant subspace of A (and we have just found one such subspace, which is the span of the eigenvector u, satisfying A * u == d * u), then we can reduce A to block triangular form (block diagonal form in this case, because A is symmetric) using similarity transforms (which, by definition, preserve the eigenvalues of A), and the required similarity transform comes from a (non-unique, unless we restrict ourselves to Householder transformations) QR decomposition of the Nx1 eigenvector u. From the block-diagonal matrix which is similar to A, we can easily find the eigenvector for the next-largest eigenvalue by once again using the power method on one of the blocks.

Performing a QR decomposition of u gives u == Q * R (where the first column of Q is equal to u, and all of the columns are mutually orthogonal), and therefore A * Q * R == d * Q * R, where R is also an Nx1 vector, and is "upper triangular" (which, in the context of a vector, means that only its first element is non-zero, and all its other elements are equal to zero). Pre-multiplying by Q^T gives us the equation Q^T * A * Q * R == d * R, and because the sub-diagonal of R is zero, we see that Q^T * A * Q must be block-triangular, and because A is symmetric, we see further that Q^T * A * Q must be block-diagonal (this is more easily seen by drawing out the block structures of R and Q^T * A * Q explicitly).

We can also interpret the equation Q^T * A * Q * R == d * R as an eigenvalue equation for the matrix Q^T * A * Q, which is similar to A, and therefore has the same eigenvalues (the explicit one here being d, which we just found using the power method).

We can also think of Q^T * A * Q as the matrix of the linear operator which A represents, expressed in the orthogonal basis Q, which contains one of the eigenvectors of A as a basis vector.

Indeed, we see that Q^T * A * Q is block diagonal:

Q =
[[ 0.501  0.68   0.15   0.475  0.197]
 [ 0.68   0.074 -0.204 -0.647 -0.268]
 [ 0.15  -0.204  0.955 -0.143 -0.059]
 [ 0.475 -0.647 -0.143  0.548 -0.187]
 [ 0.197 -0.268 -0.059 -0.187  0.922]]

Q^T * A * Q =
[[16.004  0.     0.    -0.     0.   ]
 [ 0.     4.838  2.597  1.365  4.336]
 [ 0.     2.597  4.517 -1.55   4.418]
 [-0.     1.365 -1.55   3.238 -0.707]
 [ 0.     4.336  4.418 -0.707  5.482]]

We see that Q^T * A * Q is block diagonal, with the eigenvalue which we have already calculated forming one of the blocks. This is a consequence of choosing a set of orthogonal basis vectors Q, in which one of the basis vectors is an eigenvalue of A. Another way to look at this is to look at the first column of A * Q, which is A * u == d * u; looking at the first element of Q^T * A * u we have u^T * d * u == d, and all the other elements of Q^T * A * u must be zero, because Q is orthogonal. This gives us that the first column is all zero below the first element, and because the matrix is symmetric, it must be block diagonal.

Because Q^T * A * Q is symmetric, and its eigenvectors are orthogonal, we can therefore deduce that any eigenvector of Q^T * A * Q other than R must be orthogonal to R, and therefore must have zero as its first element. The useful consequence of this, is that now we can just look at finding the eigenvectors of the 4x4 submatrix A':

A' =
[[ 4.838  2.597  1.365  4.336]
 [ 2.597  4.517 -1.55   4.418]
 [ 1.365 -1.55   3.238 -0.707]
 [ 4.336  4.418 -0.707  5.482]]

Now, any eigenvector of A' can be converted into an eigenvector of Q^T * A * Q by prepending a zero as its first element to form u', and we can convert this into an eigenvector for A by pre-multiplying u' by Q. This eigenvector and associated eigenvalue for A' can be found using the power method on A'. Once this is done, we can form a new similarity transform using the QR decomposition of the new eigenvector from A', to find a block diagonal matrix which is similar to A', and then use the power method to find an eigenvector of the non-scalar block, and so on, recursively using the power method on a sub-block to find an eigenvector, and using a QR decomposition of the eigenvector to find a unitarily similar block-triangular matrix, containing a smaller sub-block on which we can use the power method, until we have found all of the eigenvectors and eigenvalues of the matrix.

This is summarised in the Python function eig in the script eig.py below, along with the outputs from running eig.py with N = 5 and N = 10 (note that this function could be made more computationally efficient in many ways, for example to use appropriate matrix-vector multiplication and matrix-matrix subtraction instead of matrix-matrix multiplication using Householder matrices, however computational efficiency is not really the aim of this Gist):

import numpy as np
np.set_printoptions(precision=3, linewidth=1000, suppress=True)
np.random.seed(1232)
norm = lambda x: np.sqrt(np.sum(np.square(x)))
def print_power_method(i, u, A, u_old):
""" Print progress on using the power method to approximate the eigenvector
corresponding to the largest eigenvalue of A, where u is the current
estimate for the eigenvector """
print("%2i" % i, u.T @ A @ u, u.T, "%.8f" % (norm(u - u_old) / norm(u_old)))
def print_block_diagonalised(A, Q):
""" Print the matrices A, Q, and Q^T * A * Q, where Q is orthogonal, and Q^T
* A * Q is block-diagonal and similar to A """
print("A = ", A, "Q = ", Q, "Q^T * A * Q =", Q.T @ A @ Q, sep="\n")
print("*" * 100)
def eig(A, N, tol=1e-5, verbosity=0):
""" Perform an eigenvalue decomposition of the symmetric NxN matrix A """
eig_list = []
Q_list = []
for n in range(N, 1, -1):
i = 0
# Initial guess for eigenvector
u = np.random.normal(size=[n, 1])
# Find the eigenvector of the largest eigenvalue using power method
while True:
u_old = u
u = A @ u
u *= (np.sign(u[0]) / norm(u))
if verbosity >= 2:
print_power_method(i, u, A, u_old)
i += 1
if norm(u - u_old) < tol * norm(u_old):
break
# Calculate the corresponding eigenvalue
eig = u.T @ A @ u
# QR decomposition of the normalised eigenvector using Householder
u[0] -= 1
Q = np.identity(n) - (2 / (np.sum(np.square(u)))) * np.outer(u, u)
if verbosity >= 1:
print_block_diagonalised(A, Q)
# Store the eigenvalue and orthogonal basis matrix
eig_list.append(float(eig))
Q_list.append(Q)
# Next iteration, look at the sub-matrix in the orthogonal basis
A = (Q.T @ A @ Q)[1:, 1:]
# Store the final eigenvalue
eig_list.append(float(A))
# Formulate the final matrix of eigenvectors
Q = np.identity(N)
for Q_i, n in zip(reversed(Q_list), range(2, N + 1)):
Q[-n:, -n:] = Q_i @ Q[-n:, -n:]
return eig_list, Q
if __name__ == "__main__":
# Matrix size
# N = 10
N = 5
# Generate matrix that we will decompose
A = np.random.normal(size=[N, N])
A = A @ A.T
# Perform eigenvalue decomposition
eig_list, Q = eig(A, N, verbosity=2)
# Print results
D = np.diag(eig_list)
print("*" * 100)
print("A =", A, "D =", D, "Q =", Q, "Q * D * Q^T =", Q @ D @ Q.T, sep="\n")
print("Orthogonality (Q * Q^T) =", Q @ Q.T, sep="\n")
print("Error ((Q @ D @ Q.T) - A) =", (Q @ D @ Q.T) - A, sep="\n")
0 [[13.678]] [[ 0.247 0.484 -0.26 0.766 -0.225]] 1.43934773
1 [[14.893]] [[ 0.193 0.636 -0.135 0.727 -0.108]] 0.23901492
2 [[15.291]] [[ 0.219 0.685 -0.056 0.691 -0.037]] 0.12447800
3 [[15.526]] [[ 0.266 0.703 -0.008 0.659 0.012]] 0.09164047
4 [[15.689]] [[0.312 0.709 0.026 0.629 0.051]] 0.07541006
5 [[15.799]] [[0.352 0.71 0.053 0.603 0.081]] 0.06217882
6 [[15.873]] [[0.384 0.707 0.073 0.58 0.105]] 0.05064878
7 [[15.921]] [[0.409 0.704 0.089 0.56 0.125]] 0.04084594
8 [[15.951]] [[0.429 0.701 0.102 0.543 0.14 ]] 0.03271747
9 [[15.971]] [[0.444 0.697 0.112 0.53 0.152]] 0.02609147
10 [[15.983]] [[0.456 0.694 0.12 0.519 0.161]] 0.02074902
11 [[15.991]] [[0.466 0.692 0.126 0.51 0.169]] 0.01647116
12 [[15.996]] [[0.473 0.689 0.131 0.503 0.175]] 0.01306061
13 [[15.999]] [[0.479 0.688 0.135 0.497 0.179]] 0.01034895
14 [[16.001]] [[0.484 0.686 0.138 0.493 0.183]] 0.00819666
15 [[16.002]] [[0.487 0.685 0.141 0.489 0.186]] 0.00649018
16 [[16.003]] [[0.49 0.684 0.143 0.486 0.188]] 0.00513808
17 [[16.003]] [[0.492 0.683 0.144 0.484 0.19 ]] 0.00406722
18 [[16.004]] [[0.494 0.682 0.146 0.482 0.192]] 0.00321932
19 [[16.004]] [[0.496 0.682 0.146 0.48 0.193]] 0.00254808
20 [[16.004]] [[0.497 0.682 0.147 0.479 0.194]] 0.00201674
21 [[16.004]] [[0.497 0.681 0.148 0.478 0.194]] 0.00159617
22 [[16.004]] [[0.498 0.681 0.148 0.478 0.195]] 0.00126329
23 [[16.004]] [[0.499 0.681 0.149 0.477 0.195]] 0.00099983
24 [[16.004]] [[0.499 0.681 0.149 0.477 0.196]] 0.00079131
25 [[16.004]] [[0.499 0.68 0.149 0.476 0.196]] 0.00062627
26 [[16.004]] [[0.5 0.68 0.149 0.476 0.196]] 0.00049566
27 [[16.004]] [[0.5 0.68 0.15 0.476 0.196]] 0.00039228
28 [[16.004]] [[0.5 0.68 0.15 0.476 0.196]] 0.00031047
29 [[16.004]] [[0.5 0.68 0.15 0.475 0.197]] 0.00024572
30 [[16.004]] [[0.5 0.68 0.15 0.475 0.197]] 0.00019447
31 [[16.004]] [[0.5 0.68 0.15 0.475 0.197]] 0.00015391
32 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00012181
33 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00009641
34 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00007630
35 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00006039
36 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00004779
37 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00003782
38 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00002994
39 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00002369
40 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00001875
41 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00001484
42 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00001175
43 [[16.004]] [[0.501 0.68 0.15 0.475 0.197]] 0.00000930
A =
[[ 9.776 2.782 2.048 0.418 3.66 ]
[ 2.782 8.813 1.521 6.218 1.6 ]
[ 2.048 1.521 3.848 -1.843 3.248]
[ 0.418 6.218 -1.843 8.079 -2.016]
[ 3.66 1.6 3.248 -2.016 3.564]]
Q =
[[ 0.501 0.68 0.15 0.475 0.197]
[ 0.68 0.074 -0.204 -0.647 -0.268]
[ 0.15 -0.204 0.955 -0.143 -0.059]
[ 0.475 -0.647 -0.143 0.548 -0.187]
[ 0.197 -0.268 -0.059 -0.187 0.922]]
Q^T * A * Q =
[[16.004 0. 0. -0. 0. ]
[ 0. 4.838 2.597 1.365 4.336]
[ 0. 2.597 4.517 -1.55 4.418]
[-0. 1.365 -1.55 3.238 -0.707]
[ 0. 4.336 4.418 -0.707 5.482]]
****************************************************************************************************
0 [[10.98]] [[ 0.242 0.635 -0.424 0.599]] 0.63938786
1 [[12.367]] [[ 0.423 0.594 -0.214 0.65 ]] 0.28454345
2 [[12.621]] [[ 0.491 0.561 -0.12 0.656]] 0.12088736
3 [[12.66]] [[ 0.515 0.545 -0.083 0.656]] 0.04683984
4 [[12.665]] [[ 0.524 0.539 -0.069 0.655]] 0.01788014
5 [[12.666]] [[ 0.528 0.537 -0.064 0.655]] 0.00681037
6 [[12.666]] [[ 0.529 0.536 -0.062 0.655]] 0.00259318
7 [[12.666]] [[ 0.53 0.536 -0.061 0.655]] 0.00098735
8 [[12.666]] [[ 0.53 0.535 -0.061 0.655]] 0.00037593
9 [[12.666]] [[ 0.53 0.535 -0.06 0.655]] 0.00014314
10 [[12.666]] [[ 0.53 0.535 -0.06 0.655]] 0.00005450
11 [[12.666]] [[ 0.53 0.535 -0.06 0.655]] 0.00002075
12 [[12.666]] [[ 0.53 0.535 -0.06 0.655]] 0.00000790
A =
[[ 4.838 2.597 1.365 4.336]
[ 2.597 4.517 -1.55 4.418]
[ 1.365 -1.55 3.238 -0.707]
[ 4.336 4.418 -0.707 5.482]]
Q =
[[ 0.53 0.535 -0.06 0.655]
[ 0.535 0.39 0.069 -0.746]
[-0.06 0.069 0.992 0.084]
[ 0.655 -0.746 0.084 0.088]]
Q^T * A * Q =
[[12.666 0. 0. 0. ]
[ 0. 0.28 0.816 0.555]
[ 0. 0.816 2.758 2.038]
[ 0. 0.555 2.038 2.371]]
****************************************************************************************************
0 [[4.802]] [[0.196 0.682 0.704]] 0.69785069
1 [[4.822]] [[0.208 0.723 0.659]] 0.06214617
2 [[4.823]] [[0.21 0.727 0.653]] 0.00714314
3 [[4.823]] [[0.211 0.728 0.653]] 0.00082192
4 [[4.823]] [[0.211 0.728 0.653]] 0.00009457
5 [[4.823]] [[0.211 0.728 0.653]] 0.00001088
6 [[4.823]] [[0.211 0.728 0.653]] 0.00000125
A =
[[0.28 0.816 0.555]
[0.816 2.758 2.038]
[0.555 2.038 2.371]]
Q =
[[ 0.211 0.728 0.653]
[ 0.728 0.329 -0.602]
[ 0.653 -0.602 0.46 ]]
Q^T * A * Q =
[[ 4.823 0. -0. ]
[ 0. 0.403 -0.237]
[-0. -0.237 0.184]]
****************************************************************************************************
0 [[0.554]] [[ 0.863 -0.505]] 12.24688900
1 [[0.555]] [[ 0.844 -0.536]] 0.03706131
2 [[0.555]] [[ 0.843 -0.538]] 0.00213924
3 [[0.555]] [[ 0.843 -0.538]] 0.00012341
4 [[0.555]] [[ 0.843 -0.538]] 0.00000712
A =
[[ 0.403 -0.237]
[-0.237 0.184]]
Q =
[[ 0.843 -0.538]
[-0.538 -0.843]]
Q^T * A * Q =
[[0.555 0. ]
[0. 0.032]]
****************************************************************************************************
****************************************************************************************************
A =
[[ 9.776 2.782 2.048 0.418 3.66 ]
[ 2.782 8.813 1.521 6.218 1.6 ]
[ 2.048 1.521 3.848 -1.843 3.248]
[ 0.418 6.218 -1.843 8.079 -2.016]
[ 3.66 1.6 3.248 -2.016 3.564]]
D =
[[16.004 0. 0. 0. 0. ]
[ 0. 12.666 0. 0. 0. ]
[ 0. 0. 4.823 0. 0. ]
[ 0. 0. 0. 0.555 0. ]
[ 0. 0. 0. 0. 0.032]]
Q =
[[ 0.501 0.541 0.653 0.061 -0.165]
[ 0.68 -0.207 -0.392 -0.473 -0.342]
[ 0.15 0.373 -0.551 0.688 -0.248]
[ 0.475 -0.575 0.171 0.493 0.414]
[ 0.197 0.442 -0.296 -0.235 0.79 ]]
Q * D * Q^T =
[[ 9.776 2.782 2.048 0.418 3.66 ]
[ 2.782 8.813 1.521 6.218 1.6 ]
[ 2.048 1.521 3.848 -1.843 3.248]
[ 0.418 6.218 -1.843 8.079 -2.016]
[ 3.66 1.6 3.248 -2.016 3.564]]
Orthogonality (Q * Q^T) =
[[ 1. -0. 0. -0. -0.]
[-0. 1. 0. 0. 0.]
[ 0. 0. 1. 0. 0.]
[-0. 0. 0. 1. 0.]
[-0. 0. 0. 0. 1.]]
Error ((Q @ D @ Q.T) - A) =
[[-0. -0. -0. 0. -0.]
[-0. 0. -0. 0. -0.]
[-0. -0. 0. -0. -0.]
[ 0. 0. -0. 0. -0.]
[-0. -0. -0. -0. -0.]]
0 [[19.682]] [[ 0.097 0.473 0.257 -0.512 0.338 -0.034 0.296 0.123 -0.009 -0.47 ]] 1.27884118
1 [[33.057]] [[ 0.424 0.489 0.298 -0.309 0.088 0.194 0.426 0.193 0.06 -0.358]] 0.55088506
2 [[36.578]] [[ 0.549 0.454 0.301 -0.184 -0.04 0.295 0.42 0.194 0.087 -0.24 ]] 0.27228050
3 [[36.992]] [[ 0.582 0.441 0.303 -0.139 -0.075 0.327 0.407 0.186 0.089 -0.189]] 0.09166302
4 [[37.043]] [[ 0.591 0.438 0.306 -0.123 -0.082 0.338 0.4 0.18 0.087 -0.168]] 0.03165012
5 [[37.051]] [[ 0.594 0.439 0.307 -0.118 -0.083 0.343 0.398 0.176 0.085 -0.16 ]] 0.01257722
6 [[37.053]] [[ 0.595 0.44 0.308 -0.115 -0.082 0.344 0.396 0.174 0.083 -0.156]] 0.00577005
7 [[37.054]] [[ 0.595 0.44 0.309 -0.114 -0.081 0.345 0.396 0.173 0.083 -0.155]] 0.00288313
8 [[37.054]] [[ 0.596 0.441 0.309 -0.114 -0.081 0.345 0.396 0.172 0.082 -0.154]] 0.00149382
9 [[37.054]] [[ 0.596 0.441 0.309 -0.113 -0.081 0.346 0.395 0.172 0.082 -0.153]] 0.00078437
10 [[37.054]] [[ 0.596 0.441 0.31 -0.113 -0.08 0.346 0.395 0.172 0.082 -0.153]] 0.00041382
11 [[37.054]] [[ 0.596 0.441 0.31 -0.113 -0.08 0.346 0.395 0.172 0.082 -0.153]] 0.00021871
12 [[37.054]] [[ 0.596 0.441 0.31 -0.113 -0.08 0.346 0.395 0.172 0.082 -0.153]] 0.00011567
13 [[37.054]] [[ 0.596 0.441 0.31 -0.113 -0.08 0.346 0.395 0.172 0.082 -0.153]] 0.00006119
14 [[37.054]] [[ 0.596 0.441 0.31 -0.113 -0.08 0.346 0.395 0.172 0.082 -0.153]] 0.00003238
15 [[37.054]] [[ 0.596 0.441 0.31 -0.113 -0.08 0.346 0.395 0.172 0.082 -0.153]] 0.00001713
16 [[37.054]] [[ 0.596 0.441 0.31 -0.113 -0.08 0.346 0.395 0.172 0.082 -0.153]] 0.00000907
A =
[[18.589 8.267 6.434 0.92 -1.307 5.075 6.32 2.041 3.359 -3.134]
[ 8.267 11.927 5.84 -0.467 2.509 5.795 6.072 -0.152 -1.337 -1.535]
[ 6.434 5.84 6.524 -1.922 0.948 5.099 3.187 0.236 -0.922 0.557]
[ 0.92 -0.467 -1.922 8.572 1.216 -1.798 -2.555 -4.75 -0.018 2.766]
[-1.307 2.509 0.948 1.216 8.78 -2.44 -1.953 -4.799 -1.691 1.142]
[ 5.075 5.795 5.099 -1.798 -2.44 9.741 5.231 2.573 -0.937 3.572]
[ 6.32 6.072 3.187 -2.555 -1.953 5.231 8.81 3.573 2.271 -4.443]
[ 2.041 -0.152 0.236 -4.75 -4.799 2.573 3.573 7.532 1.269 -3.391]
[ 3.359 -1.337 -0.922 -0.018 -1.691 -0.937 2.271 1.269 5.251 -3.576]
[-3.134 -1.535 0.557 2.766 1.142 3.572 -4.443 -3.391 -3.576 9.758]]
Q =
[[ 0.596 0.441 0.31 -0.113 -0.08 0.346 0.395 0.172 0.082 -0.153]
[ 0.441 0.518 -0.338 0.123 0.088 -0.377 -0.431 -0.187 -0.089 0.167]
[ 0.31 -0.338 0.763 0.087 0.061 -0.265 -0.303 -0.131 -0.063 0.117]
[-0.113 0.123 0.087 0.968 -0.022 0.097 0.111 0.048 0.023 -0.043]
[-0.08 0.088 0.061 -0.022 0.984 0.069 0.078 0.034 0.016 -0.03 ]
[ 0.346 -0.377 -0.265 0.097 0.069 0.704 -0.338 -0.147 -0.07 0.131]
[ 0.395 -0.431 -0.303 0.111 0.078 -0.338 0.614 -0.168 -0.08 0.149]
[ 0.172 -0.187 -0.131 0.048 0.034 -0.147 -0.168 0.927 -0.035 0.065]
[ 0.082 -0.089 -0.063 0.023 0.016 -0.07 -0.08 -0.035 0.983 0.031]
[-0.153 0.167 0.117 -0.043 -0.03 0.131 0.149 0.065 0.031 0.942]]
Q^T * A * Q =
[[37.054 0. 0. 0. 0. 0. -0. -0. -0. 0. ]
[ 0. 7.98 3.761 3.862 3.441 1.17 1.352 -2.97 -0.075 -0.463]
[ 0. 3.761 5.549 0.939 1.476 2.394 0.493 -1.473 0.091 1.07 ]
[ 0. 3.862 0.939 6.612 0.374 1.988 1.626 -2.736 0.274 1.342]
[ 0. 3.441 1.476 0.374 8.572 -1.432 -0.904 -4.204 -1.881 0.873]
[ 0. 1.17 2.394 1.988 -1.432 4.917 0.16 -0.231 -0.232 4.942]
[-0. 1.352 0.493 1.626 -0.904 0.16 3.522 0.588 3.182 -3.073]
[-0. -2.97 -1.473 -2.736 -4.204 -0.231 0.588 5.936 1.523 -2.53 ]
[-0. -0.075 0.091 0.274 -1.881 -0.232 3.182 1.523 5.854 -4.068]
[ 0. -0.463 1.07 1.342 0.873 4.942 -3.073 -2.53 -4.068 9.489]]
****************************************************************************************************
0 [[16.634]] [[ 0.27 0.325 0.278 -0.087 0.505 -0.12 -0.209 -0.168 0.629]] 0.70126778
1 [[18.323]] [[ 0.287 0.296 0.311 0.111 0.434 -0.109 -0.289 -0.24 0.617]] 0.24138866
2 [[19.072]] [[ 0.32 0.282 0.308 0.225 0.366 -0.119 -0.346 -0.265 0.579]] 0.15586784
3 [[19.382]] [[ 0.346 0.277 0.303 0.292 0.319 -0.121 -0.377 -0.273 0.542]] 0.09919102
4 [[19.507]] [[ 0.364 0.276 0.3 0.332 0.29 -0.118 -0.395 -0.273 0.512]] 0.06279014
5 [[19.561]] [[ 0.378 0.277 0.3 0.355 0.272 -0.114 -0.404 -0.27 0.491]] 0.04056773
6 [[19.585]] [[ 0.388 0.279 0.301 0.369 0.26 -0.11 -0.41 -0.266 0.476]] 0.02699279
7 [[19.596]] [[ 0.396 0.28 0.302 0.377 0.253 -0.106 -0.414 -0.263 0.465]] 0.01847534
8 [[19.602]] [[ 0.401 0.282 0.303 0.382 0.249 -0.103 -0.416 -0.259 0.457]] 0.01293317
9 [[19.605]] [[ 0.405 0.283 0.305 0.386 0.246 -0.1 -0.417 -0.257 0.451]] 0.00919867
10 [[19.606]] [[ 0.408 0.284 0.306 0.388 0.244 -0.098 -0.418 -0.255 0.447]] 0.00661103
11 [[19.607]] [[ 0.41 0.284 0.306 0.389 0.243 -0.097 -0.419 -0.253 0.444]] 0.00478229
12 [[19.607]] [[ 0.412 0.285 0.307 0.39 0.242 -0.096 -0.419 -0.252 0.442]] 0.00347305
13 [[19.608]] [[ 0.413 0.285 0.308 0.391 0.241 -0.095 -0.42 -0.251 0.441]] 0.00252815
14 [[19.608]] [[ 0.414 0.286 0.308 0.391 0.241 -0.094 -0.42 -0.251 0.44 ]] 0.00184285
15 [[19.608]] [[ 0.415 0.286 0.308 0.391 0.241 -0.094 -0.42 -0.25 0.439]] 0.00134440
16 [[19.608]] [[ 0.415 0.286 0.309 0.392 0.24 -0.094 -0.42 -0.25 0.438]] 0.00098122
17 [[19.608]] [[ 0.415 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.25 0.438]] 0.00071635
18 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.25 0.437]] 0.00052306
19 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00038196
20 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00027894
21 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00020371
22 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00014877
23 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00010865
24 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00007935
25 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00005795
26 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00004232
27 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00003091
28 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00002258
29 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00001649
30 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00001204
31 [[19.608]] [[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]] 0.00000879
A =
[[ 7.98 3.761 3.862 3.441 1.17 1.352 -2.97 -0.075 -0.463]
[ 3.761 5.549 0.939 1.476 2.394 0.493 -1.473 0.091 1.07 ]
[ 3.862 0.939 6.612 0.374 1.988 1.626 -2.736 0.274 1.342]
[ 3.441 1.476 0.374 8.572 -1.432 -0.904 -4.204 -1.881 0.873]
[ 1.17 2.394 1.988 -1.432 4.917 0.16 -0.231 -0.232 4.942]
[ 1.352 0.493 1.626 -0.904 0.16 3.522 0.588 3.182 -3.073]
[-2.97 -1.473 -2.736 -4.204 -0.231 0.588 5.936 1.523 -2.53 ]
[-0.075 0.091 0.274 -1.881 -0.232 3.182 1.523 5.854 -4.068]
[-0.463 1.07 1.342 0.873 4.942 -3.073 -2.53 -4.068 9.489]]
Q =
[[ 0.416 0.286 0.309 0.392 0.24 -0.093 -0.42 -0.249 0.437]
[ 0.286 0.859 -0.152 -0.192 -0.118 0.045 0.206 0.122 -0.214]
[ 0.309 -0.152 0.836 -0.208 -0.127 0.049 0.223 0.132 -0.231]
[ 0.392 -0.192 -0.208 0.737 -0.161 0.062 0.282 0.167 -0.293]
[ 0.24 -0.118 -0.127 -0.161 0.901 0.038 0.173 0.102 -0.179]
[-0.093 0.045 0.049 0.062 0.038 0.985 -0.067 -0.04 0.069]
[-0.42 0.206 0.223 0.282 0.173 -0.067 0.697 -0.179 0.314]
[-0.249 0.122 0.132 0.167 0.102 -0.04 -0.179 0.894 0.186]
[ 0.437 -0.214 -0.231 -0.293 -0.179 0.069 0.314 0.186 0.673]]
Q^T * A * Q =
[[19.608 0. 0. 0. 0. 0. -0. 0. -0. ]
[ 0. 6.44 1.804 1.858 2.169 1.465 -1.53 0.884 -0.612]
[ 0. 1.804 7.441 0.654 1.664 2.707 -2.656 1.213 -0.62 ]
[ 0. 1.858 0.654 7.947 -2.442 0.698 -3.052 -0.067 -2.707]
[ 0. 2.169 1.664 -2.442 3.915 1.289 1.146 1.276 2.053]
[ 0. 1.465 2.707 0.698 1.289 2.8 -1.243 1.83 -0.608]
[-0. -1.53 -2.656 -3.052 1.146 -1.243 4.185 -0.728 1.844]
[ 0. 0.884 1.213 -0.067 1.276 1.83 -0.728 3.802 -0.217]
[-0. -0.612 -0.62 -2.707 2.053 -0.608 1.844 -0.217 2.292]]
****************************************************************************************************
0 [[11.916]] [[ 0.241 0.142 0.765 -0.104 0.35 -0.173 0.273 -0.316]] 1.21486123
1 [[13.93]] [[ 0.332 0.296 0.669 -0.123 0.239 -0.405 0.163 -0.302]] 0.34645867
2 [[14.152]] [[ 0.353 0.367 0.617 -0.105 0.232 -0.439 0.133 -0.291]] 0.10367699
3 [[14.226]] [[ 0.364 0.405 0.588 -0.083 0.242 -0.443 0.134 -0.28 ]] 0.05535895
4 [[14.266]] [[ 0.373 0.427 0.568 -0.063 0.251 -0.442 0.141 -0.272]] 0.03979124
5 [[14.288]] [[ 0.38 0.442 0.553 -0.047 0.259 -0.44 0.147 -0.265]] 0.03016614
6 [[14.302]] [[ 0.386 0.453 0.541 -0.035 0.265 -0.438 0.153 -0.259]] 0.02300871
7 [[14.31]] [[ 0.39 0.46 0.532 -0.026 0.269 -0.436 0.157 -0.255]] 0.01754382
8 [[14.314]] [[ 0.394 0.466 0.525 -0.018 0.272 -0.434 0.161 -0.252]] 0.01336532
9 [[14.317]] [[ 0.396 0.47 0.52 -0.013 0.275 -0.433 0.163 -0.249]] 0.01017547
10 [[14.318]] [[ 0.398 0.473 0.516 -0.009 0.276 -0.432 0.165 -0.247]] 0.00774377
11 [[14.319]] [[ 0.399 0.476 0.512 -0.005 0.278 -0.431 0.166 -0.246]] 0.00589175
12 [[14.32]] [[ 0.401 0.478 0.51 -0.003 0.279 -0.431 0.167 -0.245]] 0.00448202
13 [[14.32]] [[ 0.401 0.479 0.508 -0.001 0.28 -0.43 0.168 -0.244]] 0.00340931
14 [[14.32]] [[ 0.402 0.48 0.507 0. 0.28 -0.43 0.169 -0.243]] 0.00259322
15 [[14.32]] [[ 0.403 0.481 0.506 0.001 0.281 -0.43 0.169 -0.242]] 0.00197242
16 [[14.32]] [[ 0.403 0.481 0.505 0.002 0.281 -0.43 0.17 -0.242]] 0.00150021
17 [[14.32]] [[ 0.403 0.482 0.504 0.003 0.281 -0.43 0.17 -0.242]] 0.00114104
18 [[14.32]] [[ 0.403 0.482 0.504 0.003 0.281 -0.429 0.17 -0.242]] 0.00086785
19 [[14.32]] [[ 0.404 0.482 0.504 0.004 0.282 -0.429 0.17 -0.241]] 0.00066007
20 [[14.32]] [[ 0.404 0.483 0.503 0.004 0.282 -0.429 0.17 -0.241]] 0.00050204
21 [[14.32]] [[ 0.404 0.483 0.503 0.004 0.282 -0.429 0.17 -0.241]] 0.00038184
22 [[14.32]] [[ 0.404 0.483 0.503 0.004 0.282 -0.429 0.171 -0.241]] 0.00029042
23 [[14.32]] [[ 0.404 0.483 0.503 0.004 0.282 -0.429 0.171 -0.241]] 0.00022089
24 [[14.32]] [[ 0.404 0.483 0.503 0.004 0.282 -0.429 0.171 -0.241]] 0.00016800
25 [[14.32]] [[ 0.404 0.483 0.503 0.004 0.282 -0.429 0.171 -0.241]] 0.00012778
26 [[14.32]] [[ 0.404 0.483 0.503 0.005 0.282 -0.429 0.171 -0.241]] 0.00009718
27 [[14.32]] [[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]] 0.00007392
28 [[14.32]] [[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]] 0.00005622
29 [[14.32]] [[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]] 0.00004276
30 [[14.32]] [[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]] 0.00003252
31 [[14.32]] [[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]] 0.00002473
32 [[14.32]] [[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]] 0.00001881
33 [[14.32]] [[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]] 0.00001431
34 [[14.32]] [[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]] 0.00001088
35 [[14.32]] [[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]] 0.00000828
A =
[[ 6.44 1.804 1.858 2.169 1.465 -1.53 0.884 -0.612]
[ 1.804 7.441 0.654 1.664 2.707 -2.656 1.213 -0.62 ]
[ 1.858 0.654 7.947 -2.442 0.698 -3.052 -0.067 -2.707]
[ 2.169 1.664 -2.442 3.915 1.289 1.146 1.276 2.053]
[ 1.465 2.707 0.698 1.289 2.8 -1.243 1.83 -0.608]
[-1.53 -2.656 -3.052 1.146 -1.243 4.185 -0.728 1.844]
[ 0.884 1.213 -0.067 1.276 1.83 -0.728 3.802 -0.217]
[-0.612 -0.62 -2.707 2.053 -0.608 1.844 -0.217 2.292]]
Q =
[[ 0.404 0.483 0.502 0.005 0.282 -0.429 0.171 -0.241]
[ 0.483 0.608 -0.407 -0.004 -0.229 0.348 -0.138 0.195]
[ 0.502 -0.407 0.577 -0.004 -0.238 0.362 -0.144 0.203]
[ 0.005 -0.004 -0.004 1. -0.002 0.003 -0.001 0.002]
[ 0.282 -0.229 -0.238 -0.002 0.867 0.203 -0.081 0.114]
[-0.429 0.348 0.362 0.003 0.203 0.691 0.123 -0.173]
[ 0.171 -0.138 -0.144 -0.001 -0.081 0.123 0.951 0.069]
[-0.241 0.195 0.203 0.002 0.114 -0.173 0.069 0.903]]
Q^T * A * Q =
[[14.32 0. -0. 0. 0. -0. 0. 0. ]
[ 0. 5.185 -1.705 3.387 1.725 -0.595 0.616 0.736]
[-0. -1.705 5.48 -0.651 -0.33 -0.897 -0.693 -1.289]
[ 0. 3.387 -0.651 3.949 2.297 -0.383 1.887 1.197]
[ 0. 1.725 -0.33 2.297 2.422 -0.337 1.6 0.017]
[-0. -0.595 -0.897 -0.383 -0.337 2.304 -0.177 0.611]
[ 0. 0.616 -0.693 1.887 1.6 -0.177 3.662 0.163]
[ 0. 0.736 -1.289 1.197 0.017 0.611 0.163 1.5 ]]
****************************************************************************************************
0 [[2.72]] [[ 0.166 -0.179 -0.185 -0.121 0.938 -0.082 -0.073]] 0.77248711
1 [[5.148]] [[ 0.099 0.537 0.279 0.246 -0.69 0.239 -0.174]] 1.90528653
2 [[6.224]] [[ 0.257 0.586 0.397 0.339 -0.454 0.29 -0.17 ]] 0.32906366
3 [[7.516]] [[ 0.398 0.435 0.516 0.399 -0.33 0.332 -0.088]] 0.29010422
4 [[9.203]] [[ 0.516 0.179 0.588 0.42 -0.231 0.355 0.01 ]] 0.32435514
5 [[10.303]] [[ 0.572 -0.05 0.597 0.404 -0.149 0.348 0.083]] 0.26033608
6 [[10.72]] [[ 0.588 -0.19 0.582 0.38 -0.097 0.333 0.124]] 0.15953448
7 [[10.845]] [[ 0.59 -0.265 0.567 0.362 -0.069 0.321 0.145]] 0.08685492
8 [[10.879]] [[ 0.59 -0.304 0.557 0.352 -0.053 0.314 0.156]] 0.04552908
9 [[10.888]] [[ 0.589 -0.323 0.552 0.347 -0.045 0.31 0.161]] 0.02361270
10 [[10.891]] [[ 0.588 -0.333 0.549 0.344 -0.041 0.308 0.164]] 0.01221084
11 [[10.891]] [[ 0.588 -0.339 0.547 0.342 -0.039 0.307 0.165]] 0.00630970
12 [[10.892]] [[ 0.588 -0.341 0.546 0.341 -0.038 0.306 0.166]] 0.00325973
13 [[10.892]] [[ 0.588 -0.343 0.546 0.341 -0.038 0.306 0.166]] 0.00168396
14 [[10.892]] [[ 0.588 -0.343 0.546 0.341 -0.037 0.306 0.166]] 0.00086991
15 [[10.892]] [[ 0.588 -0.344 0.546 0.341 -0.037 0.306 0.166]] 0.00044938
16 [[10.892]] [[ 0.588 -0.344 0.546 0.341 -0.037 0.306 0.166]] 0.00023214
17 [[10.892]] [[ 0.588 -0.344 0.546 0.341 -0.037 0.305 0.166]] 0.00011992
18 [[10.892]] [[ 0.588 -0.344 0.545 0.341 -0.037 0.305 0.166]] 0.00006195
19 [[10.892]] [[ 0.588 -0.344 0.545 0.341 -0.037 0.305 0.166]] 0.00003200
20 [[10.892]] [[ 0.588 -0.344 0.545 0.341 -0.037 0.305 0.166]] 0.00001653
21 [[10.892]] [[ 0.588 -0.344 0.545 0.341 -0.037 0.305 0.166]] 0.00000854
A =
[[ 5.185 -1.705 3.387 1.725 -0.595 0.616 0.736]
[-1.705 5.48 -0.651 -0.33 -0.897 -0.693 -1.289]
[ 3.387 -0.651 3.949 2.297 -0.383 1.887 1.197]
[ 1.725 -0.33 2.297 2.422 -0.337 1.6 0.017]
[-0.595 -0.897 -0.383 -0.337 2.304 -0.177 0.611]
[ 0.616 -0.693 1.887 1.6 -0.177 3.662 0.163]
[ 0.736 -1.289 1.197 0.017 0.611 0.163 1.5 ]]
Q =
[[ 0.588 -0.344 0.545 0.341 -0.037 0.305 0.166]
[-0.344 0.712 0.456 0.285 -0.031 0.255 0.139]
[ 0.545 0.456 0.278 -0.451 0.049 -0.404 -0.22 ]
[ 0.341 0.285 -0.451 0.718 0.031 -0.252 -0.138]
[-0.037 -0.031 0.049 0.031 0.997 0.027 0.015]
[ 0.305 0.255 -0.404 -0.252 0.027 0.774 -0.123]
[ 0.166 0.139 -0.22 -0.138 0.015 -0.123 0.933]]
Q^T * A * Q =
[[10.892 -0. -0. -0. 0. -0. 0. ]
[-0. 4.347 0.572 0.759 -0.674 1.061 -0.669]
[-0. 0.572 2.918 1.137 -0.797 -0.386 0.49 ]
[-0. 0.759 1.137 1.376 -0.561 -0.108 -0.582]
[ 0. -0.674 -0.797 -0.561 2.365 -0.294 0.511]
[-0. 1.061 -0.386 -0.108 -0.294 1.44 -0.75 ]
[ 0. -0.669 0.49 -0.582 0.511 -0.75 1.165]]
****************************************************************************************************
0 [[3.648]] [[ 0.87 0.205 0.292 0.208 -0.26 0.064]] 0.80665134
1 [[5.222]] [[ 0.888 0.338 0.284 -0.076 0.08 -0.067]] 0.48107441
2 [[5.564]] [[ 0.833 0.34 0.285 -0.237 0.181 -0.144]] 0.21258927
3 [[5.617]] [[ 0.802 0.33 0.288 -0.301 0.208 -0.176]] 0.08278396
4 [[5.625]] [[ 0.789 0.324 0.29 -0.325 0.216 -0.188]] 0.03185453
5 [[5.626]] [[ 0.784 0.322 0.291 -0.335 0.219 -0.193]] 0.01225522
6 [[5.626]] [[ 0.782 0.321 0.291 -0.338 0.219 -0.195]] 0.00471868
7 [[5.626]] [[ 0.781 0.321 0.291 -0.34 0.22 -0.195]] 0.00182004
8 [[5.626]] [[ 0.781 0.321 0.291 -0.34 0.22 -0.196]] 0.00070528
9 [[5.626]] [[ 0.781 0.321 0.291 -0.34 0.22 -0.196]] 0.00027679
10 [[5.626]] [[ 0.781 0.321 0.291 -0.34 0.22 -0.196]] 0.00011222
11 [[5.626]] [[ 0.781 0.321 0.291 -0.34 0.22 -0.196]] 0.00004890
12 [[5.626]] [[ 0.781 0.321 0.291 -0.341 0.22 -0.196]] 0.00002399
13 [[5.626]] [[ 0.781 0.321 0.291 -0.341 0.22 -0.196]] 0.00001335
14 [[5.626]] [[ 0.781 0.321 0.291 -0.341 0.22 -0.196]] 0.00000810
A =
[[ 4.347 0.572 0.759 -0.674 1.061 -0.669]
[ 0.572 2.918 1.137 -0.797 -0.386 0.49 ]
[ 0.759 1.137 1.376 -0.561 -0.108 -0.582]
[-0.674 -0.797 -0.561 2.365 -0.294 0.511]
[ 1.061 -0.386 -0.108 -0.294 1.44 -0.75 ]
[-0.669 0.49 -0.582 0.511 -0.75 1.165]]
Q =
[[ 0.781 0.321 0.291 -0.341 0.22 -0.196]
[ 0.321 0.531 -0.426 0.498 -0.322 0.286]
[ 0.291 -0.426 0.613 0.453 -0.292 0.26 ]
[-0.341 0.498 0.453 0.471 0.342 -0.304]
[ 0.22 -0.322 -0.292 0.342 0.779 0.196]
[-0.196 0.286 0.26 -0.304 0.196 0.825]]
Q^T * A * Q =
[[ 5.626 0. -0. 0. -0. 0. ]
[ 0. 1.854 0.521 0.234 -0.136 0.671]
[-0. 0.521 1.134 0.004 0.359 -0.63 ]
[ 0. 0.234 0.004 1.375 -0.627 0.378]
[-0. -0.136 0.359 -0.627 2.283 -1.223]
[ 0. 0.671 -0.63 0.378 -1.223 1.339]]
****************************************************************************************************
0 [[2.458]] [[ 0.631 -0.399 0.146 -0.099 0.642]] 0.65085086
1 [[3.384]] [[ 0.525 -0.205 0.238 -0.486 0.624]] 0.45471280
2 [[3.589]] [[ 0.407 -0.152 0.286 -0.627 0.579]] 0.20268033
3 [[3.631]] [[ 0.338 -0.153 0.305 -0.674 0.561]] 0.08829352
4 [[3.642]] [[ 0.299 -0.163 0.312 -0.693 0.554]] 0.04513686
5 [[3.646]] [[ 0.277 -0.172 0.313 -0.701 0.552]] 0.02540301
6 [[3.647]] [[ 0.264 -0.178 0.313 -0.705 0.551]] 0.01481991
7 [[3.648]] [[ 0.257 -0.182 0.313 -0.707 0.55 ]] 0.00874690
8 [[3.648]] [[ 0.252 -0.184 0.313 -0.708 0.55 ]] 0.00518148
9 [[3.648]] [[ 0.25 -0.186 0.313 -0.709 0.55 ]] 0.00307296
10 [[3.648]] [[ 0.248 -0.187 0.312 -0.709 0.55 ]] 0.00182314
11 [[3.648]] [[ 0.247 -0.187 0.312 -0.71 0.55 ]] 0.00108177
12 [[3.648]] [[ 0.247 -0.187 0.312 -0.71 0.55 ]] 0.00064190
13 [[3.648]] [[ 0.246 -0.188 0.312 -0.71 0.55 ]] 0.00038089
14 [[3.648]] [[ 0.246 -0.188 0.312 -0.71 0.55 ]] 0.00022602
15 [[3.648]] [[ 0.246 -0.188 0.312 -0.71 0.55 ]] 0.00013412
16 [[3.648]] [[ 0.246 -0.188 0.312 -0.71 0.55 ]] 0.00007958
17 [[3.648]] [[ 0.246 -0.188 0.312 -0.71 0.55 ]] 0.00004722
18 [[3.648]] [[ 0.246 -0.188 0.312 -0.71 0.55 ]] 0.00002802
19 [[3.648]] [[ 0.246 -0.188 0.312 -0.71 0.55 ]] 0.00001663
20 [[3.648]] [[ 0.246 -0.188 0.312 -0.71 0.55 ]] 0.00000987
A =
[[ 1.854 0.521 0.234 -0.136 0.671]
[ 0.521 1.134 0.004 0.359 -0.63 ]
[ 0.234 0.004 1.375 -0.627 0.378]
[-0.136 0.359 -0.627 2.283 -1.223]
[ 0.671 -0.63 0.378 -1.223 1.339]]
Q =
[[ 0.246 -0.188 0.312 -0.71 0.55 ]
[-0.188 0.953 0.078 -0.177 0.137]
[ 0.312 0.078 0.871 0.294 -0.228]
[-0.71 -0.177 0.294 0.331 0.518]
[ 0.55 0.137 -0.228 0.518 0.599]]
Q^T * A * Q =
[[ 3.648 -0. -0. 0. -0. ]
[-0. 0.763 0.346 -0.519 -0.092]
[-0. 0.346 1.261 -0.204 0.285]
[ 0. -0.519 -0.204 0.949 -0.722]
[-0. -0.092 0.285 -0.722 1.364]]
****************************************************************************************************
0 [[2.053]] [[ 0.472 0.313 -0.677 0.47 ]] 0.69420350
1 [[2.143]] [[ 0.373 0.398 -0.619 0.565]] 0.17159806
2 [[2.16]] [[ 0.322 0.427 -0.591 0.604]] 0.07585357
3 [[2.164]] [[ 0.298 0.436 -0.579 0.621]] 0.03310416
4 [[2.165]] [[ 0.287 0.438 -0.574 0.63 ]] 0.01483449
5 [[2.165]] [[ 0.282 0.438 -0.572 0.634]] 0.00694645
6 [[2.165]] [[ 0.28 0.437 -0.571 0.636]] 0.00342577
7 [[2.165]] [[ 0.278 0.437 -0.571 0.637]] 0.00177450
8 [[2.165]] [[ 0.278 0.437 -0.571 0.638]] 0.00095515
9 [[2.165]] [[ 0.277 0.436 -0.571 0.638]] 0.00052756
10 [[2.165]] [[ 0.277 0.436 -0.571 0.638]] 0.00029596
11 [[2.165]] [[ 0.277 0.436 -0.571 0.638]] 0.00016750
12 [[2.165]] [[ 0.277 0.436 -0.571 0.638]] 0.00009526
13 [[2.165]] [[ 0.277 0.436 -0.571 0.638]] 0.00005431
14 [[2.165]] [[ 0.277 0.436 -0.571 0.638]] 0.00003101
15 [[2.165]] [[ 0.277 0.436 -0.571 0.638]] 0.00001771
16 [[2.165]] [[ 0.277 0.436 -0.571 0.638]] 0.00001012
17 [[2.165]] [[ 0.277 0.436 -0.571 0.638]] 0.00000579
A =
[[ 0.763 0.346 -0.519 -0.092]
[ 0.346 1.261 -0.204 0.285]
[-0.519 -0.204 0.949 -0.722]
[-0.092 0.285 -0.722 1.364]]
Q =
[[ 0.277 0.436 -0.571 0.638]
[ 0.436 0.737 0.344 -0.385]
[-0.571 0.344 0.55 0.504]
[ 0.638 -0.385 0.504 0.436]]
Q^T * A * Q =
[[ 2.165 -0. 0. 0. ]
[-0. 1.169 -0.123 -0.211]
[ 0. -0.123 0.894 -0.131]
[ 0. -0.211 -0.131 0.109]]
****************************************************************************************************
0 [[1.233]] [[ 0.91 -0.388 -0.144]] 1.45201604
1 [[1.236]] [[ 0.926 -0.356 -0.127]] 0.03889441
2 [[1.237]] [[ 0.933 -0.336 -0.132]] 0.02171044
3 [[1.237]] [[ 0.937 -0.322 -0.135]] 0.01568862
4 [[1.237]] [[ 0.94 -0.311 -0.138]] 0.01133352
5 [[1.238]] [[ 0.943 -0.304 -0.14 ]] 0.00818290
6 [[1.238]] [[ 0.944 -0.298 -0.141]] 0.00590644
7 [[1.238]] [[ 0.945 -0.294 -0.142]] 0.00426265
8 [[1.238]] [[ 0.946 -0.291 -0.143]] 0.00307609
9 [[1.238]] [[ 0.947 -0.289 -0.143]] 0.00221974
10 [[1.238]] [[ 0.947 -0.288 -0.144]] 0.00160175
11 [[1.238]] [[ 0.947 -0.286 -0.144]] 0.00115580
12 [[1.238]] [[ 0.947 -0.286 -0.144]] 0.00083401
13 [[1.238]] [[ 0.948 -0.285 -0.144]] 0.00060180
14 [[1.238]] [[ 0.948 -0.285 -0.144]] 0.00043425
15 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00031334
16 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00022610
17 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00016315
18 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00011773
19 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00008495
20 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00006130
21 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00004423
22 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00003192
23 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00002303
24 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00001662
25 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00001199
26 [[1.238]] [[ 0.948 -0.284 -0.144]] 0.00000865
A =
[[ 1.169 -0.123 -0.211]
[-0.123 0.894 -0.131]
[-0.211 -0.131 0.109]]
Q =
[[ 0.948 -0.284 -0.144]
[-0.284 -0.547 -0.788]
[-0.144 -0.788 0.599]]
Q^T * A * Q =
[[ 1.238 -0. -0. ]
[-0. 0.184 0.318]
[-0. 0.318 0.751]]
****************************************************************************************************
0 [[0.891]] [[0.451 0.892]] 0.68892249
1 [[0.893]] [[0.411 0.912]] 0.04482119
2 [[0.893]] [[0.409 0.913]] 0.00208519
3 [[0.893]] [[0.409 0.913]] 0.00009693
4 [[0.893]] [[0.409 0.913]] 0.00000451
A =
[[0.184 0.318]
[0.318 0.751]]
Q =
[[ 0.409 0.913]
[ 0.913 -0.409]]
Q^T * A * Q =
[[ 0.893 -0. ]
[-0. 0.042]]
****************************************************************************************************
****************************************************************************************************
A =
[[18.589 8.267 6.434 0.92 -1.307 5.075 6.32 2.041 3.359 -3.134]
[ 8.267 11.927 5.84 -0.467 2.509 5.795 6.072 -0.152 -1.337 -1.535]
[ 6.434 5.84 6.524 -1.922 0.948 5.099 3.187 0.236 -0.922 0.557]
[ 0.92 -0.467 -1.922 8.572 1.216 -1.798 -2.555 -4.75 -0.018 2.766]
[-1.307 2.509 0.948 1.216 8.78 -2.44 -1.953 -4.799 -1.691 1.142]
[ 5.075 5.795 5.099 -1.798 -2.44 9.741 5.231 2.573 -0.937 3.572]
[ 6.32 6.072 3.187 -2.555 -1.953 5.231 8.81 3.573 2.271 -4.443]
[ 2.041 -0.152 0.236 -4.75 -4.799 2.573 3.573 7.532 1.269 -3.391]
[ 3.359 -1.337 -0.922 -0.018 -1.691 -0.937 2.271 1.269 5.251 -3.576]
[-3.134 -1.535 0.557 2.766 1.142 3.572 -4.443 -3.391 -3.576 9.758]]
D =
[[37.054 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[ 0. 19.608 0. 0. 0. 0. 0. 0. 0. 0. ]
[ 0. 0. 14.32 0. 0. 0. 0. 0. 0. 0. ]
[ 0. 0. 0. 10.892 0. 0. 0. 0. 0. 0. ]
[ 0. 0. 0. 0. 5.626 0. 0. 0. 0. 0. ]
[ 0. 0. 0. 0. 0. 3.648 0. 0. 0. 0. ]
[ 0. 0. 0. 0. 0. 0. 2.165 0. 0. 0. ]
[ 0. 0. 0. 0. 0. 0. 0. 1.238 0. 0. ]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0.893 0. ]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.042]]
Q =
[[ 0.596 0.093 0.401 0.404 0.428 0.096 0.159 -0.022 0.301 0.07 ]
[ 0.441 0.315 0.033 -0.356 -0.315 0.344 0.033 -0.527 -0.208 -0.198]
[ 0.31 0.215 -0.133 -0.113 0.336 -0.077 -0.529 0.429 -0.442 -0.22 ]
[-0.113 0.335 0.347 0.463 -0.506 0.174 0.107 0.367 -0.329 0.003]
[-0.08 0.411 0.266 -0.522 0.186 -0.343 0.512 0.222 -0.059 0.119]
[ 0.346 0.16 -0.531 0.163 -0.183 -0.256 0.102 -0.01 -0.112 0.651]
[ 0.395 -0.184 -0.035 -0.153 -0.496 -0.315 0.008 0.37 0.434 -0.339]
[ 0.172 -0.46 -0.261 0.024 0.123 0.263 0.601 0.209 -0.392 -0.217]
[ 0.082 -0.268 0.29 0.192 -0.053 -0.668 -0.005 -0.384 -0.428 -0.145]
[-0.153 0.472 -0.441 0.352 0.13 -0.196 0.218 -0.161 0.148 -0.535]]
Q * D * Q^T =
[[18.589 8.266 6.434 0.92 -1.307 5.075 6.32 2.042 3.359 -3.134]
[ 8.266 11.927 5.84 -0.467 2.509 5.795 6.072 -0.152 -1.337 -1.535]
[ 6.434 5.84 6.524 -1.922 0.948 5.099 3.187 0.236 -0.922 0.557]
[ 0.92 -0.467 -1.922 8.572 1.216 -1.798 -2.555 -4.75 -0.018 2.766]
[-1.307 2.509 0.948 1.216 8.78 -2.44 -1.953 -4.799 -1.691 1.142]
[ 5.075 5.795 5.099 -1.798 -2.44 9.741 5.23 2.573 -0.937 3.572]
[ 6.32 6.072 3.187 -2.555 -1.953 5.23 8.81 3.573 2.271 -4.443]
[ 2.042 -0.152 0.236 -4.75 -4.799 2.573 3.573 7.532 1.269 -3.391]
[ 3.359 -1.337 -0.922 -0.018 -1.691 -0.937 2.271 1.269 5.251 -3.576]
[-3.134 -1.535 0.557 2.766 1.142 3.572 -4.443 -3.391 -3.576 9.758]]
Orthogonality (Q * Q^T) =
[[ 1. 0. -0. -0. -0. 0. -0. -0. -0. -0.]
[ 0. 1. 0. 0. 0. -0. -0. 0. -0. -0.]
[-0. 0. 1. -0. -0. -0. -0. -0. 0. 0.]
[-0. 0. -0. 1. 0. 0. -0. -0. 0. 0.]
[-0. 0. -0. 0. 1. 0. 0. -0. 0. -0.]
[ 0. -0. -0. 0. 0. 1. -0. -0. -0. -0.]
[-0. -0. -0. -0. 0. -0. 1. -0. -0. 0.]
[-0. 0. -0. -0. -0. -0. -0. 1. -0. 0.]
[-0. -0. 0. 0. 0. -0. -0. -0. 1. 0.]
[-0. -0. 0. 0. -0. -0. 0. 0. 0. 1.]]
Error ((Q @ D @ Q.T) - A) =
[[-0. -0. -0. -0. -0. -0. 0. 0. 0. -0.]
[-0. -0. -0. -0. -0. -0. 0. 0. 0. -0.]
[-0. -0. -0. -0. -0. 0. -0. 0. 0. 0.]
[-0. -0. -0. -0. 0. 0. -0. 0. -0. 0.]
[-0. -0. -0. 0. -0. -0. -0. -0. -0. -0.]
[-0. -0. 0. 0. -0. 0. -0. 0. -0. 0.]
[ 0. 0. -0. -0. -0. -0. 0. 0. 0. -0.]
[ 0. 0. 0. 0. -0. 0. 0. 0. 0. -0.]
[ 0. 0. 0. -0. -0. -0. 0. 0. 0. -0.]
[-0. -0. 0. 0. -0. 0. -0. -0. -0. 0.]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment