1
$\begingroup$

I have two vectors - the input and output. I would like to find a matrix that multiplied by the input vector gives the output vector.

What algorithms should be used? What is their complexity?

  • 1
    For just *two* vectors there are many such matrices. Besides, how the word *inverse* in the title is related to the question?2017-01-22
  • 0
    The word "inverse" is indeed related, albeit not quite in the sense we are used to. The inverse operation to multiplication is division; can we "divide" a vector by another vector, so as to get a matrix? No, we can't, but the question was meaningful anyway.2017-01-22
  • 0
    Ideally, the algorithm returned all the possibilities. However, I am aware that it may be difficult for large vectors computationally. So, It can also be returned to any matrix satisfying the condition.2017-01-22
  • 1
    There are not just many such matrices; there are _too many_. Picking any of them would be quite useless. Here's one: column $i$ equals the output vector divided by the $i$'th element of the input vector. All other columns are filled with zeros.2017-01-22

2 Answers 2

2

So you want a matrix, which given the input vector $a$ produces the output vector $b$.

Here is a rank-1 matrix which does that $$M=\frac{ba^T}{a^Ta}=ba^+$$ where $a^+$ is the pseudoinverse of $a$.


Later, you discover that you actually need to map a set of input vectors $\{a_k\}$ to a set of output vectors $\{b_k\}.\,\,\,$ Here is a matrix which addresses that situation $$M=BA^+$$ where $B$ is a matrix whose columns are the $\{b_k\}$ vectors, and ditto for $A$.


For a more complete solution, you can include contributions from the nullspace of $A$ $$M=BA^+ + G\,(I-AA^+)$$ where $G$ is an arbitrary matrix.

This solution remains valid when $A$ reverts to being the vector $a$, and is likely the answer to your original question.

0

Given an input $\mathrm a \in \mathbb R^n$ and an output $\mathrm b \in \mathbb R^m$, we would like to find $\mathrm X \in \mathbb R^{m \times n}$ such that

$$\mathrm X \mathrm a = \mathrm b$$

Vectorizing both sides, we obtain a linear system of $m$ equations in $m n$ unknowns

$$(\mathrm a^{\top} \otimes \mathrm I_m) \, \mbox{vec} (\mathrm X) = \mathrm b$$

Since this system is underdetermined when $n > 1$, there are infinitely many solutions. Let us look for the solution with the least Frobenius norm

$$\begin{array}{ll} \text{minimize} & \| \mathrm X \|_{\text{F}}^2\\ \text{subject to} & \mathrm X \mathrm a = \mathrm b\end{array}$$

We define the Lagrangian

$$\mathcal L (\mathrm x, \lambda) := \frac 12 \| \mathrm X \|_{\text{F}}^2 - \lambda^{\top} \left( \mathrm X \mathrm a - \mathrm b \right)$$

Taking partial derivatives and finding where they vanish, we obtain

$$\mathrm X = \lambda \mathrm a^{\top} \qquad \qquad \qquad \mathrm X \mathrm a = \mathrm b$$

Right-multiplying both sides of $\mathrm X = \lambda \mathrm a^{\top}$ by vector $\mathrm a$, we obtain

$$\lambda = \frac{\mathrm b \,\,}{\| \mathrm a \|_2^2}$$

and, thus, the least-norm solution is

$$\boxed{\mathrm X^* := \dfrac{\,\,\mathrm b \mathrm a^{\top}}{\| \mathrm a \|_2^2}}$$