# 'Undo' a matrix-vector product

I was wondering if there is an inbuilt Mathematica function that can take a vector $$v$$ whose components are sums of variables $$x_1, x_2, \dots x_{n}$$ and turn it into a matrix-vector product, where the matrix is just a coefficient matrix and vector is right and composed only of the variables? For example, is there a Mathematica function $$F$$ such that

$$\begin{pmatrix} x_{1} + 2x_{2} \\ 3x_{1} + 4x_{2}\end{pmatrix} \stackrel{F}{\to} \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} x_{1} \\ x_{2} \end{pmatrix}$$

Essentially, I'm looking for a function that 'undoes' the matrix-vector multiplication. Apologies if this has been asked before or is very simple to implement, I'm not overly familiar with Mathematica and so I don't even know what to search for.

• CoefficientArrays? Apr 6, 2020 at 11:05
• @xzczd Thanks for letting me know about this function, I'll give it a try. Apr 6, 2020 at 11:10

D[{x[1] + 2 x[2], 3 x[1] + 4 x[2]}, {{x[1], x[2]}, 1}]