Given matrices $A, B \in \mathbb{R}^{m \times n}$, I want to solve the following least-squares problem
$$ \min_{X \in \mathbb{R}^{n \times n}} \| A – B X \|_F^2 $$
where $\| \cdot \|_F$ is the Frobenius norm. In this problem, $m \ge n$.
Does anyone know how to solve this? Or possibly convert it into an ordinary least squares problem?
Best Answer
Recall that for $A \in \mathbb{R}^{m \times n},$
\begin{align*} \| A \|^{2}_{F} = \textrm{trace}(A^{\top} A). \end{align*}
With this in mind, consider the following (very relevant) post:
Derivative of squared Frobenius norm of a matrix
Hence, you can differentiate your expression in the usual way (being mindful of 2nd-order conditions for optimality), and find a solution to your optimization problem.
Additionally, a useful reference for a variety of matrix identities (including matrix calculus) is "The Matrix Cookbook" by Kaare Brandt Petersen and Michael Syskind Pedersen. A version of the document can be found here:
https://www.math.uwaterloo.ca/~hwolkowi/matrixcookbook.pdf