Re: gaussian integer modulus / Pollard's rho method on gaussian integers
[email protected] Sat, 15 Nov 2025 11:17:56 +0100
| Newsgroups | gmane.comp.mathematics.pari.user |
|---|---|
| Message-ID | <[email protected]> |
On 2025-11-14 22:33, Bill Allombert wrote:
>> ...
>> Now I tried to use GP t_COMPLEX instead of a vector of two numbers for
>> gaussian integers. And the code tells so much more how and what is
>> done:
>
> Exercise: write a GP script that write a number as the sum of three
> triangular numbers.
>
> Cheers,
> Bill
>
I learned about Gauss's Eureka theorem ...
https://warwick.ac.uk/fac/sci/maths/people/staff/michaud/thirdyearessay.pdf#page=27
... when implementing tqf.gp for determining sum of 3 squares with help
from this list two years ago:
https://pari.math.u-bordeaux.fr/archives/pari-users-2311/msg00007.html
Working tqf.gp gist is here:
https://gist.github.com/Hermann-SW/f13b8adf7d7e3094f0b6db0bce29a7b8
Solution to exercise:
$ N=42 gp -q <eureka.gp 2>/dev/null
Δ(2)+Δ(8)+Δ(2)
=3+36+3
=42
$ N=1234567891 gp -q <eureka.gp 2>/dev/null
Δ(39136)+Δ(879)+Δ(30605)
=765832816+386760+468348315
=1234567891
$
$ cat eureka.gp
read("tqf.gp");
delta(n)=n*(n+1)/2;
assert(getenv("N")!=0);
n=eval(getenv("N"));
sq3=squares34(8*n+3)\2;
print("Δ(",sq3[1],")+Δ(",sq3[2],")+Δ(",sq3[3],")");
print("=",delta(sq3[1]),"+",delta(sq3[2]),"+",delta(sq3[3]));
print("=",delta(sq3[1])+delta(sq3[2])+delta(sq3[3]));
$
Regards,
Hermann