hermann on Mon, 18 Dec 2023 20:08:49 +0100

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

```On 2023-12-18 18:38, Bill Allombert wrote:
```
On Mon, Dec 18, 2023 at 04:05:39PM +0100, hermann@stamm-wilbrandt.de wrote:
```pi@raspberrypi5:~ \$ n=101 gp -q < m2.gp
101=[1, 6, 8]
```
```
I am not sure what you mean by 'maximal norm vector",

```
```S2 is concat(S,-S) sorted by L2 norm.

The "norml2()" values are first column in output:
...
```
```all asserts OK
528979 [711, -153, -7]~ [2, 9, 4]~
10232019 [3127, -673, -31]~ [2, 9, -4]~
...
97549123438 [305322, -65715, -3023]~ [10, 0, -1]~
101592175419 [311585, -67063, -3085]~ [10, -1, 0]~
#S2=168
```
```...

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.

```
```but it you just want one solution, you can try this

forqfvec(v,M,n,if(qfeval(M,v)==n,V=v;break()))

Cheers,
Bill.

```
```That method is fast, and for n=101 it does compute maximal vector.

```
But for n=149 it does compute neither minimal nor maximal norml2 vector of M:
```
pi@raspberrypi5:~ \$ mindbg=1 n=149 gp -q < S2.b.gp
149=[2, 8, 9]
all asserts OK
64338414 [7898, -1399, -53]~ [-2, -12, 1]~
...
695958036266 [-821436, 145501, 5513]~ [-12, 2, 1]~
#S2=168
12*h(-4*n)=168
617037140090 [773460, -137003, -5191]~ [12, 2, 1]~
pi@raspberrypi5:~ \$

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);
\$

Regards,

Hermann.

```