Improved MATLAB Function Sqrtm

sqrtm-help.jpg

The MATLAB function sqrtm, for computing a square root of a matrix, first appeared in the 1980s. It was improved in MATLAB 5.3 (1999) and again in MATLAB 2015b. In this post I will explain how the recent changes have brought significant speed improvements.

Recall that every n-by-n nonsingular matrix A has a square root: a matrix X such that X^2 = A. In fact, it has at least two square roots, \pm X, and possibly infinitely many. These two extremes occur when A has a single block in its Jordan form (two square roots) and when an eigenvalue appears in two or more blocks in the Jordan form (infinitely many square roots).

In practice, it is usually the principal square root that is wanted, which is the one whose eigenvalues lie in the right-half plane. This square root is unique if A has no real negative eigenvalues. We make it unique in all cases by taking the square root of a negative number to be the one with nonnegative imaginary part.

The original sqrtm transformed A to Schur form and then applied a recurrence of Parlett, designed for general matrix functions; in fact it simply called the MATLAB funm function of that time. This approach can be unstable when A has nearly repeated eigenvalues. I pointed out the instability in a 1999 report A New Sqrtm for MATLAB and provided a replacement for sqrtm that employs a recurrence derived specifically for the square root by Björck and Hammarling in 1983. The latter recurrence is perfectly stable. My function also provided an estimate of the condition number of the matrix square root.

The importance of sqrtm has grown over the years because logm (for the matrix logarithm) depends on it, as do codes for other matrix functions, for computing arbitrary powers of a matrix and inverse trigonometric and inverse hyperbolic functions.

For a triangular matrix T, the cost of the recurrence for computing T^{1/2} is the same as the cost of computing T^{-1}, namely n^3/3 flops. But while the inverse of a triangular matrix is a level 3 BLAS operation, and so has been very efficiently implemented in libraries, the square root computation is not in the level 3 BLAS standard. As a result, my sqrtm implemented the Björck–Hammarling recurrence in M-code as a triply nested loop and was rather slow.

The new sqrtm introduced in MATLAB 2015b contains a new implementation of the Björck–Hammarling recurrence that, while still in M-code, is much faster. Here is a comparison of the underlying function sqrtm_tri (contained in toolbox/matlab/matfun/private/sqrtm_tri.m) with the relevant piece of code extracted from the old sqrtm. Shown are execution times in seconds for random triangular matrices an a quad-core Intel Core i7 processor.

n sqrtm_tri old sqrtm
10 0.0024 0.0008
100 0.0017 0.014
1000 0.45 3.12

For n=10, the new code is slower. But for n=100 we already have a factor 8 speedup, rising to a factor 69 for n=1000. The slowdown for n=10 is for a combination of two reasons: the new code is more general, as it supports the real Schur form, and it contains function calls that generate overheads for small n.

How does sqrtm_tri work? It uses a recursive partitioning technique. It writes

T = \begin{bmatrix} T_{11} & T_{12} \\ 0 & T_{22} \\ \end{bmatrix}

and notes that

T^{1/2} = \begin{bmatrix} T_{11}^{1/2} & X_{12} \\ 0 & T_{22}^{1/2} \\ \end{bmatrix},

where T_{11}^{1/2} X_{12} + X_{12} T_{22}^{1/2} = T_{12}. In this way the task of computing the square root of T is reduced to the tasks of recursively computing the square roots of the smaller matrices T_{11} and T_{22} and then solving the Sylvester equation for X_{12}. The Sylvester equation is solved using an LAPACK routine, for efficiency. If you’d like to take a look at the code, type edit private/sqrtm_tri at the MATLAB prompt. For more on this recursive scheme for computing square roots of triangular matrices see Blocked Schur Algorithms for Computing the Matrix Square Root (2013) by Deadman, Higham and Ralha.

The sqrtm in MATLAB 2015b includes two further refinements.

  • For real matrices it uses the real Schur form, which means that all computations are carried out in real arithmetic, giving a speed advantage and ensuring that the result will not be contaminated by imaginary parts at the roundoff level.
  • It estimates the 1-norm condition number of the matrix square root instead of the 2-norm condition number, so exploits the normest1 function.

Finally, I note that the product of two triangular matrices is also not a level-3 BLAS routine, yet again it is needed in matrix function codes. A proposal for it to be included in the Intel Math Kernel Library was made recently by Peter Kandolf, and I strongly support the proposal.

A Collection of Invalid Correlation Matrices

invalid-correlation-collection.jpg

I’ve written before (here) about the increasingly common problem of matrices that are supposed to be correlation matrices (symmetric and positive semidefinite with ones on the diagonal) turning out to have some negative eigenvalues. This is usually bad news because it means that subsequent computations are unjustified and even dangerous. The problem occurs in a wide variety of situations. For example in portfolio optimization a consequence could be to take arbitrarily large positions in a stock, as discussed by Schmelzer and Hauser in Seven Sins in Portfolio Optimization.

Much research has been done over the last fifteen years or so on how to compute the nearest correlation matrix to a given matrix, and these techniques provide a natural way to correct an “invalid” correlation matrix. Of course, other approaches can be used, such as going back to the underlying data and massaging it appropriately, but it is clear from the literature that this is not always possible and practitioners may not have the mathematical or statistical knowledge to do it.

Nataša Strabić and I have built up a collection of invalid correlation matrices, which we used most recently in work on Bounds for the Distance to the Nearest Correlation Matrix. These are mostly real-life matrices, which makes them valuable for test purposes.

We have made our collection of invalid correlation matrices available in MATLAB form on GitHub as the repository matrices-correlation-invalid. I am delighted to be able to include, with the permission of investment company Orbis, two relatively large matrices, of dimensions 1399 and 3120, arising in finance. These were the matrices I used in my original 2002 paper.

The Improved MATLAB Functions Expm and Logm

pcam-p97-exp-short.jpg
Equation from the Princeton Companion to Applied Mathematics, article “Functions of Matrices” (p. 97)

The matrix exponential is a ubiquitous matrix function, important both for theory and for practical computation. The matrix logarithm, an inverse to the exponential, is also increasingly used (see my earlier post, 400 Years of Logarithms).

MATLAB R2015b introduced new versions of the expm and logm functions. The Release Notes say

The algorithms for expm, logm, and sqrtm show increased accuracy, with logm and sqrtm additionally showing improved performance.

The help text for expm and logm is essentially unchanged from the previous versions, so what’s different about the new functions? (I will discuss sqrtm in a future post.)

The answer is that both functions make use of new backward error bounds that can be much smaller than the old ones for very nonnormal matrices, and so help to avoid a phenomenon known as overscaling. The key change is that when bounding a matrix power series p(X) = a_0 I + a_1 X + a_2 X^2 + \cdots, instead of bounding the kth term a_k X^k by |a_k| \|X\|^k, a potentially smaller bound is used.

This is best illustrated by example. Suppose we want to bound \|X^{12}\| and are not willing to compute X^{12} but are willing to compute lower powers of X. We have 12 = 6 \times 2 = 4 \times 3, so \|X^{12}\| is bounded by each of the terms (\|X^2\|)^6, (\|X^3\|)^4, (\|X^4\|)^3, and (\|X^6\|)^2. But it is easy to see that (\|X^6\|)^2 \le (\|X^2\|)^6 and (\|X^6\|)^2 \le (\|X^3\|)^4, so we can discard two of the bounds, ending up with

\|X^{12}\| \le \min( \|X^4\|^3, \|X^6\|^2 ).

This argument can be generalized so that every power of X is bounded in terms of the norms of X^p for values of p up to some small, fixed value. The gains can be significant. Consider the matrix

X = \begin{bmatrix}1 & 100 \\ 0 & 1 \end{bmatrix}.

We have \|X\|^{12} \approx 10^{24}, but

X^k = \begin{bmatrix}1 & 100k \\ 0 & 1 \end{bmatrix},

so the bound above is roughly \|X^{12}\| \le 6 \times 10^{7}, which is a significant improvement.

One way to understand what is happening is to note the inequality

\rho(X) \le \| X^k\| ^{1/k} \le \|X\|,

where \rho is the spectral radius (the largest modulus of any eigenvalue). The upper bound corresponds to the usual analysis. The lower bound is something that we cannot use to bound the norm of the power series. The middle term is what we are using, and as k\to\infty the middle term converges to the lower bound, which can be arbitrarily smaller than the upper bound.

What is the effect of these bounds on the algorithms in expm and logm? Both algorithms make use of Padé approximants, which are good only for small-normed matrices, so the algorithms begin by reducing the norm of the input matrix. Backward error bounds derived by bounding a power series as above guide the norm reduction and if the bounds are weak then the norm is reduced too much, which can result in loss of accuracy in floating point arithmetic—the phenomenon of overscaling. The new bounds greatly reduce the chance of overscaling.

In his blog post A Balancing Act for the Matrix Exponential, Cleve Moler describes a badly scaled 3-by-3 matrix for which the original expm suffers from overscaling and a loss of accuracy, but notes that the new algorithm does an excellent job.

The new logm has another fundamental change: it applies inverse scaling and squaring and Padé approximation to the whole triangular Schur factor, whereas the previous logm applied this technique to the individual diagonal blocks in conjunction with the Parlett recurrence.

For more on the algorithms underlying the new codes see these papers. The details of how the norm of a matrix power series is bounded are given in Section 4 of the first paper.

Principal Values of Inverse Cosine and Related Functions

casio-fx-300es-cropped.jpg

I’ve recently been working, with Mary Aprahamian, on theory and algorithms for the matrix inverse sine and cosine and their hyperbolic counterparts. Of course, in order to treat the matrix functions we first need a good understanding of the scalar case. We found that, as regards practical computation, the literature is rather confusing. The reason can be illustrated with the logarithm of a complex number.

Consider the question of whether the equation

\log(z_1 z_2) = \log z_1 + \log z_2

is valid. In many textbooks this equation is stated as is, but with the (often easily overlooked) proviso that each occurrence of \log denotes a particular branch of the logarithm—possibly different in each case. In other words, the equation is true for the multivalued function that includes all branches.

In practice, however, we are usually interested in the principal logarithm, defined as the one for which the complex argument of \log z lies in the interval (-\pi,\pi] (or possibly some other specific branch). Now the equation is not always true. A correction term that makes the equation valid can be expressed in terms of the unwinding number introduced by Corless, Hare, and Jeffrey in 1996, which is discussed in my earlier post Making Sense of Multivalued Matrix Functions with the Matrix Unwinding Function.

The definition of principal logarithm given in the previous paragraph is standard. But for the inverse (hyperbolic) cosine and sine it is difficult to find clear definitions of principal values, especially over the complex plane. Some authors define these inverse functions in terms of the principal logarithm. Care is required here, since seemingly equivalent formulas can yield different results (one reason is that (z^2-1)^{1/2} is not equivalent to (z-1)^{1/2}(z+1)^{1/2} for complex z). This is a good way to proceed, but working out the ranges of the principal functions from these definitions is not trivial.

In our paper we give diagrams that summarize four kinds of information about the principal inverse functions acos, asin, acosh, and asinh.

  • The branch points.
  • The branch cuts, marked by solid lines.
  • The domain and range, shaded gray and extending to infinity in the obvious directions).
  • The values attained on the branch cuts: the value on the cut is the limit of the values of the function as z approaches the cut from the side without the hashes.

The figures are below. Once we know the principal values we can address questions analogous to the log question, but now for identities relevant to the four inverse functions.

For more, including an explanation of the figures in words and all the details of the matrix case—including answers to questions such as “when is \mathrm{acos}(\cos A) equal to A?”—see our recent EPrint Matrix Inverse Trigonometric and Inverse Hyperbolic Functions: Theory and Algorithms.

acosm-fig0.jpg
acosm-fig1.jpg
acosm-fig2.jpg
acosm-fig3.jpg

Numerical Linear Algebra Group 2015

The Manchester Numerical Linear Algebra group was very active in 2015. This post summarizes what we got up to. Publications are not included here, but many of them can be found on MIMS EPrints under the category Numerical Analysis.

Software

We continue to make our software available. Increasingly this is done on on GitHub: Deadman, Higham, Relton, Sego, Tisseur, Zhang. We also put MATLAB software on MATLAB Central File Exchange and on our own web sites, e.g., the Rational Krylov Toolbox (RKToolbox).

151013-1040-56-6822.jpg

PhD Students

New PhD student Matthew Gwynne joined the group in January 2015, sponsored partly by Arup.

New PhD students Massimiliano Fasi (supported by a Presidential Doctoral Scholarship), Jundong Li (supported by The MathWorks), and Mante Zemaityte, joined the group in September 2015.

Mario Berljafa and Weijian Zhang served as Treasurer and Webmaster, respectively, of the Manchester SIAM Student Chapter, 2014-2015. For 2015-2016, Weijian Zhang is President, Mante Zemaityte is Vice President, Matthew Gwynne is Secretary, and Mario Berljafa is treasurer. Massimiliano Fasi is webmaster.

Postdoctoral Research Associates (PDRAs)

Scott Ladenheim joined the group as a PDRA in August 2015. He is working with Milan Mihajlovic in the School of Computer Science.

Mary Aprahamian became a PDRA in October 2015 after submitting her PhD thesis.

Edvin Deadman moved to a position with NAG (Manchester) in May 2015.

Leo Taslaman moved to a position with COMSOL (Stockholm) in August 2015.

Jennifer Pestana moved to a Lectureship at the University of Strathclyde in October 2015.

Vanni Noferini moved to a Lectureship at the University of Essex in September 2015.

Vedran Sego worked with Francoise Tisseur, September–October, 2015.

Presentations

Members of the group gave presentations (talks or posters) at the following conferences and workshops.

SIAM UKIE Meeting 2015, January 8, 2015, University of Bath, UK: Berljafa, Mower.

LMS Tropical Mathematics and its Applications workshop, Manchester, January 23, 2015: Tisseur.

SIAM Student Chapter Delft: Student Krylov Day 2015, February 2, 2015: Berljafa.

SIAM Conference on Computational Science & Engineering, Salt Lake City, March 14-18, 2015: Berljafa, Higham, Pestana, Relton, Zhang.

25 Years of Innovative Computing Workshop, UT Knoxville, March 31-April 2, 2015: Hammarling, Tisseur.

The Joint British (Applied) Mathematical Colloquium 2015, Cambridge, UK, March 30-April 2, 2015: Guettel.

Conference in Honor of Volker Mehrmann “Numerical Algebra, Matrix Theory, Differential-Algebraic Equations, and Control Theory”, TU Berlin, May 6-9 2015: Noferini, Perez, Tisseur.

Birmingham Young Mathematician Colloquium, University of Birmingham, 13th May 2015: Berljafa.

Postgraduate Summer Research Showcase, The University of Manchester, June 5, 2015: Berljafa, Zhang.

Gene Golub SIAM Summer School 2015, RandNLA: Randomization in Numerical Linear Algebra, Delphi, Greece, June 15-26, 2015: Berljafa, Fasi.

International Conference on Preconditioning Techniques for Scientific and Industrial Applications, June 17-19 2015, Eindhoven, The Netherlands: Pestana.

26th Biennial Conference on Numerical Analysis, Glasgow, June 23-26, 2015: Higham, Noferini, Perez, Pestana, Relton.

GAMM Workshop on Applied and Numerical Linear Algebra, Magdeburg, Germany, July 9-10, 2015: Šego, Strabić.

The International Congress on Industrial and Applied Mathematics (ICIAM), August 10-14, 2015, Beijing, China: Guettel, Noferini, Pestana.

Applied Harmonic Analysis and Sparse Approximation, Oberwolfach, Germany, August 16–22, 2015: Lotz.

New Directions in Numerical Computation, Oxford, August 25-28, 2015: Guettel, Higham, Relton, Strabić.

International Workshop on Eigenvalue Problems: Algorithms; Software and Applications, in Petascale Computing September 14-16, 2015, Tsukuba, Japan: Tisseur.

Mathematics Research Students’ Conference 2015, University of Manchester, September 30, 2015: Berljafa, Zhang.

Workshop on Matrix Equations and Tensor Techniques, Bologna, Italy, September 21-22, 2015: Strabić.

SIAM Conference on Applied Linear Algebra, Atlanta, October 2015: Aprahamian, Berljafa, Deadman, Fasi, Higham, Hook, Noferini, Perez, Relton, Tisseur.

Conference and Workshop Organization

Oliver Dorn and Martin Lotz organized the workshop Compressive Sensing and Sparsity: Theory and Applications in Tomography, November 12-13, 2015.

Françoise Tisseur served as member of the organizing committee for the SIAM Conference on Applied Linear Algebra, Atlanta, October 2015.

Christopher Mower, Mario Berljafa, and Weijian Zhang were on the organizing committee of the Manchester SIAM Student Chapter conference, May 2, 2015.

Two minisymposia were organized:

151026-1217-07-3293.jpg
Bruno Iannazzo, Marcel Schweitzer, Michele Benzi, Sivan A. Toledo, Sam Relton and Edvin Deadman.
151026-1700-29-3303.jpg
Edvin Deadman, Peter Kandolf, Antti Koskela, Massimiliano Fasi and Sam Relton.

Visitors

Vedran Sego visited the group throughout 2015.

Peter Kandolf is visiting the group from September 2015 to March 2016.

Tomas Gergelits is visiting the group from October 2015 to March 2016.

Knowledge Transfer

In the Knowledge Transfer Partnership with Sabisu, involving KTP Associate Tim Butters, Stefan Guettel, Nick Higham, and Jon Shapiro (School of Computer Science), an alarm management system has been developed and launched as a product.

MSc student Chris Mower did a dissertation project “Shrinking for Restoring Definiteness” sponsored NAG and worked in the Manchester NAG office.

Mante Zemaityte carried out a summer project sponsored by Arup, working with the Manchester Arup office.

Recognition and Service

Martin Lotz and his co-authors won the inaugural 2015 best paper prize for the journal Information and Inference.

Weijian Zhang won first place in the presentation prize at the 2015 Mathematics Research Students’ Conference, University of Manchester, September 30, 2015.

Nick Higham and Natasa Strabić won best poster prize at the SIAM Conference on Applied Linear Algebra, Atlanta, October 2015, for their poster “Anderson Acceleration of the Alternating Projections Method for Computing the Nearest Correlation Matrix”.

Françoise Tisseur served as

  • Vice-President of the UK & Republic of Ireland SIAM Section, 2014-2015, and
  • Program Director of the SIAM Activity Group on Linear Algebra, 2013-2015.

The Rise of Mixed Precision Arithmetic

For the last 30 years, most floating point calculations in scientific computing have been carried out in 64-bit IEEE double precision arithmetic, which provides the elementary operations of addition, subtraction, multiplication, and division at a relative accuracy of about 10^{-16}. We are now seeing growing use of mixed precision, in which different floating point precisions are combined in order to deliver a result of the required accuracy at minimal cost.

Single precision arithmetic (32 bits) is an attractive alternative to double precision because it halves the costs of storing and transferring data, and on Intel chips the SSE extensions allow single precision arithmetic to run twice as fast as double.

wpid-qd-compare2.jpg
” /> The Mandelbrot set computed in double and quadruple precision. Image taken from https://www.thasler.com/blog/blog/glsl-part5.

Quadruple precision arithmetic, which was included in the 2008 revision of the IEEE standard, is supported by some compilers, and it can be implemented in terms of double precision arithmetic via double-double arithmetic. Arbitrary precision floating point arithmetic is available through, for example, the GNU MPFR library, the mpmath library for Python, the core data type BigFloat in the new language Julia, VPA arithmetic in the MATLAB Symbolic Math Toolbox, or the Advanpix Multiprecision Computing Toolbox for MATLAB.

Half precision arithmetic, in which a number occupies 16 bits, is supported by the IEEE standard for storage but not for computation. It has been argued that for deep learning half precision, with its relative accuracy of about 10^{-4}, is good enough for training and running neural networks. Here are some of the ways in which extra precision is currently being used.

  • Iterative refinement, in the traditional form that first became popular in the 1960s, improves the quality of an approximate solution to a linear system via updates obtained from residuals computed in extra precision.
  • When an algorithm suffers instability it may be possible to overcome it by using extra precision in just a few, key places. This has been done recently in eigensolvers and for matrix orthonormalization.
  • Any iterative algorithm that accepts an arbitrary starting point can be run once at a given precision and the solution used to “warm start” a second run of the same algorithm at higher precision. This idea has been used recently in linear programming.
  • Numerical integration of differential equations over long time periods may need higher precision in order to allow the phenomena of interest to be observed. A recent example is in the study of Kerr (rotating) black holes, where the underlying hyperbolic partial differential equation is solved using quadruple precision arithmetic running on GPUs.
  • When one is developing error bounds or testing algorithms, one needs in principle the exact solution. In practice, a solution computed at high precision and rounded to the working precision is usually adequate, and this is an approach I frequently use in my work in numerical linear algebra.

As the relative costs and ease of computing at different precisions evolve, due to changing architectures and software, as well as the disruptive influence of accelerators such as GPUs, we will see an increasing development and use of mixed precision algorithms. In some ways this is analogous to the increasing interoperability of programming languages (illustrated by C++, Julia, and Python, for example): one uses the main tool (precision) one would like to work with and brings in other tools (precisions) as necessary in order to complete the task.

Update: linear programming link updated December 18, 2018.

Anderson Acceleration

Anderson acceleration, also known in quantum chemistry as Pulay mixing or direct inversion in the iterative subspace (DIIS), is a technique for accelerating the convergence of a fixed-point iteration. It has been widely used in electronic structure computations, but does not seem to be well known to numerical analysts.

Anderson’s original paper is from 1965 and is well cited, as Google Scholar shows: and65-gs.jpg I learned about Anderson acceleration in the minisymposium Anderson Acceleration and Applications organized by Tim Kelley at the SIAM Conference on Computational Science and Engineering in Salt Lake City in March 2015. Tim gave an excellent overview of the topic in the opening talk. The slides for that talk are available on Tim’s website.

PhD student Nataša Strabić and I have shown that Anderson acceleration works very well for speeding up the alternating projections method for computing the nearest correlation matrix. It typically gives a reduction in the number of iterations by a factor at least 2 for the standard nearest correlation matrix problem and by at least a factor 3 when additional constraints are imposed on the matrix (specified elements fixed and a lower bound on the smallest eigenvalue). In some cases the reduction is by a factor of as much as 25. Since the overhead of Anderson acceleration is small, significant speedups are obtained.

In my 2013 post The Nearest Correlation Matrix I included a MATLAB code nearcorr.m. In place of this I now recommend our new accelerated code nearcorr_aa.m, which is available from the repository anderson-accel-ncm on GitHub. Our paper describing this work is available on MIMS EPrints.

For me this project is an excellent illustration of the importance of going to conferences in order to learn of new ideas and new developments.

Numerical Linear Algebra Group 2014

The Manchester Numerical Linear Algebra group was very active in 2014. This post summarizes what we got up to. Publications are not included here, but many of them can be found on MIMS EPrints under the category Numerical Analysis.

A new venture for several of us this year was to make our software available on GitHub: Deadman, Higham, Relton, Sego, Zhang.

140930-1044-20-6703.jpg

PhD Students

Three students successfully defended their theses:

Sam and Leo are now postdoctoral Research Associates in the group. Ramaseshan is a Senior Engineer at Arup, working in the Manchester office.

Weijian Zhang joined the group in September as a PhD student working with Nick Higham.

Sam Relton and Mary Aprahamian served as President and Treasurer, respectively, of the Manchester SIAM Student Chapter.

Postdoctoral Research Associates (PDRAs)

Jennifer Pestana joined the group in January, from Oxford University, to work with Françoise Tisseur.

Javier Perez joined the group in September, to work with Françoise Tisseur.

Tim Butters joined the group in January to work as a postdoctoral Knowledge Transfer Associate with Stefan Guettel and Nick Higham, in a project with Sabisu.

Lijing Lin (2007-2014) left the group in September to take up a Research Associate position in the Faculty of Life Sciences at The University of Manchester.

Amal Khabou (2013-2014) left in September to take up a Maître de conférences position at Université Paris Sud.

Meisam Sharify (2013-2014) left in May to take up a post as Assistant Professor in the Department of Computer Science, Shahid Beheshti University, G.C. Tehran, Iran.

Presentations

Members of the group gave presentations at the the following conferences and workshops.

IMA Conference on the Mathematical Challenges of Big Data, London, December 16-17, 2014 (Higham).

Structured Numerical Linear and Multilinear Algebra: Analysis, Algorithms and Applications, Kalamata, Greece, September 8-12 2014 (Noferini).

Spectral Theory Workshop to celebrate the 70th birthday of Brian Davies, King’s College London, 30 October 2014 (Tisseur).

4th IMA Conference on Numerical Linear Algebra and Optimisation, Birmingham, September 3-5, 2014 (Aprahamian, Berljafa, Khabou, Pestana, Relton, Strabić, Tisseur).

11th World Congress on Computational Mechanics, Barcelona, 20-25 July 2014 (Kannan).

International Workshop on Operator Theory and Applications, Amsterdam, July 14-18, 2014 (Tisseur).

SIAM Annual Meeting, Chicago, July 7-11, 2014 (Aprahamian, Deadman, Guettel, Lotz, Zhang).

First Joint International Meeting RSME-SCM-SEMA-SIMAI-UMI, Bilbao, June 30-July 4, 2014 (Noferini).

Householder Symposium XIX on Numerical Linear Algebra, Spa, Belgium, June 8-13, 2014 (Deadman, Guettel, Higham, Khabou, Lin, Noferini, Pestana, Taslaman, Tisseur).

10th International Workshop on Accurate Solution of Eigenvalue Problems (IWASEP10), Dubrovnik, Croatia, June 2-5 (Sego, Strabić).

Structured Matrix Days, XLIM, Université de Limoges, France, May 26-27, 2014 (Noferini).

Advances in Numerical Algorithms and High Performance Computing, University College London, April 14-15, 2014 (Deadman, Higham, Relton).

Napier 400th Anniversary Celebrations: Computation in Mathematics Workshop, ICMS, Edinburgh, April 2, 2014 (Higham: Video podcast).

Workshop on Nonlinear Eigenvalue Problems, The University of Manchester, April 23-25, 2014 (organized by Tisseur, Pestana, Kressner and Michiels and attended by the whole group).

Annual Meeting of the International Association of Applied Mathematics and Mechanics, Erlangen, March 10-14, 2014 (Guettel).

International Workshop on Eigenvalue Problems: Algorithms; Software and Applications, in Petascale Computing March 7-9, 2014 Tsukuba, Japan (Guettel, Tisseur).

2014 SET for BRITAIN exhibition at the House of Commons (Mary Aprahamian presented a poster).

Conference and Workshop Organization

The group organized three events in Manchester.

Several minisymposia were organized:

Visitors

Vedran Sego visited the group throughout 2014.

Zhi-Gang Jia from Jiangsu Normal University, China, visited the group August 2013-July 2014.

Philip Gill (UC San Diego) and Margaret Wright (New York University) both visited for two weeks in March.

Jan Papež, a PhD student at the Academy of Sciences of the Czech Republic, Prague, visited for a week in November.

Marcel Schweitzer, a PhD student at the Universit of Wuppertal, visited the group for one week in September 2014.

Vladimir Druskin (Schlumberger-Doll Research Center, Cambridge, USA) visited the group for one week in June 2014.

Daniel Ruprecht (Università della Svizzera Italiana) and Robert Speck (Jülich Supercomputing Centre) visited the group for one week in February 2014.

Massimiliano Fasi, an M.Sc. student at the University of Bologna, Italy, visited for a week in November. He will join the group as a PhD student in September 2015, funded by a University of Manchester President’s Doctoral Scholarship Award.

Caterina Fenu, a PhD student at the University of Cagliari, Italy, visited for a week in November.

Knowledge Transfer

In The Knowledge Transfer Partnership with Sabisu, involving KTP Associate Tim Butters, Stefan Guettel, Nick Higham, and Jon Shapiro (School of Computer Science), an alarm management system has been developed and launched as a product.

Recognition and Service

Françoise Tisseur was awarded a Royal Society Wolfson Research Merit Award (2014-2019) to support her work on the numerical solution of nonlinear eigenvalue problems.

Former PDRA Yuji Nakatsukasa (2011-2013) was awarded the Householder Prize 2014 for his PhD thesis “Algorithms and Perturbation Theory for Matrix Eigenvalue Problems and the Singular Value Decomposition” (2011), written at the University of California, Davis.

Nick Higham served on Subpanel 10, Mathematical Sciences, in the Research Excellence Framework (REF) 2014.

Françoise Tisseur served as

  • Vice-President of the UK & Republic of Ireland SIAM Section,
  • Program Director of the SIAM Activity Group on Linear Algebra,
  • Member of the Householder Prize Committee 2014.

400 Years of Logarithms

The logarithm was first presented in John Napier’s 1614 book Mirifici Logarithmorum Canonis Descriptio (Description of the Wonderful Canon of Logarithms). Last week I was celebrating 400 years of logarithms at the Napier 400 workshop held at the ICMS in Edinburgh and organized by NAIS. The previous such celebrations had been in 1914 and, as one speaker remarked, it is nice to participate in an event held only once every 100 years.

This one-day workshop included talks by Mike Giles on computing logarithms and other special functions on GPUs, and Jacek Gondzio on the history of the logarithmic barrier function in linear and nonlinear optimization.

My interest is in the matrix logarithm. The earliest explicit occurrence that I am aware of is in an 1892 paper by Metzler On the Roots of Matrices, so we are only just into the second century of matrix logarithms.

140402-1631-24-111.jpg
Photo and Tweet by @DesHigham: “@nhigham introduced by Dugald Duncan at @ICMS_Edinburgh”.

In my talk The Matrix Logarithm: from Theory to Computation I explained how the inverse scaling and squaring (ISS) algorithm that we use today to compute the matrix logarithm is a direct analogue of the method Henry Briggs used to produce his 1624 tables Arithmetica Logarithmica, which give logarithms to the base 10 of the numbers 1–20,000 and 90,000–100,000 to 14 decimal places. Briggs’s impressive hand computations were done by using the formulas \log a = 2^k \log a^{1/2^k} and \log(1+x) \approx x to write \log_{10} a \approx 2^k \cdot \log_{10}e \cdot (a^{1/2^k} - 1). The ISS algorithm for the matrix case uses the same idea, with the square roots being matrix square roots, but approximates \log(1+x) at a matrix argument using Padé approximants, evaluated using a partial fraction expansion. The Fréchet derivative of the logarithm can be obtained by Fréchet differentiating the formulas used in the ISS algorithm. For details see Improved Inverse Scaling and Squaring Algorithms for the Matrix Logarithm (2012) and Computing the Fréchet Derivative of the Matrix Logarithm and Estimating the Condition Number (2013).

As well as the logarithm itself, various log-like functions are of interest nowadays. One is the unwinding function, discussed in my previous post. Another is the Lambert W function, defined as the solution W(z) of W(z) e^{W(z)} = Z. Its many applications include the solution of delay differential equations. Rob Corless and his colleagues produced a wonderful poster about the Lambert W function, which I have on my office wall. Cleve Moler has a recent blog post on the function.

A few years ago I wrote a paper with Rob, Hui Ding and David Jeffrey about the matrix Lambert W function: The solution of S exp(S) = A is not always the Lambert W function of A. We show that as a primary matrix function the Lambert W function does not yield all solutions to S \exp(S) = A, just as the primary logarithm does not yield all solutions to e^X = A. I am involved in some further work on the matrix Lambert W function and hope to have more to report in due course.

Making Sense of Multivalued Matrix Functions with the Matrix Unwinding Function

Try the following quiz. Let A be an n\times n real or complex matrix. Consider the principal logarithm—the one for which \log z has imaginary part in (-\pi,\pi]—and define z^{t} = e^{t \log z} for t\in\mathbb{C} (an important special case being t = 1/p for an integer p) .

True or false:

  1. \log e^A = A for all A, in other words passing A through the exponential then the logarithm takes us on a round trip.
  2. (I-A^2)^{1/2} = (I-A)^{1/2}(I+A)^{1/2} for all A.
  3. (AB)^{t} = A^{t}B^{t} whenever A and B commute.

The answers are

  1. False. Yet e^{\log A} = A is always true.
  2. True. Yet the similar identity (A^2-I)^{1/2}=(A-I)^{1/2}(A+I)^{1/2} is false.
  3. False.

At first sight these results may seem rather strange. How can we understand them? If you take the viewpoint that each occurrence of \log and a power t in the above expressions stands for the families of all possible logarithms and powers then the identities are all true. But from a computational viewpoint we are usually concerned with a particular branch of each function, the principal branch, so equality cannot be taken for granted.

An excellent tool for understanding these identities is a new matrix function called the matrix unwinding function. This function is defined for any square matrix A by U(A) = (A - \log e^A )/(2\pi i), and it arises from the scalar unwinding number introduced by Corless, Hare and Jeffrey in 1996 1, 2. There is nothing special about A and B being matrices in this quiz; the answers are the same if they are scalars. But the matrix unwinding function neatly handles the extra subtleties of the matrix case.

130712-1101-57-2430.jpg
Mary’s talk at the 2014 SIAM Annual Meeting in San Diego.

From the definition we have \log e^A = A + 2\pi i U(A), so the relation in the first quiz question is clearly valid when U(A) = 0, which is the case when the eigenvalues of A have imaginary parts lying on the interval (-\pi,\pi]. Each of the above identities can be understood by deriving an exact relation in which the unwinding function provides the discrepancy between the left and right-hand sides. For example,

(AB)^t = A^t B^t e^{-2\pi t i U(\log A + \log B)}.

Mary Aprahamian and I have recently published the paper The Matrix Unwinding Function, with an Application to Computing the Matrix Exponential, (SIAM J. Matrix. Anal. Appl., 35, 88-109, 2014), in which we introduce the matrix unwinding function and develop its many interesting properties. We analyze the identities discussed above, along with various others. Thanks to the University of Manchester’s Open Access funds, that paper is available for anyone to download from the SIAM website, using the given link.

The matrix unwinding function has another use. Note that e^A=e^{\log e^A}=e^{A-2\pi i U(A)} and the matrix A-2\pi i U(A) has eigenvalues with imaginary parts in (-\pi,\pi]. The scaling and squaring method for computing the matrix exponential is at its most efficient when A has norm of order 1, and this argument reduction operation tends to reduce the norm of A when A has eigenvalues with large imaginary part. In the paper we develop this argument reduction and show that it can lead to substantial computational savings.

How can we compute U(A)? The following incomplete MATLAB code implements the Schur algorithm developed in the paper. The full code is available.

function U = unwindm(A,flag)
%UNWINDM  Matrix unwinding function.
%   UNWINDM(A) is the matrix unwinding function of the square matrix A.

%   Reference: M. Aprahamian and N. J. Higham.
%   The matrix unwinding function, with an application to computing the
%   matrix exponential.  SIAM J. Matrix Anal. Appl., 35(1):88-109, 2014.

%   Mary Aprahamian and Nicholas J. Higham, 2013.

if nargin < 2, flag = 1; end
[Q,T] = schur(A,'complex');

ord = blocking(T);
[ord, ind] = swapping(ord);  % Gives the blocking.
ord = max(ord)-ord+1;        % Since ORDSCHUR puts highest index top left.
[Q,T] = ordschur(Q,T,ord);
U = Q * unwindm_tri(T) * Q';

%%%%%%%%%%%%%%%%%%%%%%%%%%%
function F = unwindm_tri(T)
%UNWINDM_tri   Unwinding matrix of upper triangular matrix.

n = length(T);
F = diag( unwind( diag(T) ) );

% Compute off-diagonal of F by scalar Parlett recurrence.
for j=2:n
     for i = j-1:-1:1
         if F(i,i) == F(j,j)
            F(i,j) = 0;        % We're within a diagonal block.
         else   
            s = T(i,j)*(F(i,i)-F(j,j));
            if j-i >= 2
               k = i+1:j-1;
               s = s + F(i,k)*T(k,j) - T(i,k)*F(k,j);
            end
            F(i,j) = s/(T(i,i)-T(j,j));
         end
     end   
end

%%%%%%%%%%%%%%%%%%%%%%
function u = unwind(z)
%UNWIND  Unwinding number.
%   UNWIND(A) is the (scalar) unwinding number.

u = ceil( (imag(z) - pi)/(2*pi) );

... Other subfunctions omitted

Here is an example. As it illustrates, the unwinding matrix of a real matrix is usually pure imaginary.

>> A = [1 4; -1 1]*4, U = unwindm(A)
A =
     4    16
    -4     4
U =
   0.0000 + 0.0000i   0.0000 - 2.0000i
   0.0000 + 0.5000i  -0.0000 + 0.0000i
>> residual = A - logm(expm(A))
residual =
   -0.0000   12.5664
   -3.1416   -0.0000
>> residual - 2*pi*i*U
ans =
   1.0e-15 *
  -0.8882 + 0.0000i   0.0000 + 0.0000i
  -0.8882 + 0.0000i  -0.8882 + 0.3488i

Footnotes:

1

Robert Corless and David Jeffrey, The Unwinding Number, SIGSAM Bull 30, 28-35, 1996

2

David Jeffrey, D. E. G. Hare and Robert Corless, Unwinding the Branches of the Lambert W Function, Math. Scientist 21, 1-7, 1996