hermann on Wed, 20 Dec 2023 02:14:29 +0100

 Re: Question on "qfminim()" for quadratic form

```On 2023-12-18 20:08, hermann@stamm-wilbrandt.de wrote:
```
```
So question was, whether there is an efficient method to
compute either [711, -153, -7]~ from M with minimal norml2 of 528979.
Or compute vector [311585, -67063, -3085]~ from M with
maximal norml2 of 101592175419.
...
Script used, tqf.gp has to be in same directory:

\$ cat S2.b.gp
n=eval(getenv("n"));
Q=get_tqf(n);
M=Q~*Q;

S=[x|x<-Vec(qfminim(M,n)[3]),qfeval(M,x)==n];
S2=vecsort(concat(S,-S),norml2);

{if(!eval(getenv("mindbg")),
foreach(S2,s,print(norml2(s)," ",s," ",Q*s)),
print(norml2(S2[1])," ",S2[1]," ",Q*S2[1]);
print("...");
print(norml2(S2[#S2])," ",S2[#S2]," ",Q*S2[#S2]))}

print("#S2=",#S2);
print("12*h(-4*n)=",12*qfbclassno(-4*n));

forqfvec(v,M,n,if(qfeval(M,v)==n,V=v;break()));
print(norml2(V)," ",V," ",Q*V);
\$

```
In the last few postings regarding ternary quadratic forms based on Dirichlet's 1850 construction in different threads, application of "qflllgram()" got lost.
```
With this little diff it is used again as it should:

\$ diff S2.b.gp S2.c.gp
3c3
< Q=get_tqf(n);
---
```
```Q=qflllgram(get_tqf(n))^-1;
```
```\$

```
And for that Q, with M=Q~*Q we know the minimal L2 norm vector, no search needed.
```It is [0,0,1]~ by Dirichlet's construction.
All L2 norms of the middle column vectors are much lower than before.
So only question remaining is, whether one can efficiently determine
the last vector with maximal L2 norm 3142707 of S2.

\$ n=101 gp -q < S2.c.gp
101=norml2([1, 6, 8])
all asserts OK
1 [0, 0, 1]~ [-1, -6, -8]~
1 [0, 0, -1]~ [1, 6, 8]~
651 [25, -5, -1]~ [6, 1, 8]~
651 [-25, 5, 1]~ [-6, -1, -8]~
6886 [81, -18, -1]~ [-8, 6, -1]~
6886 [-81, 18, 1]~ [8, -6, 1]~
23826 [151, -32, -1]~ [6, -8, -1]~
23826 [-151, 32, 1]~ [-6, 8, 1]~
23891 [151, -33, -1]~ [-8, 1, -6]~
23891 [-151, 33, 1]~ [8, -1, 6]~
40181 [196, -42, -1]~ [1, -8, -6]~
40181 [-196, 42, 1]~ [-1, 8, 6]~
43561 [204, -44, -3]~ [-1, 6, 8]~
43561 [-204, 44, 3]~ [1, -6, -8]~
43970 [205, -44, -3]~ [2, 4, 9]~
43970 [-205, 44, 3]~ [-2, -4, -9]~
48350 [215, -46, -3]~ [4, 2, 9]~
48350 [-215, 46, 3]~ [-4, -2, -9]~
49307 [217, -47, -3]~ [-4, 7, 6]~
49307 [-217, 47, 3]~ [4, -7, -6]~
57835 [235, -51, -3]~ [-6, 7, 4]~
57835 [-235, 51, 3]~ [6, -7, -4]~
59731 [239, -51, -3]~ [6, -1, 8]~
59731 [-239, 51, 3]~ [-6, 1, -8]~
74662 [267, -58, -3]~ [-8, 6, 1]~
74662 [-267, 58, 3]~ [8, -6, -1]~
77357 [272, -58, -3]~ [7, -4, 6]~
77357 [-272, 58, 3]~ [-7, 4, -6]~
94105 [300, -64, -3]~ [7, -6, 4]~
94105 [-300, 64, 3]~ [-7, 6, -4]~
96781 [304, -66, -3]~ [-9, 4, -2]~
96781 [-304, 66, 3]~ [9, -4, 2]~
115417 [332, -72, -3]~ [-9, 2, -4]~
115417 [-332, 72, 3]~ [9, -2, 4]~
118762 [337, -72, -3]~ [6, -8, 1]~
118762 [-337, 72, 3]~ [-6, 8, -1]~
139475 [365, -79, -3]~ [-8, -1, -6]~
139475 [-365, 79, 3]~ [8, 1, 6]~
142411 [369, -79, -3]~ [4, -9, -2]~
142411 [-369, 79, 3]~ [-4, 9, 2]~
156667 [387, -83, -3]~ [2, -9, -4]~
156667 [-387, 83, 3]~ [-2, 9, 4]~
158386 [389, -84, -3]~ [-6, -4, -7]~
158386 [-389, 84, 3]~ [6, 4, 7]~
166606 [399, -86, -3]~ [-4, -6, -7]~
166606 [-399, 86, 3]~ [4, 6, 7]~
167405 [400, -86, -3]~ [-1, -8, -6]~
167405 [-400, 86, 3]~ [1, 8, 6]~
182014 [417, -90, -5]~ [-4, 6, 7]~
182014 [-417, 90, 5]~ [4, -6, -7]~
206377 [444, -96, -5]~ [-7, 6, 4]~
206377 [-444, 96, 5]~ [7, -6, -4]~
228114 [467, -100, -5]~ [6, -4, 7]~
228114 [-467, 100, 5]~ [-6, 4, -7]~
270987 [509, -109, -5]~ [6, -7, 4]~
270987 [-509, 109, 5]~ [-6, 7, -4]~
356957 [584, -126, -5]~ [-7, -4, -6]~
356957 [-584, 126, 5]~ [7, 4, 6]~
375467 [599, -129, -5]~ [-4, -7, -6]~
375467 [-599, 129, 5]~ [4, 7, 6]~
393242 [613, -132, -7]~ [-2, 4, 9]~
393242 [-613, 132, 7]~ [2, -4, -9]~
432542 [643, -138, -7]~ [4, -2, 9]~
432542 [-643, 138, 7]~ [-4, 2, -9]~
478341 [676, -146, -7]~ [-9, 4, 2]~
478341 [-676, 146, 7]~ [9, -4, -2]~
574411 [741, -159, -7]~ [4, -9, 2]~
574411 [-741, 159, 7]~ [-4, 9, -2]~
604545 [760, -164, -7]~ [-9, -2, -4]~
604545 [-760, 164, 7]~ [9, 2, 4]~
661315 [795, -171, -7]~ [-2, -9, -4]~
661315 [-795, 171, 7]~ [2, 9, 4]~
708739 [823, -177, -9]~ [0, 1, 10]~
708739 [-823, 177, 9]~ [0, -1, -10]~
717349 [828, -178, -9]~ [1, 0, 10]~
717349 [-828, 178, 9]~ [-1, 0, -10]~
729706 [835, -180, -9]~ [-6, 4, 7]~
729706 [-835, 180, 9]~ [6, -4, -7]~
745541 [844, -182, -9]~ [-7, 4, 6]~
745541 [-844, 182, 9]~ [7, -4, -6]~
819406 [885, -190, -9]~ [4, -6, 7]~
819406 [-885, 190, 9]~ [-4, 6, -7]~
845531 [899, -193, -9]~ [4, -7, 6]~
845531 [-899, 193, 9]~ [-4, 7, -6]~
872459 [913, -197, -9]~ [-10, 1, 0]~
872459 [-913, 197, 9]~ [10, -1, 0]~
899410 [927, -200, -9]~ [-10, 0, -1]~
899410 [-927, 200, 9]~ [10, 0, 1]~
980369 [968, -208, -9]~ [1, -10, 0]~
980369 [-968, 208, 9]~ [-1, 10, 0]~
998710 [977, -210, -9]~ [0, -10, -1]~
998710 [-977, 210, 9]~ [0, 10, 1]~
1013281 [984, -212, -9]~ [-7, -6, -4]~
1013281 [-984, 212, 9]~ [7, 6, 4]~
1023571 [989, -213, -9]~ [-6, -7, -4]~
1023571 [-989, 213, 9]~ [6, 7, 4]~
1112366 [1031, -222, -11]~ [-4, 2, 9]~
1112366 [-1031, 222, 11]~ [4, -2, -9]~
1114429 [1032, -222, -11]~ [-1, 0, 10]~
1114429 [-1032, 222, 11]~ [1, 0, -10]~
1125219 [1037, -223, -11]~ [0, -1, 10]~
1125219 [-1037, 223, 11]~ [0, 1, -10]~
1177826 [1061, -228, -11]~ [2, -4, 9]~
1177826 [-1061, 228, 11]~ [-2, 4, -9]~
1211721 [1076, -232, -11]~ [-9, 2, 4]~
1211721 [-1076, 232, 11]~ [9, -2, -4]~
1296490 [1113, -240, -11]~ [-10, 0, 1]~
1296490 [-1113, 240, 11]~ [10, 0, -1]~
1329299 [1127, -243, -11]~ [-10, -1, 0]~
1329299 [-1127, 243, 11]~ [10, 1, 0]~
1338331 [1131, -243, -11]~ [2, -9, 4]~
1338331 [-1131, 243, 11]~ [-2, 9, -4]~
1408221 [1160, -250, -11]~ [-9, -4, -2]~
1408221 [-1160, 250, 11]~ [9, 4, 2]~
1415190 [1163, -250, -11]~ [0, -10, 1]~
1415190 [-1163, 250, 11]~ [0, 10, -1]~
1437209 [1172, -252, -11]~ [-1, -10, 0]~
1437209 [-1172, 252, 11]~ [1, 10, 0]~
1469371 [1185, -255, -11]~ [-4, -9, -2]~
1469371 [-1185, 255, 11]~ [4, 9, 2]~
1632531 [1249, -269, -13]~ [-6, 1, 8]~
1632531 [-1249, 269, 13]~ [6, -1, -8]~
1679987 [1267, -273, -13]~ [-8, 1, 6]~
1679987 [-1267, 273, 13]~ [8, -1, -6]~
1725001 [1284, -276, -13]~ [1, -6, 8]~
1725001 [-1284, 276, 13]~ [-1, 6, -8]~
1801037 [1312, -282, -13]~ [1, -8, 6]~
1801037 [-1312, 282, 13]~ [-1, 8, -6]~
1949830 [1365, -294, -13]~ [-8, -6, -1]~
1949830 [-1365, 294, 13]~ [8, 6, 1]~
1978410 [1375, -296, -13]~ [-6, -8, -1]~
1978410 [-1375, 296, 13]~ [6, 8, 1]~
2227502 [1459, -314, -15]~ [-4, -2, 9]~
2227502 [-1459, 314, 15]~ [4, 2, -9]~
2239819 [1463, -315, -15]~ [-6, -1, 8]~
2239819 [-1463, 315, 15]~ [6, 1, -8]~
2258042 [1469, -316, -15]~ [-2, -4, 9]~
2258042 [-1469, 316, 15]~ [2, 4, -9]~
2295347 [1481, -319, -15]~ [-8, -1, 6]~
2295347 [-1481, 319, 15]~ [8, 1, -6]~
2316769 [1488, -320, -15]~ [-1, -6, 8]~
2316769 [-1488, 320, 15]~ [1, 6, -8]~
2367217 [1504, -324, -15]~ [-9, -2, 4]~
2367217 [-1504, 324, 15]~ [9, 2, -4]~
2404757 [1516, -326, -15]~ [-1, -8, 6]~
2404757 [-1516, 326, 15]~ [1, 8, -6]~
2456149 [1532, -330, -15]~ [-9, -4, 2]~
2456149 [-1532, 330, 15]~ [9, 4, -2]~
2478307 [1539, -331, -15]~ [-2, -9, 4]~
2478307 [-1539, 331, 15]~ [2, 9, -4]~
2517382 [1551, -334, -15]~ [-8, -6, 1]~
2517382 [-1551, 334, 15]~ [8, 6, -1]~
2536699 [1557, -335, -15]~ [-4, -9, 2]~
2536699 [-1557, 335, 15]~ [4, 9, -2]~
2549842 [1561, -336, -15]~ [-6, -8, 1]~
2549842 [-1561, 336, 15]~ [6, 8, -1]~
2992266 [1691, -364, -17]~ [-6, -4, 7]~
2992266 [-1691, 364, 17]~ [6, 4, -7]~
3024245 [1700, -366, -17]~ [-7, -4, 6]~
3024245 [-1700, 366, 17]~ [7, 4, -6]~
3027646 [1701, -366, -17]~ [-4, -6, 7]~
3027646 [-1701, 366, 17]~ [4, 6, -7]~
3077675 [1715, -369, -17]~ [-4, -7, 6]~
3077675 [-1715, 369, 17]~ [4, 7, -6]~
3124657 [1728, -372, -17]~ [-7, -6, 4]~
3124657 [-1728, 372, 17]~ [7, 6, -4]~
3142707 [1733, -373, -17]~ [-6, -7, 4]~
3142707 [-1733, 373, 17]~ [6, 7, -4]~
#S2=168
12*h(-4*n)=168
708739 [823, -177, -9]~ [0, 1, 10]~
\$

Regards,

Hermann.

```