# Find the symmetrical matrix $A$ so that $Q(\vec x) = \vec x^TA \vec x$

$$Q(\vec x) = x_1^2+x_1x_2+x_2^2$$

The matrix $$A=\begin{bmatrix}1 & 0.5 \\ 0.5 & 1\end{bmatrix}$$ seems to do the job. But what's the general procedure for finding a solution?

I can just think of setting it up like this for more clarity:

$$\begin{bmatrix}x_1 & x_2\end{bmatrix}\begin{bmatrix}? & ?\\ ? & ?\end{bmatrix}\begin{bmatrix}x_1\\ x_2\end{bmatrix} =\begin{bmatrix}x_1^2+x_1x_2+x_2^2\end{bmatrix}$$

But after that I'm lost, there surely must be some concepts I can apply.

• Short of writing $$A=\begin{bmatrix}a&b\\b&d\end{bmatrix}$$ I am not sure there is much more that you can do. That would probably be the best way for 2x2 matrices, though this would get more complicated for larger matrices. Guessing the answer is often the quickest way though. – John Doe Apr 5 '19 at 15:37

$$A$$ is called the matrix associated with the quadratic form $$Q$$. The general procedure is rather simple: put the coefficients of $$x_i^2$$ in the diagonal $$a_{ii}$$ and divide the coefficient of $$x_{ij}$$ in $$2$$, writing it twice in $$A$$: once in $$a_{ij}$$ and once in $$a_{ji}$$.
In your example, the coefficient of $$x_1^2$$ is $$1$$ so $$a_{11}=1$$, the coefficient of $$x_2^2$$ is $$1$$ so $$a_{22}=1$$. The coefficient of $$x_1x_2$$ is $$1$$ so $$a_{12}=a_{21}=\frac{1}{2}$$, resulting in: $$A=\begin{pmatrix} 1 & 0.5 \\ 0.5 & 1 \end{pmatrix}$$
Here is another example. Consider $$Q(\underline{x})=x_1^2+2x_2^2+x_3^2+2x_1x_2+x_3x_2$$. Then the matrix associated with $$Q$$ is: $$\begin{pmatrix} 1 & 1 & 0 \\ 1 & 2 & 0.5\\ 0 & 0.5 & 1 \end{pmatrix}$$ For further information see here.