Charles Greathouse on Wed, 04 Oct 2023 02:57:18 +0200


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

Re: How to generate wolframscript "PowersRepresentations[...]" output in PARI/GP


?? will almost always give the library form. You can also find the function entry in the source:

egrep --include='qfsolve' -R '^C-Name: ' src/functions/

yields

src/functions/linear_algebra/qfsolve:C-Name: qfsolve

On Tue, Oct 3, 2023 at 8:25 PM <hermann@stamm-wilbrandt.de> wrote:
On 2023-10-03 10:45, Bill Allombert wrote:
>>
>> Is qfsolve() only available for GP?
>
> Of course not:
>
> ? ??qfsolve
> qfsolve(G):
> ...
>    The library syntax is GEN qfsolve(GEN G).
>
Thanks Bill, so I have to search for "The library syntax" in either
GP user manual (more than 1000 matches) or "??func" output.

I implemented foursquare.cc gist, nice libpari hands-on:
https://gist.github.com/Hermann-SW/fc96e5b1148c72ce07cfa4e55b6c0cd3

Using C++ does not change the qfsolve runtime, no surprise.

? p=precprime(10^30)
%41 = 999999999999999999999999999989
? q=precprime(p-1)
%42 = 999999999999999999999999999983
? n=p*q
%43 = 999999999999999999999999999972000000000000000000000000000187
? foursquare(n)
%44 = [312403411064839129238661430583, 892113694587116093864238410176,
253468622571348560165608955929, 205647567593108547766440174091]~
? ##
   ***   last result computed in 2,769 ms.
?


libgmpxx+lipbari:

$ f=foursquare
$ g++ $f.cc -lgmp -lgmpxx -O3 -o $f -lpari -DPARI -Wall -Wextra
-pedantic
$ ./$f 999999999999999999999999999989 999999999999999999999999999983
R = qfsolve(M)
2.85703s
223605138439657340220247124809 147944036070869714718268156597
314020169936458430849348767399 910771451642793118995923538064
sum of 4 squares verified for 61-digit number
$


Regards,

Hermann.