# Prove $PCP^{-1}B^{-1}$ is always symmetric

While working on programming, I noticed this very interesting property, and I've verified it with the code, while I didn't find a way to prove it.

The question is following:

Let $$A$$ and $$B$$ be symmetric and invertible matrices. The product $$AB$$ can be decomposed using Eigenvalue Decomposition (EVD) as $$AB = PDP^{-1}$$, where $$D$$ is a diagonal matrix, and $$P$$ is an invertible matrix.

Given another arbitrary diagonal matrix $$C$$, prove that the matrix $$PCP^{-1}B^{-1}$$ is symmetric.

The code to verify:

import numpy as np

# Set the size of the matrices
N = 5

# Generate random symmetric matrix
A = np.random.rand(N, N)
A = A + A.T
B = np.random.rand(N, N)
B = B @ B.T

# EVD of AB
d, P = np.linalg.eig(A @ B)

# Arbitrary diagonal matrix C
C = np.diag(np.random.rand(N))

# Compute the matrix in question
result = P @ C @ np.linalg.inv(P) @ np.linalg.inv(B)

# Check if the result is symmetric
print(np.allclose(result, result.T))

• You also assume that $B$ is invertible, does this hold for $A$ aswell? Commented Jul 29 at 22:35
• @tychonovs-scholar Yes, A is also invertible. Thanks for your attention. I will modify the problem. Commented Jul 29 at 22:41
• The premise that $AB$ can be written as $PDP^{-1}$ is false in the first place. For example, $A=\begin{pmatrix}0&1\\1&0\end{pmatrix}$ and $B=\begin{pmatrix}1&1\\1&0\end{pmatrix}$ are both symmetric and invertible, but $AB=\begin{pmatrix}1&0\\1&1\end{pmatrix}$ is not diagonalizable. Commented Jul 29 at 22:54
• Even if $AB$ can be written as such, the result is still false. For example, $A=B=\begin{pmatrix}1&0\\0&1\end{pmatrix}$, then you can write $AB=PDP^{-1}$ with $D=\begin{pmatrix}1&0\\0&1\end{pmatrix}$, $P=\begin{pmatrix}1&1\\0&1\end{pmatrix}$, and $P^{-1}=\begin{pmatrix}1&-1\\0&1\end{pmatrix}$. If $C=\begin{pmatrix}1&0\\0&0\end{pmatrix}$, then $PCP^{-1}B^{-1}=\begin{pmatrix}1&-1\\0&0\end{pmatrix}$ is not symmetric. Commented Jul 29 at 23:03
• This is a nice observation, and it came for sure from a very specific practical situation. From my perspective the question comes with work, it is the running code, and although not claiming a true result (in full generality) we have a good grain of a structural situation that needs an articulated claim, which finally holds. For me, this is one of the cases that makes stronger the community, and shows effort and curiosity. Upvoted, to motivate similar questions in the future. Commented Jul 29 at 23:15

Let us consider first a very particular case. We take $$A=B=I$$, the identity matrix, and it is enough for our purposes of giving a counterexample to use only $$2\times 2$$ matrices. We further take $$C,P$$ as below and compute $$PCP^{-1}$$: $$C =\begin{bmatrix}3\\& 4 \end{bmatrix} \ ,\qquad P =\begin{bmatrix}1 & 1\\& 1 \end{bmatrix} \ ,\qquad P^{-1} =\begin{bmatrix}1 & -1\\& 1 \end{bmatrix} \ ,\\ PCP^{-1} = \begin{bmatrix}1 & 1\\& 1 \end{bmatrix} \begin{bmatrix}3 \\& 4 \end{bmatrix} \begin{bmatrix}1 & -1\\& 1 \end{bmatrix} = \begin{bmatrix}3 & 4\\& 4 \end{bmatrix} \begin{bmatrix}1 & -1\\& 1 \end{bmatrix} = \begin{bmatrix}3 & 1\\& 4 \end{bmatrix} \ .$$ This is not a symmetric matrix.

But when does it work? Why does the claim work randomly so good?

The reason is as follows. It works when the diagonal matrix $$C$$ has equal diagonal entries on two positions when on the same two positions we have equal entries in $$D$$. For instance, if $$D$$ has all diagonal entries different, then the condition is automatically satisfied.

So consider $$D$$ with diagonal entries $$d_1,d_2,\dots,d_n$$. Let $$C$$ have also as a matter of notations the entries $$c_1,c_2,\dots,c_n$$. In this case, there always exists a polynomial $$f$$ such that $$f(d_k)=c_k$$ for all indices $$k$$ from one to $$n$$. Then by matrix functional calculus: $$f(AB) =f(PDP^{-1}) =Pf(D)P^{-1} =PCP^{-1} \ .$$ So we can restate, and want to show that for any polynomial $$f$$ the matrix $$f(AB)B^{-1}$$ is symmetric. Such a polynomial is a sum of simple monomials (times coefficients). So it is enough to show this for $$f$$ in the list $$1,x,x^2,x^3,\dots$$. (The sum of two symmetric matrices is also symmetric, the product of a scalar and a symmetric matrix is also symmetric.)

Well, for the above values we get the matrices:

• $$B^{-1}$$ for $$f=1$$,
• $$(AB)B^{-1}=A$$ for $$f=x$$,
• $$(AB)^2B^{-1}=ABAB\;B^{-1}=ABA$$ for $$f=x^2$$,
• $$(AB)^3B^{-1}=ABABAB\;B^{-1}=ABABA$$ for $$f=x^3$$,

and so on, in general we obtain (for the next cases, the first two are somehow special) the matrix $$ABA\dots ABA$$, and it is easy to check it is symmetric. (A non-commutative palindrome is applied on symmetric matrices.)

• Is $D$ the $2\times2$ identity matrix? Commented Jul 29 at 23:17
• @Lucenaposition Yes, in the case of $A=B=I$, then $AB=1$ with eigenvalues $1,1$ (with multiplicity) and $D$ must have these eigenvalues on the diagonal. Commented Jul 29 at 23:22
• That's a quite nice answer. Thanks for your response Commented Jul 29 at 23:30
• You didn't specify what $D$ was. Commented Jul 30 at 0:08