I am trying to find a solution for the following equation:
$$\underset{X}{\text{argmin}} \sum_{i=1}^{N} (y_i - \mathbf{a_{i}^TX^T b_i})^2$$
Where $\mathbf{a_i}$ and $\mathbf{b_i}$ are vectors and $\mathbf{X}$ is a matrix.
I have worked out the derivative:
$$\begin{align} \nabla_X L(\mathbf{X}) &= \nabla_X \sum_{i=1}^{N} (y_i - \mathbf{a_{i}^TX^T b_i})^2 \\ &= \sum_{i=1}^{N} 2(y_i - \mathbf{a_{i}^TX^T b_i})\nabla_X(y_i - \mathbf{a_{i}^T X^T b_i}) \\ &= \sum_{i=1}^{N} -2(y_i - \mathbf{a_{i}^TX^T b_i})\mathbf{b_i a_i^T} \end{align}$$
When I set the derivative to $0$ I am not sure how to derive the solution for $\mathbf{X}$:
$$\begin{align} \sum_{i=1}^{N} -2(y_i &- \mathbf{a_{i}^T X^T b_i})\mathbf{b_i a_i^T} = \mathbf{0} \\ \sum_{i=1}^{N} y_i\mathbf{b_i a_i^T} &= \sum_{i=1}^{N}(\mathbf{a_{i}^T X^T b_i})\mathbf{b_i a_i^T} \\ \mathbf{X} &= \;? \end{align}$$
$$\sum_{i=1}^n \left( \mathrm b_i^{\top} \mathrm X \,\mathrm a_i - y_i \right)^2 = \sum_{i=1}^n \left( \mathrm b_i^{\top} \mathrm X \,\mathrm a_i \mathrm a_i^{\top} \mathrm X^{\top} \mathrm b_i - 2 y_i \mathrm b_i^{\top} \mathrm X \,\mathrm a_i + y_i^2\right)$$
Differentiating this cost function with respect to $\mathrm X$ and finding where the derivative vanishes, we obtain the following linear matrix equation
$$\sum_{i=1}^n \mathrm b_i \left( \mathrm b_i^{\top} \mathrm X \,\mathrm a_i - y_i \right) \mathrm a_i^{\top} = \mathrm O$$
which can be rewritten as follows
$$\sum_{i=1}^n \left( \mathrm b_i \mathrm b_i^{\top} \right) \mathrm X \left( \mathrm a_i \mathrm a_i^{\top} \right) = \sum_{i=1}^n y_i \mathrm b_i \mathrm a_i^{\top}$$
Vectorizing, we obtain the following linear system
$$\left( \sum_{i=1}^n \left(\mathrm a_i \mathrm a_i^{\top}\right) \otimes \left(\mathrm b_i \mathrm b_i^{\top}\right) \right) \, \mbox{vec} (\mathrm X) = \sum_{i=1}^n (\mathrm a_i \otimes \mathrm b_i) \, y_i$$