Properties of the matrix square root In a paper I am reading, it is claimed that if $A, B \in \mathbb{R}^{n \times n}$ are positive definite, then
$$ A^{1/2} (A^{−1/2} B A^{−1/2})^{1/2} A^{1/2} = A (A^{-1}B)^{1/2} $$
because of the properties of the principal matrix square root, but I am not sure how this equality can be proved. Has anybody got a hint?
 A: Note that we have 
$$A^{-1}B=A^{-1/2}(A^{-1/2}BA^{-1/2})A^{1/2}=:A^{-1/2}CA^{1/2}.$$ 
So if $C=QDQ^*$ is an eigen-decomposition of the HPD matrix $C$, then
$$A^{-1}B=A^{-1/2}QDQ^*A^{1/2}=XDX^{-1}, \quad X:=A^{-1/2}Q,$$
is the eigen-decomposition of $A^{-1}B$. With $(A^{-1}B)^{1/2}=XD^{1/2}X^{-1}$, we get
$$
A(A^{-1}B)^{1/2}=AXD^{1/2}X^{-1}=A^{1/2}QD^{1/2}Q^*A^{1/2}=A^{1/2}(A^{-1/2}BA^{-1/2})^{1/2}A^{1/2}.
$$
A: Pre-multiply both sides by $A^{-1}$
$$
  A^{-1/2}(A^{-1/2}BA^{-1/2})^{1/2}A^{1/2} = (A^{-1}B)^{1/2}
$$
Now square both sides
$$\eqalign{
  A^{-1/2}(A^{-1/2}BA^{-1/2})^{1/2}A^{1/2}\,\,\,A^{-1/2}(A^{-1/2}BA^{-1/2})^{1/2}A^{1/2} &= (A^{-1}B) \cr
  A^{-1/2}(A^{-1/2}BA^{-1/2})A^{1/2} &= (A^{-1}B) \cr
  A^{-1}B &= (A^{-1}B) \cr
}$$
These algebraic manipulations hinge on the fact that, for a positive definite matrix, $A^{1/2}$ and $A^{-1/2}$ can be uniquely defined (as the principal matrix square root). 
A: This is true if and only if $A$ and $B$ commute.
If they do commute, they are simultaneously unitarily diagonalisable. Hence the equality can be handled like the scalar case and it's trivial.
If they don't commute, the $A^{-1}B$ on the RHS is not Hermitian and $(A^{-1}B)^{1/2}$ is not well defined.
