Finding the matrix of this particular quadratic form I have been working on problems related to bilinear and quadratic forms,
and I came across an introductory problem that I have been having issues with.
Take
$$Q(x) = x_1^2 + 2x_1x_2 - 3x_1x_3 - 9x_2^2 + 6x_2x_3 + 13x_3^2$$
I want to find a matrix $A$ such that $Q(x) = \langle Ax,x \rangle$. My initial guess was to simply establish this via a coefficient matrix, i.e.,
$$A = \begin{bmatrix} 1 & 2 & -3\\ 2 & -9 & 6\\ -3 & 6 & 13\end{bmatrix}$$
However, upon closer inspection, I see that this matrix does not produce our
desired outcome. Is there a more reasonable algorithm for generating the
matrix $A$ of a quadratic form?
 A: There are infinitely many matrices $A$ such that $x^T A x = Q (x)$. The diagonal entries of $A$ are the coefficients of the $x_i^2$ monomials
$$A = \begin{bmatrix} 1 & a_{12} & a_{13}\\ a_{21} & -9 & a_{23}\\ a_{31} & a_{32} & 13\end{bmatrix}$$
The coefficients of the $x_i x_j$ monomials give us $3$ linear equality constraints on the entries of $A$ off the main diagonal
$$a_{12} + a_{21} = 2 \qquad \qquad a_{13} + a_{31} = -3 \qquad \qquad a_{23} + a_{32} = 6$$
Hence, both the upper triangular matrix
$$A = \begin{bmatrix} 1 & 2 & -3\\ 0 & -9 & 6\\ 0 & 0 & 13\end{bmatrix}$$
and the lower triangular matrix
$$A = \begin{bmatrix} 1 & 0 & 0\\ 2 & -9 & 0\\ -3 & 6 & 13\end{bmatrix}$$
are admissible. However, we usually choose to make $A$ a symmetric matrix so that $A$ is diagonalizable, has real eigenvalues and orthogonal eigenvectors. Hence,
$$a_{12} = a_{21} = 1 \qquad \qquad a_{13} = a_{31} = -\frac{3}{2} \qquad \qquad a_{23} = a_{32} = 3$$
A: Observe that $x^T A x = \sum_i \sum_j x_i x_j a_{ij}$.  If $-3x_1 x_3$ is the $x_1 x_3$ term in the quadratic form, then we want $a_{13} x_1 x_3 + a_{31} x_3 x_1$ to equal $-3x_1 x_3$.  So take $a_{13}=a_{31}=-3/2$.  The diagonal terms $a_{ii}$ can be taken to be the coefficient of $x_i x_i = x_i^2$. For example, due to the  $-9 x_2^2$ term, take $a_{22}=-9$.  So your answer for $A$ is correct except for the factor of $2$ in the off-diagonal terms.
A: The matrix associated with your quadratic form is
$$Q=\begin{pmatrix}1 & 1 & -\frac{3}{2} \\ 1 & -9 & 3 \\ -\frac{3}{2} & 3 & 13 \end{pmatrix}$$
and the characteristic polynomial of $Q$ is 
$$ q(x) = x^3-5x^2-\frac{501}{4}x+\frac{511}{4}$$
so the eigenvalues are 
$$\approx -9.5372,\qquad \approx 0.9886,\qquad \approx 13.5486. $$
