TITLE: Elimination of variables the old-fashioned way
QUESTION [9 upvotes]: I'm trying to eliminate variables in some fairly simple sets of equations. A typical example is: 
$$ 9 x^2 + 18 xy + 9 y^2 - 32 = 256z$$
$$ 9 x^2 + 6 xy - 3 y^2 - 8 = 376z$$
$$ 9 x^2 - 6 xy  + y^2 = 512z$$
I'd like to eliminate $x$ and $y$. Mathematica tells me that the answer is $ 161 z^2 -162z + 1 = 0 $. OK. Good.
But how would I do this elimination manually (without Mathematica). I'm hoping that there is some fairly simple mechanical process that I can express in a few hundred lines of C code.
I realize that general elimination procedures are pretty complex, but this sort of problem looks quite special and therefore easier (I hope). Roughly speaking, it's just a system of "linear" equations in the variables $x^2$, $xy$, $y^2$, and $z$. Is there some sort of diagonalization process that can be applied, for example ?
Edit:
From the proposed answer below, I see that things can be simplified by setting $p=3x+3y$ and $q = 3x-y$. Then the equations become:
$$p^2 = 32 + 256z$$
$$pq = 8 + 376z$$
$$q^2 = 512z$$
I can then eliminate $p$ and $q$. Is there always a linear transformation that simplifies the problem in this way? If there is, how do I compute it?

REPLY [2 votes]: Clever Observant Solution (as in Mark's comment)
Denote the right-hand sides by $a$, $b$, $c$. In other words, $a = 32+256z$, $b = 8 + 376z$, $c = 512z$. Also, let $p = 3x + 3y$ and $q = 3x - y$. Then the equations become simply:
$$ p^2 = a \quad ; \quad pq = b \quad ; \quad q^2 = c$$
From this, we get $b^2 - ac = 0$. Substituting for $a$, $b$, $c$ gives us the same result we got from Mathematica: $161z^2 -162z + 1 = 0$.
Dumb Mechanical Solution (which is what I need)
Let $M$ be the matrix
$$ M = \begin{pmatrix} 9&18&9\\9&6&\!\!\!\!-3\\9&\!\!\!\!-6&1\end{pmatrix}$$
and let $u = x^2$, $v = xy$, $w = y^2$. Then the original equations can be written as
$M.[u, v, w]^t = [a, b, c]^t$.
Using standard techniques (eigenvalues or Gaussian elimination), we can find a diagonal matrix $D$ and an invertible matrix $P$ such that $P^{-1}MP = D$. The solution of the system of equations is then $[u, v, w]^t = PD^{-1}P^{-1}[a, b, c]^t$. Setting $v^2 = uw$ again gives us the equation $161z^2 -162z + 1 = 0$.