# Computing the Matrix Logarithm with the Romberg Integration Method
## 3 Numerical Tests  
This section collects the results corresponding to the different numerical experiments carried out using the following four MATLAB codes, to comparatively determine the accuracy and efficiency of the proposed algorithms:  
* logm_romberg: This computes the principal matrix logarithm using the inverse scaling and squaring procedure and the Romberg integration method, as described above in Algorithms 1 and 2. The code is available at [[http://personales.upv.es/joalab/software/logm_romberg.m](http://personales.upv.es/joalab/software/logm_romberg.m)]([http://personales.upv.es/joalab/software/logm_romberg.m](http://personales.upv.es/joalab/software/logm_romberg.m)) (accessed on 2 August 2023). Input parameters max_sqrts, m, and tol were set to 10, 7, and \(10^{-11}\), respectively, for all the tests;
* logm_iss_full: This consists of Algorithm 5.2 detailed in [33], designated as the iss_new code. It uses the transformation-free form of the inverse scaling and squaring technique with Pade approximation to compute the matrix logarithm. Matrix square roots are calculated by means of the product form of the Denman-Beavers iteration, as detailed in [1] (Equation (6.29));
* logm_new: This is Algorithm 4.1, denoted as the iss_schur_new function, as detailed in [33]. This code initially performs the transformation to the Schur triangular form \(A=QTQ^{*}\) of the input matrix \(A\). Then, the logarithm of the upper triangular matrix \(T\) is computed by applying the inverse scaling and squaring technique and Pade approximation. The Bjorck and Hammarling algorithm, detailed in [1] (Algorithm 6.3) and [51], is applied to work out the square roots of matrix \(T\);
* logm: This is a MATLAB built-in function that calculates the matrix logarithm from the algorithms included in [33; 34]. Its algorithmic structure is very similar to that of logm_new, but the square roots of \(T\) are calculated using a recursive blocking version of de Bjorck and Hammarling method [52]. Matrix multiplications and the Sylvester equation solution are the main computational problems involved. Three types of matrices, with very different characteristics from each other, were generated to build a heterogeneous test battery, which allowed comparing the numerical and computational performance of these codes. The MATLAB Symbolic Math Toolbox with 256 digits of precision was employed to compute _\"exactly\"_ the matrix logarithm function using the vpa (variable-precision floating-point arithmetic) function. The battery featured the following three matrix sets, which are practically the same as the ones used and described in [44]:  
* Set 1: One hundred diagonalizable \(128\times 128\) complex matrices. For each of them, an orthogonal matrix \(V=H/\sqrt{128}\) was first generated from a Hadamard matrix \(H\). In addition, from a diagonal matrix \(D\) whose eigenvalues were all complex, a matrix \(A=V\times D\times V^{T}\) was computed. Their 2-norm ranged from 0.1 to 300. The _\"exact\"_ logarithm was calculated as \(\log\left(A\right)=V\times\log\left(D\right)\times V^{T}\);
* Set 2: One hundred non-diagonalizable \(128\times 128\) complex matrices. For each of them, an orthogonal matrix \(V\) was obtained first. Elements of \(V\) belonged to intervals getting longer and longer, from \([-2.5,2.5]\) for the first matrix to \([-250,250]\) for the last one. Next, a Jordan matrix \(J\) whose complex eigenvalues had an algebraic multiplicity from 1 to 3 was computed. Then, a test matrix \(A=V\times J\times V^{T}\) was generated. The 2-norm of these matrices took values from 3.39 to 337.72. As in the previous set, the matrix logarithm was exactly calculated as \(\log\left(A\right)=V\times\log\left(J\right)\times V^{T}\);
* Set 3: Fifty-two matrices from the matrix computation toolbox (MCT) [53] and twenty from the Eigtool MATLAB Package (EMP) [54]. The size of these was \(128\times 128\).