Consider a quadratic form $$f(x) = \sum_{i=1}^{n}a_i x_i ^2$$ $f$ represents $0$ non-trivially. Then I need to show that by a linear change of variables, I can get the following quadratic form $$f(y) = \sum_{i=1}^{n-2}b_i y_i ^2 - 2 b_ny_{n-1}y_n$$
Now as suggested in Find a change in variable that will reduce the quadratic form to a sum of squares by Gerry Myerson, I put $x = Py$ , for some $n \times n$ matrix $P$. Then $$f(x)=f(Py)=(Py)^tAPy=y^t(P^tAP)y$$ My question is how do I find the matrix $P$ s.t. I get $f(y)$ as mentioned above.