{'fraction_non_alphanumeric': 0.037681912681912684, 'fraction_numerical': 0.01136954261954262, 'mean_word_length': 4.267967145790554, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Joint Approximate Diagonalization of Symmetric Real Matrices of Order 2

The problem of joint approximate diagonalization of symmetric real matrices is addressed. It is reduced to an optimization problem with the restriction that the matrix of the similarity transformation is orthogonal. Analytical solutions are derived for the case of matrices of order 2. The concepts of off-diagonalizing vectors, matrix amplitude, which is given in terms of the eigenvalues, and partially complementary matrices are introduced. This leads to a geometrical interpretation of the joint approximate diagonalization in terms of eigenvectors and off-diagonalizing vectors of the matrices. This should be helpful to deal with numerical and computational procedures involving high-order matrices.


INTRODUCTION
Linear Algebra has many applications in science and engineering [2,6,7]. In particular, the calculation of eigenvalues and eigenvectors of a linear operator allows one to find the main directions of a rotating body, the normal modes of an oscillating mechanical and/or electrical system and the stationary states of a quantum system. Such a calculation leads to a similarity transformation that produces a diagonal representation of the linear operator, thus the process is called as a diagonalization.
There are cases where several linear operators are relevant in the analysis of the system under investigation. When the operators commute, they may be diagonalized by the same similarity transformation. This problem has been numerically addressed by Bunse-Gerstner et al. [5]. Their algorithm is an extension of the Jacobi technique that generates a sequence of similarity transformations that are plane rotations. Moreover, Lathauwer [11] established a link between the canonical decomposition of higher-order tensors and simultaneous matrix diagonalization.
In the case of noncommuting operators, researchers try to find a compromise solution that nearly diagonalizes the matrices representing the operators. Several methods for joint approximate diagonalization have been proposed in the literature. They differ in how the optimization problem is formulated and solved, and in the conditions for both the diagonalizing matrix and the set In the present work, analytical solutions for the problem of joint approximate diagonalization are given for a set of symmetric real matrices of order 2. This leads to a new and deeper geometrical interpretation of the diagonalization process that should improve numerical and computational procedures required to deal with larger matrices. Several pairs of matrices are investigated in order to clarify the role played by the amplitudes and the main directions of each operator. In this respect, the introduction of the concepts of off-diagonalizing vectors, matrix amplitude and partially complementary matrices proves to be very helpful.
The structure of the manuscript is as follows: § 2 discusses the main concepts and procedures for the case of a single matrix, § 3 sets up the optimization problem for several symmetric real matrices, § 4 presents an analytical solution for the particular case of several matrices of order 2, and § 5 focuses on a pair of 2×2 matrices and discusses the geometrical aspects of the procedure. The main findings of the work are summarized in § 6.

A SINGLE MATRIX OF ORDER N: EIGENVECTORS AND OFF-DIAGONALIZING VECTORS
The diagonalization of a real symmetric square matrix M can be viewed as an optimization problem. One should find a nonsingular real square matrix U of the same order, such that the product M = U −1 MU is a diagonal matrix [15,17]. Let us define a function, denoted by the term "off ", that gives the sum of the squared values of the off-diagonal entries of each square matrix. M is diagonal when off (M ) = 0. Since every real symmetric square matrix M can be diagonalized, the function f (M, U) = off (U −1 MU) has a global minimum and its value is zero. The diagonalization of M is then reduced to finding the minimizing matrix U.
The columns of the diagonalizing matrix U are eigenvectors of the matrix M. To each of those vectors corresponds an eigenvalue in the main diagonal of M [15]. Moreover, the eigenvectors of different eigenvalues are known to be orthogonal. In the case of a degenerate eigenvalue of multiplicity d, a set of d orthogonal eigenvectors may be chosen. Therefore, one may look for a minimizing matrix U having orthogonal columns. Additionally, the columns may be normalized while remaining eigenvectors of M. In this way, the study may be restricted to matrices U, with transpose denoted byŨ, such thatŨ U = UŨ = I.
This means U is an orthogonal matrix. Therefore, the search for the minimum may be restricted to the set O of orthogonal matrices of order n.
Taking (2.1) into account, the objective function may be written as As f is a function of n 2 entries of U, it is a polynomial of fourth degree in R n 2 . Since O is a compact subset of R n 2 , the existence of both the minimum and the maximum values of the continuous function f (M, U) is guaranteed. Any column of a maximizing matrix U will be called as an off-diagonalizing vector of M. One may also say that such a matrix U off-diagonalizes M.
To understand this, one may consider a real symmetric matrix of order 2, given by Since U is an orthogonal matrix, it may be written in the form where θ and θ give the directions of the vectors in the first and second columns of U. Taking into account the fact that such vectors are orthogonal, one may take θ = θ ± π/2. As a result, the transformation matrix has the form (see Ref. [2]) U = cos(θ) ∓ sin(θ) sin(θ) ± cos(θ) , (2.5) and the objective function becomes When a = c and b = 0, the objective function vanishes everywhere. This is because the matrix is a scalar multiple of the identity matrix and such a matrix commutes with every square matrix M. Instead, when a = c or b = 0, the objective function oscillates between zero and its maximum value. The values of θ leading to such extreme values can be obtained from the derivative of f (M, U) with respect to θ. However, the simplicity of this function allows the optimization process to be performed algebraically. The vector (a − c, b) is the product of its norm, (a − c) 2 + b 2 , with the unit vector (cos(2φ), sin(2φ)), where φ is a real number fulfilling Therefore, the objective function may be written as The objective function oscillates harmonically with both the mean value and the amplitude given by C. It should be noted that C vanishes when a = c and b = 0.
When C = 0, the eigenvectors (off-diagonalizing vectors) of M are along the directions given by where q is an even (odd) integer. The corresponding optimal value of the objective function are f min = 0 and f max = 2C. Moreover, each off-diagonalizing vector bisects the angle between two orthogonal eigenvectors, and conversely.
It is very interesting to note that the amplitude C may be easily expressed in terms of the trace, a + c, and the determinant, Since the trace and the determinant are invariant under the similarity transformation given by U, the matrix M has the same amplitude as its diagonalized form where λ 1 and λ 2 are the eigenvalues of M. Therefore, C equals half the maximum value of f (D, U). According to Eq. (2.6), this is given by Then, the amplitude of M is also given by (2.14) Of course, since Tr(M) = λ 1 + λ 2 and det(M) = λ 1 λ 2 , the latter equation is equivalent to Eq. (2.11).
In order to simplify the equations for matrices of order n, it is useful to recall the Frobenius norm of a real square matrix M, whose square is given by the sum of the squares of the entries m i j of the matrix, that is, For a symmetric matrix M, the squared norm is the trace of M 2 , that is, SinceŨMU is symmetric, we have For the matrix of order 2 in Eq. (2.3) one may write Then, the minimum value of g(M, U) in reached when the cosine of 4(θ − φ) equals −1. Such a minimum is given by From this, one may draw two interesting conclusions. On the one hand, after off-diagonalization, M =ŨMU has a null diagonal if and only of c = −a. This means that the off-diagonalization process is not perfect for most matrices. On the other hand, g min = g(M, I) when (a + c) 2 /2 = a 2 + c 2 , that is, c = a. Matrices satisfying this condition are as off-diagonal as they can be transformed into.

JOINT APPROXIMATE DIAGONALIZATION OF SEVERAL MATRICES
When one considers two real symmetric matrices M 1 and M 2 , the existence of a common diagonalizing matrix U is equivalent to the condition M 1 M 2 = M 2 M 1 . Hence, several matrices have a common diagonalizing matrix whenever each pair of them commute.
In the present work, we consider a set of K noncommuting real symmetric matrices M 1 , M 2 , . . . , M K of order n. Such matrices cannot be diagonalized by the same orthogonal matrix U. Then, one may look for U leading to the minimum value of where f has the meaning of Eq. (2.2). The minimum is not zero, thus the process can be called as a joint approximate diagonalization of the matrices under consideration. The optimization process for an arbitrary value of n requires numerical iterative procedures [18]. Therefore, the next sections focus on the case n = 2.

JOINT APPROXIMATE DIAGONALIZATION OF SEVERAL MATRICES OF ORDER 2
Similarly to (2.3), the k-th matrix of the set is written as Then according to (2.5) and (2.6), one has where and Comparing with Eq. (2.9), we note that C k is the amplitude of M k . In analogy with Eq. (2.8), one may also write where The objective function (3.1) is then written as where A = K k=1 A k , B = K k=1 B k and C = K k=1 C k . These parameters may be expressed in terms of the K -vectors a = (a 1 , . . . , a K ), b = (b 1 , . . . , b K ) and c = (c 1 , . . . , c K ), namely The function F(U) will be the constant value C when A = B = 0, that is, In this case, no matrix U is able to decrease the joint off-diagonal measure of the set of matrices. In other cases, there is an angle φ such that The minimizing values of U are given by where q is an integer. Moreover, the minimum value of the objective function is It is worthy noting that all matrices will be diagonalized when F min = 0. This occurs when F min = 0 when the matrices commute pairwise.
It is also useful to note that, from Eqs. (3.1) and (4.5), the objective function of the jointapproximate diagonalization may be written as (4.15)

JOINT APPROXIMATE DIAGONALIZATION OF TWO MATRICES OF ORDER 2: FOUR CASES
For two matrices M 1 and M 2 , the objective function in Eq. (4.15) is a constant when the amplitudes C 1 and C 2 satisfy the equations C 1 cos(4φ 1 ) + C 2 cos(4φ 2 ) = 0 C 1 sin(4φ 1 ) + C 2 sin(4φ 2 ) = 0. Eq. (5.1), the amplitudes should fulfill the condition C 1 + (−1) p C 2 = 0. Since the amplitudes are non-negative numbers, one arrives at the following conditions: (i) C 1 = C 2 and (ii) p should be an odd integer. Condition (i) means that the matrices have equal amplitudes, while condition (ii) states that the eigenvectors of M 1 are off-diagonalizing vectors of M 2 , and conversely. For short, it will be said that two matrices obeying condition (ii) are partially complementary. Furthermore, when (i) and (ii) are satisfied, the matrices may be told as fully complementary, because in such a case the objective function is a constant.
In the following subsections, the four cases which differ in whether the matrices are partially complementary or have different amplitudes are illustrated and discussed.

Non partially complementary matrices of different amplitudes
In this subsection we consider the matrices  Moreover, they are closer to the directions of the matrix with larger amplitude, namely M 2 . This is also apparent in Figure 2, where the objective function F(U) is displayed as a function of θ.
The objective functions f (M 1 , U) and f (M 2 , U) of the separate diagonalization of the matrices are also shown. It is seen that the minimization procedure has lowered the value of the objective function from its initial value F(I) = 4 to its minimum value F min = 2.

Non partially complementary matrices of equal amplitudes
Now we consider the matrices  In this case, the minimizing angles are θ = π 4 + qπ 2 , where q is an integer. In Figure 3,

Partially complementary matrices with different amplitudes
It is also interesting to consider the matrices  In this case, as shown in Figure 5, the minimizing directions coincide with the main directions of the matrix having larger amplitude, namely M 2 . Figure 6 displays the objective functions F(U), f (M 1 , U) and f (M 2 , U) as a function of θ. One may note that the latter two functions oscillate in complete out of phase, that is, the angles producing the maximum value for one matrix yield the minimum value for the other. Therefore, the term of larger amplitude is dominant in the sum F(U).

Fully complementary matrices
Finally, we consider the matrices , (5.5) whose amplitudes equal 5 4 . Since these matrices are partially complementary, that is, (a 1 − c 1 ) (a 2 − c 2 ) + b 1 b 2 = 0, and have equal amplitudes, they are fully complementary. This is the case where the objective function F(U) remains constant, as displayed in Figure 7. Therefore, one is not able to decrease the joint off-diagonal measure of the pair of matrices. Since no special value of θ exist, a figure similar to Figures 1, 3 and 5 would not be meaningful in this case.

CONCLUSIONS
We have dealt with the problem of joint approximate diagonalization of a set of symmetric real matrices. The problem has been reduced to the search for the orthogonal transformation matrix that minimizes the joint off-diagonal sums of squares of the matrices.
Analytical expressions have been given for the case of a set of matrices of order 2. For the particular case of two matrices, the discussions were performed after introducing the concept of offdiagonalizing vectors. The latter are the columns of an orthogonal matrix that off-diagonalizes a given matrix. When the eigenvectors of one of the matrices are off-diagonalizing vectors of the other, we say that the matrices are partially complementary. Moreover, the sum of the squared off-diagonal entries of a transformed matrix oscillates harmonically, as a function of the rotation angle. The amplitude of the oscillation is one fourth of the squared difference between the eigenvalues of the matrix. The results and discussions are presented for several cases, differing on whether the matrices are partially complementary and/or have equal amplitudes. The case where both situations apply deserves special attention because the joint approximate diagonalization has no effect, in other words, the objective function is constant. We say that such matrices are fully complementary.
We note that the joint approximate diagonalization is often applied to large matrices, and the numerical and computational aspects have been the main focus of precedent works. In contrast, our thorough discussion of matrices of order 2 has shed light on the geometrical meaning of the procedure. The introduction of the concepts of off-diagonalizing vectors, matrix amplitude and complementary matrices have been very useful and should find additional applications in Linear Algebra and other branches of science. Hopefully, the work will encourage the treatment of both complex and high-order matrices.