Bill Allombert on Thu, 07 Dec 2023 23:42:34 +0100


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

Re: norml2() with variables in vector?


On Thu, Dec 07, 2023 at 10:52:52PM +0100, hermann@stamm-wilbrandt.de wrote:
> 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.

You can use qfsolve by adding a variable (always the same trick).

v=[-102, -107, 93; 22, 23, -20; 1, 1, -1]^-1
M=matconcat([v~*v,0;0,-101]);
qfsolve(M)
%5 = [913,-197,-9,1]~
? substvec(14*a^2 + (130*b + 2*c)*a + (302*b^2 + 101*c^2),[a,b,c],[913,-197,-9])
%6 = 101

Or if you want all the solutions:

? M=v~*v;[x|x<-Vec(qfminim(M,101)[3]),qfeval(M,x)==101]
%18 = [[823,-177,-9]~,[828,-178,-9]~,[1032,-222,-11]~,[1037,-223,-11]~,[205,-44,-3]~,[613,-132,-7]~,[215,-46,-3]~,[1031,-222,-11]~,[643,-138,-7]~,[1459,-314,-15]~,[1061,-228,-11]~,[1469,-316,-15]~,[0,0,1]~,[204,-44,-3]~,[25,-5,-1]~,[1249,-269,-13]~,[239,-51,-3]~,[1463,-315,-15]~,[1284,-276,-13]~,[1488,-320,-15]~,[399,-86,-3]~,[417,-90,-5]~,[389,-84,-3]~,[835,-180,-9]~,[467,-100,-5]~,[1691,-364,-17]~,[885,-190,-9]~,[1701,-366,-17]~,[400,-86,-3]~,[196,-42,-1]~,[599,-129,-5]~,[217,-47,-3]~,[584,-126,-5]~,[844,-182,-9]~,[365,-79,-3]~,[1267,-273,-13]~,[151,-33,-1]~,[1481,-319,-15]~,[272,-58,-3]~,[1700,-366,-17]~,[899,-193,-9]~,[1715,-369,-17]~,[1312,-282,-13]~,[1516,-326,-15]~,[795,-171,-7]~,[387,-83,-3]~,[989,-213,-9]~,[235,-51,-3]~,[984,-212,-9]~,[444,-96,-5]~,[760,-164,-7]~,[1076,-232,-11]~,[332,-72,-3]~,[1504,-324,-15]~,[300,-64,-3]~,[1728,-372,-17]~,[509,-109,-5]~,[1733,-373,-17]~,[1131,-243,-11]~,[1539,-331,-15]~,[1185,-255,-11]~,[369,-79,-3]~,[1160,-250,-11]~,[676,-146,-7]~,[304,-66,-3]~,[1532,-330,-15]~,[741,-159,-7]~,[1557,-335,-15]~,[977,-210,-9]~,[1375,-296,-13]~,[151,-32,-1]~,[1365,-294,-13]~,[267,-58,-3]~,[927,-200,-9]~,[1113,-240,-11]~,[81,-18,-1]~,[1551,-334,-15]~,[337,-72,-3]~,[1561,-336,-15]~,[1163,-250,-11]~,[1172,-252,-11]~,[968,-208,-9]~,[1127,-243,-11]~,[913,-197,-9]~]

Cheers,
Bill

PS: PARI/GP is free for the Raspberry pi too!