# Is there a systematic way of finding the matrix of a quadratic form? [duplicate]

For example i have this quadratic form $q(x_1,x_2)=8{x_1}^2-4x_1x_2+5{x_2}^2$ , here it's a simple factoring:

$q\begin{bmatrix}x_1 \\x_2 \\x_3\\\end{bmatrix}=\begin{bmatrix}x_1 \\x_2 \\x_3\\\end{bmatrix} \cdot \begin{bmatrix}8x_1 &-2x_2\\-2x_1&5x_2\end{bmatrix}=\vec{x}^{T}A\vec{x} ,A=\begin{bmatrix}8 &-2\\-2&5\end{bmatrix}$.

But this is not always the case where one can simply see how the matrix is going to be ,so is there a certain method of finding this matrix?

## marked as duplicate by Dietrich Burde, Lord Shark the Unknown, José Carlos Santos, Daniel W. Farlow, Namaste linear-algebra StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Jul 22 '17 at 20:50

The matrix of the quadratic form $q(x_1,x_2)=a{x_1}^2+bx_1x_2+c{x_2}^2$ is always$$\begin{pmatrix}a&\frac b2\\\frac b2&c\end{pmatrix}.$$
• This works for any $\vec{x}\in{\mathbb{R}^{n}} ,q\vec{x}$? – user3133165 Jul 22 '17 at 11:17
• Let's say i have $q(x_1,x_2,x_3)=x_1^2+x_1x_2-x_1x_3$ how will this work here? – user3133165 Jul 22 '17 at 11:21
• @user3133165 Sure: $\begin{pmatrix}1&1/2&-1/2\\1/2&0&0\\-1/2&0&0\end{pmatrix}$. – José Carlos Santos Jul 22 '17 at 11:38
The general method is to write the coefficients of the quadratic terms on the diagonal. And for the $a_{ij}x_ix_j$ terms write $a_{ij}/2$ into the i.th row and j.th column and also into the j.th row and the i.th column.