Bill Allombert on Fri, 06 Oct 2023 19:54:50 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: efficient foursquare() and/or threesquare1m4() functions
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: efficient foursquare() and/or threesquare1m4() functions
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Fri, 6 Oct 2023 19:54:46 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1696614878; c=relaxed/relaxed; bh=fHr1vzE1Yz/8dO4J14fD3E89WYplOc+84t2HJZ6b7vc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=q7agtPvOYq2xIFxnHXRWu3CB3Hd2JjgtAUhITQMZicr/iqYEGuJdas8Mbi+moUqVPfHFkVRtrb7COfJmKEf4S2cnh75JlNqs1e6x/qlAzUDjQPfpYaSX5Foi7b/tiSEgUPZ3ZZq8e8R5bITwH8Q/WK5rfGQ22PUojLCaWYXOS8frqfFUHKblfjyxawF+gO1NGMRbLBPoWstbh2cF1h0k1jYGdV7iwQ4zBJ9NWi8OUmwMc8IDpRo1eIl0IljbP6mh3ebeW2/D2UDJ3/KiKLWbGX9d4iJ564BM+uSQOSdaySymQ/ZRbrrQGVKzAj9ZqycilLlvLUPRQi2G/uxDZdyWYQURdCvBmfONS7pf1UfFA+jyPB2T5YBOcux897cWz2g5sEvoQ18alGs4sxwjrNVB9YwBIHjckDVbzlkgrVG3iCvea/6VafxTTPeuNswbxXoIJHEEDi3vT+R79zHaz9yhnHd5S+CERqKHWsO+1p2nudAtOszOm6dLfPz9FjxTXk3tbujHjBxQW7VQo+x4pgUMmNzB9KqH9PdPDWQ9s1cFuwDwLe8rFWGd6pcSKnEc6jevuvd+RPcvOpad9tCu5ZwpIU44KS0+jiAfLYSFu8BjIH2hip0ONr23Hn4U/NhpHlKQjiibAxj4nIOoNhMDmR3gyk4cq8qmyxgDPSZ3JE+xkPw=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1696614878; cv=none; b=qyOWDISFu6SWqtnXtaB2iCrSfpedis55y9v3A+3Q9q/8sAwUO5Tci5X1EZDpXBdRzcodHr1f1JyDxsn746UQ8GsycSdi8JpsGK/5C8LrcZ5xuGkMlKrGvbO8RZ06ZAIOpRHqZSdtIzCdWYMqiEKRxkxUuUICJFRftUFC5L6n6kVXAW8Tx2dMfin8YylRYeVEWIjjZ9nyzKDDQXrFcM2rpxik4nKY7uphRFJNtzJ0ZNmO1FzgWiKxEXkz6nFdLwtNlKljpsYdPFnOflnNGWfnmUSHSlSplMWE+h/+qMFSCkGpD+UNl8ilEsE8U+4hNKxODZOazvGqy6CplGRYhXgFfPVgsLHQx10MU6zH0jXfxeMmJLrOOJvQRNb45xxqX51Um4T86/nXuJxTbLfILEkUEG/5GGOqBcYXIhm+Q5/btUwvKaBA0pZX5zIAWFULaGY3Db/VtoC2o7wDeYbVKkVLd0vgMrCj1ckRFxq2lXDmKirFWNehFNojsMtUS6erKfbv4CsO8aJ/ciAfFt5RTNIZUnq5Zhl7+85lAwv8Kw6R6OwirCDAL842ouL5WK5Zo00sH79juaO3EaNQbpklrLYPPYLFamfdAneENyKtL1yc1dmgMSc5ocnFc14oEh/+4eSk0ZjpyM2Z8+40w+pSBeaTzhC09kTZx8OyYqdWk8t68yo=
- Authentication-results: smail; arc=none
- Delivery-date: Fri, 06 Oct 2023 19:54:50 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1696614878; bh=fHr1vzE1Yz/8dO4J14fD3E89WYplOc+84t2HJZ6b7vc=; h=Date:From:To:Subject:References:In-Reply-To:From; b=boOO+zdXGbqbtw8mOJ5msKFY2aVfv+7kh/0DuT45qOx69e+VUBVFv5vMvuTrijGGV g+iLUBYt+WxtHdB6qdnfZrqBOA2zZ2mJP3Nc+WwPs6fVgDHmkP+JV1DPvGoMuNIOZr 819EP8/XNxxQbPuqo3PK7fiYkxYGKk9dSItz+3L5HgYilODU4SWOt8pEEDlyvZjt0w yHYakn6kgXGeV+V4rhlLFAFutZZSXDDKAQutEO04wK3IE796sqMW0/qZgvz+V+fbik eYC6Fy/xFdCyh8gUJNtxvpaG5bMuexaxX9ylc8+3pVLfeaUO6XC10bYsy7QcW794bF iaaZyjSKauO49bk9dncg4A2H5blUDINt7VqFEReQRhHuhnG1NrZsPjA3xSl3if6XhC myrhywkmMS9F0CUuafndqkKsxgyfM+NSCJY9w7q6NO6+yCF1H8I5Bu/ivjxZx+AlbA CjZf1VZLpK+lEkoW+OHIGuOMRUD3ICQEh42XvXimZvaLSmWt+8rYMzn112v7gXL5Do tPWHjaKzHTlZriHPgg9dY0IUPUyjeFcMmkXz6M05aJyHSZtHpoOoEQ4kXoFDut3sZZ QmzGmQ4f1Hq2AnHqSGLOGUlyTMB036SKUgp5cmODEzhLywpBRusDhqlF60q/KHySsi eXFy6V/lR9t5Pu78te28F/5I=
- In-reply-to: <fd1141975cb1f0b4b488689089c0f980@stamm-wilbrandt.de>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <d1c78430066dfb66eb8919b4cde59d9c@stamm-wilbrandt.de> <ZR/CnVFCjw69Ukyc@seventeen> <ZR/HnWWiyARDRhLM@seventeen> <ZSAT28CAqWZ+90qF@seventeen> <fd1141975cb1f0b4b488689089c0f980@stamm-wilbrandt.de>
On Fri, Oct 06, 2023 at 06:41:49PM +0200, hermann@stamm-wilbrandt.de wrote:
> > ... but suboptimal, we should start by the largest i, so that P is as
> > small as possible!
> >
> > foursquaref(n)=
> > {
> > forstep(i=sqrtint(n),1,-1,
> > my(P=n-i^2, v = valuation(P,2)\2);
> > if (P/4^v%8!=7,
> > my(F=factor(P,2^20)[,1]);
> > if(ispseudoprime(F[#F]),
> > return(concat(i,threesquare(P))))));
> > }
> >
> I tried that, for some values >100x faster than the other.
> But still not good for really large numbers.
>
> All but first Mersenne prime are =7 (mod 8), so needing 4 squares.
> I tried some Mersenne primes 2^p-1 on fast AMD 7600X CPU:
>
> p time [min]
> 11213 0:02
> 21701 1:12
> 44497 2:08
> 86243 stooped after 46:00
If your number is prime, you do not need to use foursquaref, you can use foursquare
since you know the factorization!
? foursquare(2^86243-1);
##
*** last result computed in 2min, 30,519 ms.
(the only bug is that qfsolve should allow the user to provide the factorization of the
discriminant, this would save 40s).
Cheers,
Bill