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(x1,…,x7)=−x21−2x22−5x23−4x24−2x25−71x26−2x27+2x1x2+2x1x3+2x1x4+2x1x6+2x4x5+2x6x7,
which is a negative definite quadratic form, i.e. f(x1,…,xn)<0 for all nonzero (x1,…,x7)∈R7. The answers used the "completing the square method" to express f as sums of negative squares: f(x)=−(x1−x2−x3−x4−x6)2−(x2−x3−x4−x6)2−3(x3−23x4−23x6)2−23(x4−32x5−5x6)2−12(x5−10x6)2−(x6−x7)2−x27
Now let f(x1,…,xn) 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 x1, and get f=−c(x1−f1(x2,…,xn))2+g1(x2,…,xn),
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(x1,…,xn)=−x21−3x22−5x23−7x24−4x25−2(x26+⋯+x215)+2x1x2+2x1x3+2x1x4+2x1x5+2(x5x6+x6x7+⋯+x14x15),
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.