Given matrix $Q$ and vector $s$, find a vector $w$ that minimizes $\| Qw-s \|^2$

71 Views Asked by At

The very simple, very formal description of the problem is this:

I have a real matrix $\mathrm{\textbf{Q}}$ and a real vector $\mathrm{\textbf{s}}$.

How could I calculate the vector $\mathrm{\textbf{w}}$, that I minimize $(\mathrm{\textbf{Q}}\mathrm{\textbf{w}}-\mathrm{\textbf{s}})^2$ for that?

$\mathrm{\textbf{Q}}$ is not surely square, thus $\mathrm{\textbf{w}}$ and $\mathrm{\textbf{s}}$ can have different dimensions. Singular cases are not a problem.


After some thinking I suspect these:

  • I am essentially looking for the minimum of an n-dimensional quadratic potential. Thus, finding $\mathrm{\textbf{w}}$ if $\frac{d(\mathrm{\textbf{Q}}\mathrm{\textbf{w}}-\mathrm{\textbf{s}})^2}{\mathrm{d \textbf{w}}}=0$ will be likely a solution.
  • The problem is likely to find the nearest points of two 1d lines in an n-dimensional space.

If it is true, then the solution is probably a simple formula, containing maybe a $\mathrm{\textbf{Q}}^{-1}$ and some elemental scalar vector operation. But as I tried to solve the problem, all my formulas became quickly chaotically unsolvable.