In this question: Calculating the maximum value of a quadratic polynomial on several variables with some restrictions, I asked about finding the maximum value of a certain quadratic polynomial with some restrictions on the variables. Actually, the function was $$f(x_1,\dots,x_7)=-x_1^2-2x_2^2-5x_3^2-4x_4^2-2x_5^2-71x_6^2-2x_7^2+2x_1x_2+2x_1x_3+2x_1x_4+2x_1x_6+2x_4x_5+2x_6x_7, $$ which is a negative definite quadratic form, i.e. $f(x_1,\dots,x_n)<0$ for all nonzero $(x_1,\dots,x_7)\in \Bbb R^7$. The answers used the "completing the square method" to express $f$ as sums of negative squares: $$\begin{aligned}f(x) = -(x_1-x_2-x_3-x_4-x_6)^2&\\ -(x_2-x_3-x_4-x_6)^2&\\ - 3(x_3-\frac23x_4-\frac23x_6)^2&\\ - \frac23(x_4-\frac32x_5-5x_6)^2&\\ - \frac12 (x_5-10x_6)^2&\\ - (x_6-x_7)^2 &\\ - x_7^2& \end{aligned}$$
Now let $f(x_1,\dots,x_n)$ be a negative definite quadratic form on $n$ variables. Is there a calculator or program that expresses $f$ as sums of negative sqaures as in the above situation?
Clearly we have an algorithm for doing this: we first gather the terms containing $x_1$, and get $$f=-c(x_1-f_1(x_2,\dots,x_n))^2 + g_1(x_2,\dots,x_n),$$ and so on. I can do this by hand if $n$ is not large, but if $n$ gets large, then it takes too much time for doing this. For example, if $$f(x_1,\dots,x_n)=-x_1^2-3x_2^2-5x_3^2-7x_4^2-4x_5^2-2(x_6^2+\cdots+x_{15}^2)+2x_1x_2+2x_1x_3+2x_1x_4+2x_1x_5+2(x_5x_6+x_6x_7+\cdots+x_{14}x_{15}),$$ then this is a negative definite quadratic form but the calculation becomes too complicated to do it by hand. So I am finding a calculating program for doing this.
This new matrix is symmetric unimodular. Meanwhile, here is a rational version that requires a diagonal rational matrix in the middle.
In dimension $8$ or larger, a symmetric positive definite integer matrix of determinant $1$ is not guaranteed to be expressible as $P^T P...$
My try to write it my $H$ ( the negative of your matrix) as some $ H=P^T P$ seemed to fail. One simple way to confirm: write a computer program, integer variables $x_1$ up to $x_{15} $ as vector $v,$ in a multiple loop, and count the number of ways that $v^T H v = 1$ which would be the count of your $f(v) = -1.$ The count of $v$ with $v \cdot v = 1$ is exactly $30,$ those being $\pm e_i$ where $e_i$ has a one in position $i$ with the other spots $0.$ If the count of $f(v) = -1$ is different from $30$ the failure is confirmed.
$$ \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc \bigcirc $$
$$ Q^T D Q = H $$
$$ Q^T = \left( \begin{array}{rrrrrrrrrrrrrrr} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ - 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ - 1 & - \frac{ 1 }{ 2 } & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ - 1 & - \frac{ 1 }{ 2 } & - \frac{ 3 }{ 7 } & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ - 1 & - \frac{ 1 }{ 2 } & - \frac{ 3 }{ 7 } & - \frac{ 15 }{ 34 } & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & - \frac{ 34 }{ 31 } & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & - \frac{ 31 }{ 28 } & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & - \frac{ 28 }{ 25 } & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & - \frac{ 25 }{ 22 }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