[Math] Minimize the Frobenius norm of the difference of two matrices with respect to matrix: $\underset{B} {\mathrm{argmin}} \left\| A- B \right\|_F$

linear algebramatricesoptimization

The following question is similar to this one, but I think that it is not straightforward to move from one to the other, so please take a look. Otherwise, please let me know and I will delete it.


Let $A,B\in\Bbb{R}^{n\times n}$ two square real $n\times n$ matrices with the additional properties that $A$ is also symmetric, and $B$ is diagonal with entries $\{b_i\colon b_i\in\Bbb{R}, i=1,\ldots,n\}$, that is, $B=\operatorname{diag}(b_1,\ldots,b_n)$.

We want to minimize the Frobenius norm of the difference of $A$, $B$ with respect to the matrix $B$. Let $B^{\star}$ denote the minimizer of the aforementioned norm, that is
$$
B^{\star} = \underset{B} {\mathrm{argmin}} \left\| A- B \right\|_F,
$$
where $\lVert A\rVert_F$ denotes the Frobenius norm of an $n\times n$ real symmetric matrix $A=\big(a_{ij}\big)_{i,j=1}^n$, and is given by
$$
\lVert A\rVert_F
=
\left(\sum_{i,j=1}^n \left\| a_{ij} \right\|^2\right)^{\frac{1}{2}}
=
\sqrt{\operatorname{tr}(A^\top A)}
=
\sqrt{\operatorname{tr}(AA^\top)}.
$$

Best Answer

Since $$\|A-B\|_F^2 = 2\sum_{i>j}|a_{ij}|^2 + \sum_{i=1}^{n}|a_{ii}-b_{ii}|^2 $$ it follows that the minimum is attained when $b_{ii}=a_{ii}$ for any $i\in[1,n]$.