使用pari进行平方和计算

作者寻求使用PARI/GP的内置函数实现类似`PowersRepresentations`的功能,计算给定数如17*29作为4个非负整数的第p次幂之和。提到了一个自定义函数`foursquare`作为示例。
摘要由CSDN通过智能技术生成

参考链接:https://pari.math.u-bordeaux.fr/archives/pari-users-2310/msg00004.html

Re: How to generate wolframscript “PowersRepresentations[…]” output in PARI/GP

On Mon, Oct 02, 2023 at 08:38:54PM +0200, hermann@stamm-wilbrandt.de wrote:

https://reference.wolfram.com/language/ref/PowersRepresentations.html
“PowersRepresentations[n,k,p]
gives the distinct representations of the integer n as
a sum of k non-negative p^(th) integer powers.”

I searched for all hits for “powers” and “representations” in GP user
manual and found nothing. How to compute sum of 4 squares of here
17*29 semiprime with PARI/GP by using any builtin function?

If you want only one solution, you can do

foursquare(n) = abs(qfsolve(matdiagonal([1,1,1,1,-n]))[1..4]);

? foursquare(17*29)
%15 = [0,0,13,18]~

? foursquare(2^127-1)
%13 = [3485713606461563310,6176908041673972933,4510469025815889567,9974590734764851407]~

Cheers,
Bill

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值