hermann on Tue, 21 Nov 2023 01:39:42 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Question on ternary quadratic form |
On 2023-11-20 23:18, Bill Allombert wrote:
The difference is that tqf is calling ispseudoprime on numbers of size n, whilethreesquares only call ispseudoprime on numbers of size about sqrt(n). If you like to have an assert() that you can easily disable, you can define it as assert(b,s="assert") = if(!b(),error(Str(s))); and then replace assert(COND) by assert(()->COND) This way you can disable assert() by refinining it as assert(b,s)=; and COND will not be evaluated.
Thanks for the assert trick! And for the ispseudoprime() explanation n vs sqrt(n).The initial ternary quadratic form matrix generation goes back to Dirichlet 1850.
I did brute force determine all matrices ? Q [a b 1] [b c 0] [1 0 n] ?with matdet(Q)==1 ( and qfeval(Q,[0,0,1]~)==n ) for a,b,c up to some factor of n:
https://www.mersenneforum.org/showthread.php?p=643698#post643698Interesting to see other ternary quadratic forms result in different sums of squares:
? {Qs=[ [2,16,1;16,129,0;1,0,65] ,[26,71,1;71,194,0;1,0,65] ,[27,59,1;59,129,0;1,0,65] ,[30,108,1;108,389,0;1,0,65] ,[38,70,1;70,129,0;1,0,65] ,[78,123,1;123,194,0;1,0,65] ,[99,113,1;113,129,0;1,0,65] ,[163,145,1;145,129,0;1,0,65] ,[203,281,1;281,389,0;1,0,65] ,[274,188,1;188,129,0;1,0,65] ,[307,199,1;199,129,0;1,0,65] ,[362,265,1;265,194,0;1,0,65] ];} ? foreach(Qs,Q,print((qflllgram(Q)^-1)*[0,0,1]~)) [-8, 0, 1]~ [2, -5, -6]~ [-2, -5, 6]~ [-7, 0, -4]~ [-2, -5, -6]~ [5, 2, -6]~ [8, 0, -1]~ [-8, 0, -1]~ [-7, 0, 4]~ [-2, -5, -6]~ [-2, -5, 6]~ [2, -5, 6]~ ? Would be nice to identify how to get those containing 0^2 ;-) Such "sum of two squares" would allow to factor n easily: ? gcd(65, (8+4)^2 + (1-7)^2) %49 = 5 ? gcd(65, (8+4)^2 + (1+7)^2) %50 = 13 ? Regards, Hermann.