  The unitary polar factor $Q=U$ in the polar decomposition of the matrix
$Z=UH$ is the minimizer for both $\| \mathrm{Log}(Q^* Z)\|^2$ and its Hermitian
part $\| \mathrm{sym Log}(Q^* Z)\|^2$ over both $\mathbb{R}$ and $\mathbb{C}$,
for any given invertible matrix $Z$ in $\mathbb{C}^{n\times n}$ and any matrix
logarithm $\mathrm{Log}$, not necessarily the principal logarithm
$\mathrm{log}$. We prove this for the spectral matrix norm in any dimension and
for the Frobenius matrix norm in two and three dimensions. The result shows
that the unitary polar factor is the nearest orthogonal matrix to $Z$ not only
in the normwise sense, but also in a geodesic distance. The derivation is based
on Bhatia's generalization of Bernstein's trace inequality for the matrix
exponential and a new sum of squared logarithms inequality.
