hermann on Thu, 07 Dec 2023 22:53:00 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: norml2() with variables in vector?


On 2023-12-07 20:09, Bill Allombert wrote:

You are victim of a strange PARI behaviour which is that some functions
are fully recursive so

norml2([a,b,c]) = norml2(a) + norml2(b) + norml2(c)
etc.

? (3^2+14^2+1^2)+(2^2+9^2+6^2)+(1^2+5^2+8^2)
%4 = 417

Oops.

You probably want v~*v
? v~*v
%5 = 14*a^2+(130*b+2*c)*a+(302*b^2+101*c^2)

Cheers,
Bill

Thank you, that was indeed what I want.

G was the matrix computed with qflllgram() from ternary quadratic form
with determinant 1 representing 101.

? v=[-102, -107, 93; 22, 23, -20; 1, 1, -1]^-1*[0,0,1]~
[-1, -6, -8]~
? v~*v
101
?

Now with variables as you showed:

? v=[-102, -107, 93; 22, 23, -20; 1, 1, -1]^-1*[a,b,c]~
[3*a + (14*b - c), -2*a + (-9*b - 6*c), a + (5*b - 8*c)]~
? v~*v
14*a^2 + (130*b + 2*c)*a + (302*b^2 + 101*c^2)
?


Next I had to switch to wolframscript since I don't know how to
solve the equation in Integers with PARI/GP.


In the output below (middle) is "{a -> 0, b -> 0, c -> 1}" corresponding to first calculation.

Regards,

Hermann.


Mathematica/wolframscript is free use on Raspberry computers.
Yesterday I ordered new Raspberry Pi5 computer for 60$.
It is 2-3x faster than my Pi4Bs and my Pi400.

While I can use PARI/GP on those computers as well, it is 7x
faster on my AMD 7600X/7950X computers.


pi@raspberrypi400:~ $ wolframscript
Wolfram Language 13.3.1 Engine for Linux ARM (64-bit)
Copyright 1988-2023 Wolfram Research, Inc.

In[1]:= Solve[14*a^2+(130*b+2*c)*a+(302*b^2+101*c^2)==101,{a,b,c},Integers]

Out[1]= {{a -> -1733, b -> 373, c -> 17}, {a -> -1728, b -> 372, c -> 17},

   {a -> -1715, b -> 369, c -> 17}, {a -> -1701, b -> 366, c -> 17},

   {a -> -1700, b -> 366, c -> 17}, {a -> -1691, b -> 364, c -> 17},

   {a -> -1561, b -> 336, c -> 15}, {a -> -1557, b -> 335, c -> 15},

   {a -> -1551, b -> 334, c -> 15}, {a -> -1539, b -> 331, c -> 15},

   {a -> -1532, b -> 330, c -> 15}, {a -> -1516, b -> 326, c -> 15},

   {a -> -1504, b -> 324, c -> 15}, {a -> -1488, b -> 320, c -> 15},

   {a -> -1481, b -> 319, c -> 15}, {a -> -1469, b -> 316, c -> 15},

   {a -> -1463, b -> 315, c -> 15}, {a -> -1459, b -> 314, c -> 15},

   {a -> -1375, b -> 296, c -> 13}, {a -> -1365, b -> 294, c -> 13},

   {a -> -1312, b -> 282, c -> 13}, {a -> -1284, b -> 276, c -> 13},

   {a -> -1267, b -> 273, c -> 13}, {a -> -1249, b -> 269, c -> 13},

   {a -> -1185, b -> 255, c -> 11}, {a -> -1172, b -> 252, c -> 11},

   {a -> -1163, b -> 250, c -> 11}, {a -> -1160, b -> 250, c -> 11},

   {a -> -1131, b -> 243, c -> 11}, {a -> -1127, b -> 243, c -> 11},

   {a -> -1113, b -> 240, c -> 11}, {a -> -1076, b -> 232, c -> 11},

   {a -> -1061, b -> 228, c -> 11}, {a -> -1037, b -> 223, c -> 11},

   {a -> -1032, b -> 222, c -> 11}, {a -> -1031, b -> 222, c -> 11},

   {a -> -989, b -> 213, c -> 9}, {a -> -984, b -> 212, c -> 9},

   {a -> -977, b -> 210, c -> 9}, {a -> -968, b -> 208, c -> 9},

   {a -> -927, b -> 200, c -> 9}, {a -> -913, b -> 197, c -> 9},

   {a -> -899, b -> 193, c -> 9}, {a -> -885, b -> 190, c -> 9},

   {a -> -844, b -> 182, c -> 9}, {a -> -835, b -> 180, c -> 9},

   {a -> -828, b -> 178, c -> 9}, {a -> -823, b -> 177, c -> 9},

   {a -> -795, b -> 171, c -> 7}, {a -> -760, b -> 164, c -> 7},

   {a -> -741, b -> 159, c -> 7}, {a -> -676, b -> 146, c -> 7},

   {a -> -643, b -> 138, c -> 7}, {a -> -613, b -> 132, c -> 7},

   {a -> -599, b -> 129, c -> 5}, {a -> -584, b -> 126, c -> 5},

   {a -> -509, b -> 109, c -> 5}, {a -> -467, b -> 100, c -> 5},

   {a -> -444, b -> 96, c -> 5}, {a -> -417, b -> 90, c -> 5},

   {a -> -400, b -> 86, c -> 3}, {a -> -399, b -> 86, c -> 3},

   {a -> -389, b -> 84, c -> 3}, {a -> -387, b -> 83, c -> 3},

   {a -> -369, b -> 79, c -> 3}, {a -> -365, b -> 79, c -> 3},

   {a -> -337, b -> 72, c -> 3}, {a -> -332, b -> 72, c -> 3},

   {a -> -304, b -> 66, c -> 3}, {a -> -300, b -> 64, c -> 3},

   {a -> -272, b -> 58, c -> 3}, {a -> -267, b -> 58, c -> 3},

   {a -> -239, b -> 51, c -> 3}, {a -> -235, b -> 51, c -> 3},

   {a -> -217, b -> 47, c -> 3}, {a -> -215, b -> 46, c -> 3},

   {a -> -205, b -> 44, c -> 3}, {a -> -204, b -> 44, c -> 3},

   {a -> -196, b -> 42, c -> 1}, {a -> -151, b -> 32, c -> 1},

   {a -> -151, b -> 33, c -> 1}, {a -> -81, b -> 18, c -> 1},

   {a -> -25, b -> 5, c -> 1}, {a -> 0, b -> 0, c -> -1},

   {a -> 0, b -> 0, c -> 1}, {a -> 25, b -> -5, c -> -1},

   {a -> 81, b -> -18, c -> -1}, {a -> 151, b -> -33, c -> -1},

   {a -> 151, b -> -32, c -> -1}, {a -> 196, b -> -42, c -> -1},

   {a -> 204, b -> -44, c -> -3}, {a -> 205, b -> -44, c -> -3},

   {a -> 215, b -> -46, c -> -3}, {a -> 217, b -> -47, c -> -3},

   {a -> 235, b -> -51, c -> -3}, {a -> 239, b -> -51, c -> -3},

   {a -> 267, b -> -58, c -> -3}, {a -> 272, b -> -58, c -> -3},

   {a -> 300, b -> -64, c -> -3}, {a -> 304, b -> -66, c -> -3},

   {a -> 332, b -> -72, c -> -3}, {a -> 337, b -> -72, c -> -3},

   {a -> 365, b -> -79, c -> -3}, {a -> 369, b -> -79, c -> -3},

   {a -> 387, b -> -83, c -> -3}, {a -> 389, b -> -84, c -> -3},

   {a -> 399, b -> -86, c -> -3}, {a -> 400, b -> -86, c -> -3},

   {a -> 417, b -> -90, c -> -5}, {a -> 444, b -> -96, c -> -5},

   {a -> 467, b -> -100, c -> -5}, {a -> 509, b -> -109, c -> -5},

   {a -> 584, b -> -126, c -> -5}, {a -> 599, b -> -129, c -> -5},

   {a -> 613, b -> -132, c -> -7}, {a -> 643, b -> -138, c -> -7},

   {a -> 676, b -> -146, c -> -7}, {a -> 741, b -> -159, c -> -7},

   {a -> 760, b -> -164, c -> -7}, {a -> 795, b -> -171, c -> -7},

   {a -> 823, b -> -177, c -> -9}, {a -> 828, b -> -178, c -> -9},

   {a -> 835, b -> -180, c -> -9}, {a -> 844, b -> -182, c -> -9},

   {a -> 885, b -> -190, c -> -9}, {a -> 899, b -> -193, c -> -9},

   {a -> 913, b -> -197, c -> -9}, {a -> 927, b -> -200, c -> -9},

   {a -> 968, b -> -208, c -> -9}, {a -> 977, b -> -210, c -> -9},

   {a -> 984, b -> -212, c -> -9}, {a -> 989, b -> -213, c -> -9},

   {a -> 1031, b -> -222, c -> -11}, {a -> 1032, b -> -222, c -> -11},

   {a -> 1037, b -> -223, c -> -11}, {a -> 1061, b -> -228, c -> -11},

   {a -> 1076, b -> -232, c -> -11}, {a -> 1113, b -> -240, c -> -11},

   {a -> 1127, b -> -243, c -> -11}, {a -> 1131, b -> -243, c -> -11},

   {a -> 1160, b -> -250, c -> -11}, {a -> 1163, b -> -250, c -> -11},

   {a -> 1172, b -> -252, c -> -11}, {a -> 1185, b -> -255, c -> -11},

   {a -> 1249, b -> -269, c -> -13}, {a -> 1267, b -> -273, c -> -13},

   {a -> 1284, b -> -276, c -> -13}, {a -> 1312, b -> -282, c -> -13},

   {a -> 1365, b -> -294, c -> -13}, {a -> 1375, b -> -296, c -> -13},

   {a -> 1459, b -> -314, c -> -15}, {a -> 1463, b -> -315, c -> -15},

   {a -> 1469, b -> -316, c -> -15}, {a -> 1481, b -> -319, c -> -15},

   {a -> 1488, b -> -320, c -> -15}, {a -> 1504, b -> -324, c -> -15},

   {a -> 1516, b -> -326, c -> -15}, {a -> 1532, b -> -330, c -> -15},

   {a -> 1539, b -> -331, c -> -15}, {a -> 1551, b -> -334, c -> -15},

   {a -> 1557, b -> -335, c -> -15}, {a -> 1561, b -> -336, c -> -15},

   {a -> 1691, b -> -364, c -> -17}, {a -> 1700, b -> -366, c -> -17},

   {a -> 1701, b -> -366, c -> -17}, {a -> 1715, b -> -369, c -> -17},

   {a -> 1728, b -> -372, c -> -17}, {a -> 1733, b -> -373, c -> -17}}

In[2]:=