Re: expressing a number as the sum of 3 triangular numbers

[email protected] Sun, 16 Nov 2025 18:36:59 +0100
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
On 2025-11-16 03:28, Max Alekseyev wrote:
> You can replace sqs3 with
> 
> { sqs3_(N) = my(s = qfsolve(matdiagonal([1,1,1,-N])));
> vector(3,i,abs(s[i]/s[4])); }
> 
> Regards,
> Max
> 
Wow, your solution is a oneliner for "sum of three squares":

? N=254;my(s = qfsolve(matdiagonal([1,1,1,-N]))); 
vector(3,i,abs(s[i]/s[4]))
%12 = [2, 5, 15]
?

(A) Are the entries s[i]/s[4] guaranteed to be integers?
[for n \neq 4^a (8b+7) with a,b positive integers (*)]


? n=254;qfsolve(matdiagonal([1,1,1,-n]))
%14 = [-2, 5, 15, 1]~
?

(B) Can it ever happen that s[4] is not 1 for n as in (*)?


? ?qfsolve
qfsolve(G): solve over Q the quadratic equation X^t G X = 0, where G is 
a
symmetric matrix.

?

(C) Is it guaranteed that the first three entries of

qfsolve(matdiagonal([1,1,1,-n]))

with n as in (*) are always integers?


Regards,

Hermann.