# Computing eigenvalues and eigenvectors

## Contents

## Introduction

The concept of computation of eigenvalues and eigenvectors is very important in many areas of economics, especially in statistics, econometrics and macroeconomics. Some important concepts of economic analysis use eigenvalues and eigenvectors, i.e. dynamic analysis, stability analysis, concepts and methods for reducing dimensionality, etc.

In econometrics the concept of eigenvalues and eigenvectors (in econometric terms the concept of characteristic roots and characteristic vectors) is important part of the vector ARMA models and of the principal component regression model [2].

In time series analysis, it is common to use the principal component analysis. This concept can be used for reducing dimensionality of the data. Therefore, it can be helpful for modelling the covariance (or correlation) structure of the time series. This covariance structure modelling plays an important role in portfolio selection [6].

There are two different sets of techniques for computation of eigenvalues and eigenvectors. The first set relies on specially designed transformations that are useful for specific tasks, for example zeroing a particular off-diagonal element (Jacobi's method) or zeroing a whole row or column (Household method). The second set of techniques is connected with factorization models (QR and QL method) [4].

In the following the Jacobi's method will be explained. There exist several competing versions of Jacobi's method. Two basic versions will be introduced: the classical Jacobi's method and the threshold Jacobi's method [3].

## Eigenvalues and Eigenvectors

In the dimensional space eigenvalues are characteristic roots of the characteristic (eigenvalue) equation. This eigenvalue equation is a polynomial of order . Since a polynomial of order can have solutions, there exist also possible eigenvalues. Some eigenvalues can, however, be equal. Eigenvectors are corresponding vectors associated with each eigenvalue that are solutions to the eigenvalue equation.

We can distinguish between right and left eigenvalues and between right and left eigenvectors. Later in this chapter we will connect the concepts of computation of the right and left eigenvalues and eigenvectors.

Symmetric matrices can have some nice properties that will be explained later in this chapter. Also, we can decompose any symmetric matrix according to the concept of spectral decomposition.

Thus, in this chapter the following concepts will be introduced:

- Right eigenvalues and right eigenvectors,

- Left eigenvalues and left eigenvectors, and

- Characteristics of a symmetric matrix; spectral decomposition of a matrix.

This chapter is an introduction to the concept of computation of eigenvalues and eigenvectors. Therefore, some terms will be defined, and the concept of computation of eigenvalues and eigenvectors will be explained for matrices of order .

- Right eigenvalues and right eigenvectors

Right eigenvalues of a quadratic matrix can be computed according to rules (1) - (5), where is a quadratic matrix of order , is identitiy matrix of order (with ones on the mean diagonal), represents one right eigenvector, and represents one right eigenvalue. The expression (5) is in fact a polynomial of order , so it can have possible solutions.

As an example, consider a symmetric matrix in (6). This matrix is symmetric, it is of order 2 and it contains real numbers [5].

The procedure for computation of right eigenvalues is given in expressions (7) - (9). In (8) we have a quadratic polynomial, which has two solutions, in our case two real right eigenvalues given in (9).

If we consider the first right eigenvalue one can compute the corresponding first right eigenvector by rules (10) - (13). It is enough to solve for only one equation that arise from expression (10). In (12) we use the fact that eigenvectors are orthonormal, that is their Euclidean norm (square root of the sum of the squared elements of a vector) is equal to one and they are orthogonal each other [1]. After solving, we finally get following two elements of the first right eigenvector , namely and in (13).

Similar, for the second right eigenvalue the corresponding right eigenvector can be found by expressions (14) - (17):

- Left eigenvalues and left eigenvectors

For computation of the left eigenvalues and left eigenvectors we have the following steps (18) - (23). There is no difference between left and right eigenvalues, but difference occurs in the case of computation of the left and right eigenvectors.

From (23) it follows that for a symmetric real matrix the left eigenvalues are equal to the right eigenvalues, and that the left eigevectors are transposed right eigenvectors.

For matrix from our example we get right eigenvalues as in (9) and right eigenvectors which are given in (24) and in (25).

- Characteristics of a symmetric matrix; spectral decomposition of a matrix

If we consider a symmetric matrix of order with real entries then the characteristic polynomial of this matrix has only real roots (all eigenvalues are real) [5].
If all eigenvalues are nonnegative then the matrix is called positive semidefinite. Also, if all eigenvalues are greater than zero, the matrix is called positive definite.

Since in our example all eigenvalues of matrix are real and greater than zero, the matrix is positive definite.

According to the spectral decomposition of a matrix, every square matrix can be decomposed with the matrix of eigenvectors and diagonal matrix of eigenvalues . The matrix of eigenvalues contains all eigenvalues on the mean diagonal. The expression for spectral decomposition is given in (26) [1], and spectral decomposition for our matrix is given in (27).

The matrix of eigenvalues has some nice properties. These properties are related to the trace and determinant of the matrix .

For any given symmetric matrix the trace (sum of the diagonal elements) is equal to the trace of its matrix of eigenvalues . Put otherwise, the trace of a symmetric matrix is equal to the sum of its eigenvalues. The proof for this property is given in (28).

On the other hand, the determinant of any symmetric matrix is equal to the determinant of its matrix of eigenvalues , so the determinant of a symmetric matrix is equal to the product of its eigenvalues. Proof for this statement is given in (29).

To show empirically that the statement about the trace and determinant of a symmetric matrix and the matrix of eigenvalues is correct, consider our matrix with matrix of eigenvalues and matrix of eigenvectors given in (27). The expressions (30) and (31) show us these two properties.

## Jacobi's Method

In the previous chapter we introduced the concept of computation of eigenvalues and eigenvectors considering matrices of order . As we know, difficulties can arise when one should compute eigenvalues and eigenvectors for matrices of higher order. To overcome these problems we will introduce the Jacobi's Method, in particular the classical Jacobi's Method and the threshold Jacobi's Method.

The idea of the Jacobi's Method is to transform a symmetric matrix to a diagonal matrix by a sequence of similarity transformations. Each similarity transformation involves a rotation designed to increase the sum of squares of the diagonal entries of the matrix currently similar to our symmetric matrix [3].

After similarity transformations we should get a diagonal matrix. In particular, the goal is to zeroing a particular off-diagonal element of a symmetric matrix. The procedure is finished when one get after these similarity transformations a diagonal matrix. This diagonal matrix, as we will see later, is the matrix of eigenvalues .

In the following we will define:

- Rotation matrix, ,

- Reflection matrix, ,

- Transformation matrix, ,

- Similarity transformations,

- Zeroing a particular off-diagonal element in the similarity transformations, and

- Increasing the sum of squared elements on the mean diagonal of the transformed matrices.

Thereafter, the classical Jacobi's Method and the threshold Jacobi's Method will be explained in detail.

At the end of the chapter, the theoretical concepts of the classical Jacobi's Method will be illustrated with an numerical problem. This problem will be solved by using the statistical software package XploRe.

- Rotation matrix,

Rotation matrix (32) rotates the objects clockwise by angle . For example, if we consider a vector and choose angle , we will get a rotated vector in (33).

Useful properties of the rotation matrix are that it is a nonsymmetric square matrix of order two (34), its trace is given in (35), and it has determinant 1, as we can see in (36).

- Reflection matrix,

Reflection matrix, (37) reflects the objects by angle . If we consider a vector and choose angle , we will get a reflected vector in (38).

Properties of the reflection matrix are that it is a symmetric square matrix of order two (39), its trace is 0 (given in (40)), and it has determinant -1, as we can see in (41).

- Transformation matrix,

Transformation matrix, , given in (42) transforms a matrix. In this expression represents a rotation matrix of order 2, is a zero matrix with rows and columns, is an identity matrix of order .

General, the transformation matrix, for transforming (zeroing) the element of a symmetric matrix is given in (43).

For zeroing elements of a symmetric matrix of order , and we use the transformation matrices given in expressions (44), (45) and (46), respectively. One can easy extended this concept to the class of matrices of higher order.

The most important characteristics of the transformation matrix, , are that it is a square matrix of order and orthonormal as stated in expression (47). The proof for orthonormality is given in expressions (48) - (51).

- Similarity transformations

Similarity transformations transform a symmetric matrix under the assumption that the transformation matrix is orthonormal as stated in (47).

The first similarity transformation of a symmetric matrix of order is given by matrix in (52). This similarity transformation (matrix ) has the property that its trace is equal to the trace of the matrix . This property is proven in (53). Also, the Euclidean norm of the similarity transformation (matrix ) is equal to the Euclidean norm of the matrix A. Proof for this property is given in expressions (54) - (55).

If we consider a symmetric matix of order and if we are interested in zeroing the element one can obtain a matrix (in expression (56)) using one similarity transformation. After calculation one get all nine elements of matrix in expressions (57) - (65). The elements of matrix are in fact functions of elements of matrix and the rotation angle .

- Zeroing a particular off-diagonal element in the similarity transformations

Zeroing a particular off-diagonal element of the symmetric matrix gives us a diagonal matrix at the end of these similarity transformations.

In the following we will describe the way to zero a particular off-diagonal element of the matrix . For this purpose we will set the element to zero as in expression (66). It is obvious that one can set any off-diagonal element of the matrix to zero. In this context there is a difference between the classical Jacobi's Method and the threshold Jacobi's Method.

To get an angle that allows us to set the value of element to zero one use the expressions (58) and (66). One can thereafter easy get the expression (67), and after some rearranging the expression (68). Using the formula from trigonometrics (69) it follows (70). If we choose angle according to this rule it follows (66) - we successfully imposed the procedure for zeroing a particular off-diagonal element of a symmetric matrix. An important restriction for this procedure is that the element is not equal to zero.

Next step is to find a solution to element . In expression (57) we add an additional term (which is equal to zero as we know). That leads us to expression (71). Using the definition on the right side of (58) for we insert this in (71) and get (72). Rearranging elements and and manipulation we end with (75). Thus, under all assumptions and restrictions one finally get the expression for computation of the element on the mean diagonal that is affected by the similarity transformation if one is interested in zeroing the off-diagonal element .

The next element that will be explained is . We start with expression (53) that states that the trace of similarity transformation matrix is equal to the trace of the matrix . Using the fact (62) and inserting the expression (75) for we finally get an expression for element in (79). It remains to calculate the other elements of the matrix .

Other elements of the matrix can be computed as before. In particular, the elements of the third row (, and ) are given by expressions (64), (65) and (62), respectively. The elements and are given by expressions (59) and (61), respectively.

- Increasing the sum of squared elements on the mean diagonal of the transformed matrices

For matrix of order we can define the Euclidean norm as in expression (80), where represent the sum of squared elements on the mean diagonal and represent the sum of squared off-diagonal elements. The extension is straightforward for matrices of (higher) order . For matrix we get similar expression (81).

Using the expressions (59) and (61) for elements and , respectively, we can conclude (82), and after some transformations we finally get (83). Thus, the sum of squared particular elements of the original matrix and the transformed matrix are equal and can be cancelled out, as it will be stated later.

With assumption and condition we can rewrite the sum of squared diagonal elements of the matrix as in (84). Immediately we can conclude that the sum of squared elements of the transformed matrix is greater than the sum of squared elements of the initially given matrix as stated in (85). This proves us the idea of the Jacobi's method - increase the sum of squared diagonal elements of the transformed matrix . This proof can be easy extended to case of matrices of higher order than .

### Classical Jacobi's method

The classical Jacobi's method uses a transformation matrix which contains a rotation matrix to decrease the sum of squared off-diagonal elements of the transformed matrices. In each transformation it is necessary to find the largest off-diagonal element and then using the angle set value for this element and recalculate other elements of the transformed matrix. Later, we will prove the fact that the transformed matrix converge to the matrix of eigenvalues , and that the product of the transformation matrices converge to the matrix of eigenvectors . Put otherwise, the elements of the resulting diagonal matrix (after similarity transformations) are eigenvalues of the matrix . The matrix of eigenvectors can be computed by product of the transformed matrices.

The classical Jacobi's method is a simple algorithm (strategy) and it is not the fastest one. Considering tridiagonal matrices, the procedure can be easier and faster. One can use, for example, the Householder algorithm to transform a symmetric matrix to a tridiagonal symmetric matrix.

Two concepts will be considered:

- Decreasing the sum of squared off-diagonal elements of the transformed matrices and

- Proof of convergence of the classical Jacobi's method [3].

At the end of this chapter an numerical example will be introduced to complete the introduced concept for finding the eigenvalues and eigenvectors for a real and symmetric matrix .

- Decreasing the sum of squared off-diagonal elements of the transformed matrices

Since matrices and have the same Euclidean norm (according to proof in (54) and (55)) we can state the relationship (86), which can be expressed like in (87). From rearranged expression (84) for the difference and plugging into (87), and after following the expressions until (89) we finally get the result (90). In expression (88) we used the fact that the sum of all squared off-diagonal elements of any symmetric matrix is less than or equal to the squared largest element multiplied by its frequency. In the case of symmetric matrices of order there are 6 off-diagonal elements that should be defined.

Using the fact stated in (88) we finally get our result in (90); the sum of squared off-diagonal elements of the transformed matrices is less than or equal than the sum of squared off-diagonal elements of the symmetric matrix before the transformation. Therefore, the sum of squared off-diagonal elements of the transformed matrices tends to zero.

Our transformed matrix will now be replaced by matrix which represents matrix after first transformation.

General, in classical Jacobi's method start with a symmetric matrix and use a sequence of rotations (similarity transformations) to decrease the sum of squares of the off-diagonal elements of the transformed matrices.

If we consider a sequence of square matrices {…,} and a sequence of rotation matrices {…,} we get the expression (93) that is similar to (86). The transformed matrix is given by similarity transformations in (91). As we can see from this expression and according to previous result (90), we are indeed interested in decreasing the sum of squared off-diagonal elements of the resulting transformed matrices. We use the element that has the strongest impact on the decreasing of the sum of the off-diagonal elements.

The sequence {…,} represents the product of transformation matrices {…,}. In particular, the matrix is given in expression (92).

- Proof of convergence of the classical Jacobi's method [3]

The classical Jacobi's method generates a sequence of rotations {…,} that have the property (94) which means that the limit of the transformations exist and that it is equal to a diagonal matrix , whose entries are the eigenvalues of , in some order [3]. It is already shown that the off-diagonal elements tend to zero. If the sequence is a convergent subsequence with limit we can find the following expression (95).

Thus, possesses the same eigenvalues, counting multiplicities, as matrix [3].

On the other hand, the sequence {…,} converges to the matrix of eigenvectors .

The sequence is bounded because (97). If we suppose that has a convergent subsequence with limit , then one can show (98).

### Threshold Jacobi's Method

The threshold Jacobi's Method is an algorithm that transforms a symmetric matrix to a diagonal matrix (matrix of its eigenvalues, ) according to a fixed schedule. The goal is to increase the sum of squared diagonal elements and to decrease the sum of squared off-diagonal elements in the transformed matrices.

In the threshold Jacobi's Method the cyclic strategy for searching through all off-diagonal entries is modified so that a rotation is undertaken only when the current off-diagonal element is sufficiently large in absolute value [3].

This method is, like the classical Jacobi's Method, slow and simple, and it can be improved.

### Numerical Example

Using the statistical software XploRe we will consider a numerical example for computation of eigenvalues and eigenvectors. For this proposes we use the matrix of order . After every transformation it is necessary to recalculate the angle . In the first transformation we use the angle . The resulting first transformation matrix and the first transformed matrix are given in (100) and (101), respectively.

The first step is to find the largest squared off-diagonal element, and then zero its value according to the procedure of the Jacobi's method. If we proceed on this way, we will get the largest decreasing of the sum of squared elements of the off-diagonal elements.

In this example all results are expressed on five decimal places.

After two swaps (6 transformations in our case) we get a symmetric matrix of eigenvalues (103). Also, the matrix of corresponding eigenvectors is given in (104). Finally, the spectral decomposition of the symmetric and real matrix is given in expression (105).

## Conclusion

In the second chapter the concept of computation of eigenvalues and eigenvectors was introduced. This part gives us the necessary understanding of the problematic of the computation of eigenvalues and eigenvectors.

In the third chapter the Jacobi's method was explained in detail. This method is very useful in cases of the computation of eigenvalues and eigenvectors for matrices of higher order. Two methods were introduced, the classical Jacobi's method and the threshold Jacobi's method. These methods are simple. A disadvantage of these two methods is that they are slower than some other methods (i.e. the factorization methods; the QR and QL algorithm).

The computation can be further improved if we transform our symmetric matrix to tridiagonal form with the Household algorithm. The computation can then be faster and easier. This advantage has its importance in computation of eigenvalues and eigenvectors for matrices of higher order.

Finally, the introduced Jacobi's method is a numerical algorithm that enables to compute eigenvalues and eigenvectors for real and symmetric matrices that are in the dimensional space .

## References

[1] Härdle, W., Simar, L. (2002) *Applied Multivariate Statistical Analysis*, Springer

[2] Judge, G.G. et al. (1985) *The Theory and Practice of Econometrics*, 2nd ed. John Wiley & Sons, Inc., New York

[3] Lange, K. (1998) *Numerical Analysis for Statisticians*, Springer-Verlag

[4] Press, W.H. et al. (1992) *Numerical Receipes in C*, 2nd ed. Cambridge University Press, New York

[5] Sydsaeter, K., Hammond, P.J. (1995) *Mathematics for Economic Analysis*, Pretence-Hall Inc., New Jersey

[6] Tsay, R.S. (2002) *Analysis of Financial Time Series*, John Wiley & Sons, Inc., New York