Symbolic Math Solves a Linear Algebra Conundrum

I'd like to introduce this week's guest blogger Alan Weiss. Alan writes documentation for mathematical toolboxes here at MathWorks.

An economist I know (well, he's my son) asked me a question the other day. I was able to answer him quickly by using Symbolic Math Toolbox™ calculations. You might find the steps to be an interesting case of a somewhat nonstandard use of symbolic mathematics

Contents

A Linear Algebra Question

My son was working through a paper that described a computational algorithm. He got stuck on one step of the algorithm:

If $A$ is a positive definite (symmetric) matrix, find a lower triangular matrix $G$ such that

$$GAG^{-1} = D, \mbox{ where }D\mbox{ is diagonal.}$$

He called me asking if there was some linear algebra that he just never learned. I knew how to find a matrix $G$ that would diagonalize $A$ using the eig function. But a lower triangular version? I didn't know how to do that. I told him I would call him back after some investigation.

A Symbolic Approach

After spending a couple of minutes fruitlessly looking through a linear algebra book, I decided to see what Symbolic Math Toolbox had to say about the equations that any such matrix $G$ would have to satisfy. Here were my steps.

syms a b c g1 g2 g3 real % Create symbolic variables
G = [g1,0;g2,g3] % Lower triangular matrix
H = inv(G) % Its inverse
A = [a,b;b,c] % Symmetric matrix A
D = G*A*H % D is supposed to be diagonal

G =
[ g1,  0]
[ g2, g3]
H =
[        1/g1,    0]
[ -g2/(g1*g3), 1/g3]
A =
[ a, b]
[ b, c]
D =
[                                 a - (b*g2)/g3,        (b*g1)/g3]
[ (a*g2 + b*g3)/g1 - (g2*(b*g2 + c*g3))/(g1*g3), (b*g2 + c*g3)/g3]


Look at the upper right entry in D. If D is diagonal, then b*g1 = 0. This means b = 0 or g1 = 0. But if b = 0 then A is already diagonal. And if g1 = 0 then the first row of G is zero, so G is not invertible.

In other words, I had just proved that there is no such thing as a lower triangular matrix that diagonalizes a symmetric matrix in this way.

I called my son back and explained the calculation. We decided that the paper he was reading had a misstatement, and he went ahead and used eig to diagonalize the matrix in his application. He will get in touch with the author of the paper to explain the misstatement in the algorithm.

I was quite happy with this result. Symbolic math calculations had saved us both a lot of time searching for an algorithm that doesn't exist.

Feedback

Do you use symbolic math calculations in cute or innovative ways? Tell us about it here.

Published with MATLAB® R2014a

|