Bill Allombert on Fri, 06 Oct 2023 10:17:41 +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 10:17:33 +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=1696580245; c=relaxed/relaxed; bh=FVeFUn12h5lOqol4DiOn02lq6RPo+b1MfKApKh7k0+8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=rxu8zarRw/zvYwaP5VhNxKBESCgmNf4qTlfuaxT9zRLp42IhtIxsb8jdU8xwzwolXvGUnC9TNPF254mtwTSrXF9RmapANkLWeuwsKCifsmITNLkXCa3pqxQjI1l2zacXMWNxzNf72NsX5kqo8Z2ww4F5hk1LBLcBwPl3S8KJ2CbWz3fR5X3CsCnPymNSLt9BgWRD+yxXHBW8jbEIwR8yIgTtaCL2dukBtEMrM0adUo1R5+aoV9JNWxJ95fl+YZJMxlIaY58aoN+jdAgv1OultWGt3U0dyL6jXrXAwNixY5yE8t6nVKQImUVQaWkW8P//clad+GQR8w7pOy+UktigqV5SWvGYwkr/a5q1ssz6CSh4M4VtHUHOiniq0Q3NhBZQYM0RiQWHUCVadkD2Lo2wkmR10e0wJGUelev6rT5Y939Zt6AZT4tD8A/MTqNLqTs53sF2eeaqtc5fL/6F4BnRmpibrLPCZBXw46+bgRVqX2sdU3B28mTwf6a5ufJdeFqkscA+IbISpzlADZ1+kGTEaMX/IlcO5Ucof4RWL6wAj3mliRr2xPyN61Zsi4oxLkgrcfZvRMEJv961ZI9850pWyti0hJumZ3Iju7kaXTugVK/TxNHpRUhF+KEKMEZKY3eoSa2QP3gOQKqYkfECqFdBZhdKdyrKHffyqHpEfUB1xEQ=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1696580245; cv=none; b=AajE62gPsHe6d1A8DPdiiJIXkpuW4H8fSyliXKMbtzVKqB0ohutUZfqfrb0UpMhJFmS18sDkk0oC+DU0rIlwH6CXqsIH34S96pBaRGwhIYk9E8CTvMhCv/WaZ+xSqPwQrDjkZI7v2aTW4RSBFlDuL/JXudXxGjIJOg0qryJZvdhgIEOQEQGHOhAoCIHza/HMTA+q+aLVLLJFou8WwfPYAJdqYKK/nief/nkq2MmajRaNtpctiQrLMlK4Sj9peOrifIJKR1rODEfPRdp/17uPQZ+DHMeLDJed4/ncYSW4qhSBvCc+mcV4G/tCdEn9cbFnlJbbn4A17+JVTxB/y4UPLTEwnSRoJZR3vWlQSizO8/gzzYWw2xGgf/iQHLlYHY8r7oPpjqMbGzNcupQY8yxrMsYjtoKtCe2Ao1lqetCQFi8lOZFJRtTKZbx57UdNB1hIowLrb22jubjIztQ2JRhqq5lwBRIS8jZ2M3M+BqnffV5ka8QcDUUjJWf3vgDCoWMh1Drg3L5U+sH4SMxilEl6Y7bxTyqnda8zEvDLVinIEF2kDobC3EuP3fkfXlLAD4/+/S9QHfzAWJq2XZFRRcn99X6J6sNFOX9HfiOpvAw7qHwdtoK/BeZ+obLUiPuO8mOnA5RBkLjWPfyL6hPMkDFKxhXesvFBPwe9hA31bwsmyOs=
- Authentication-results: smail; arc=none
- Delivery-date: Fri, 06 Oct 2023 10:17:41 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1696580245; bh=FVeFUn12h5lOqol4DiOn02lq6RPo+b1MfKApKh7k0+8=; h=Date:From:To:Subject:References:In-Reply-To:From; b=R7BAjmbatEhj/BnXm3x9OyJ6+HX/+N9Xc4V1akv0J7LcbXlpyihaWkfI8QEEYLrpQ Npho9reJoKSQMMmtJrMB1EEsO7nUIv7NG0I2f0k8qOu8UKhB9RmM6iK6PeJvU4TE0O V8Uvmv56+xUpaWrBE00UC4GbzfX8pFJ+yVEF7z+Flj9y1nvDRZGiZqYM05ovKjVZfq WENYbxg4j9heD3KZMcxTnWZtYKfQz5t4hLttGm5zUaOMJnAjshi4EVROZyBxPA1uuQ lWvAyF6qHZZkkJY0EPU4IgPiXs+A6/QoUgXmjeYEY8huAmjsZC6db0wKhLPn3lG6XE f21i4w0JwyJ1x2cFc1FElWp9LjVuQfTJRgIcr/9yl3lQCOxzhd6xyrL4jgGHqNzyTq Sq0l+5kPTJn29zUOkzl+iyS4ayD6fYAcMKqpFaG2O75T8hVNZ6Z92zZnukZ+v8K/Gx 71Ir+JpdIohd/jT/8Z/z7ORsFH9ZjN5h8uo0P0rpTEx1A80mS1pOArPnFpSHl3HIoE kr/6KtM+zOw21wlBw9KKH2eVOuVsDA8zEQIkzUj+EAR1kp8E/pURhZhOg/mnweX4yb Mrw0Gchh1VvPDQHm+ld7onhA1kiuTVLtIsYccbdgx+/XNU2uwTOLyY8TdFbLQG/aTX aDMA4VOZq0sTxbZjiR8WkSvE=
- In-reply-to: <d1c78430066dfb66eb8919b4cde59d9c@stamm-wilbrandt.de>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <d1c78430066dfb66eb8919b4cde59d9c@stamm-wilbrandt.de>
On Fri, Oct 06, 2023 at 01:06:31AM +0200, hermann@stamm-wilbrandt.de wrote:
> In this posting Bill provided function "foursquare(n)":
> https://pari.math.u-bordeaux.fr/archives/pari-users-2310/msg00004.html
>
> foursquare(n) = abs(qfsolve(matdiagonal([1,1,1,1,-n]))[1..4]);
>
> It has interesting property wrt odd semiprimes being product of two primes
> =1 (mod 4):
All these numbers are sum of two squares.
> I asked for foursquare() for applying to unfactored RSA-numbers =1 (mod 4) >
> RSA-250.
> Unfortunately that is not possible, since qfsolve() does first factor the
> determinant
> of passed matrix, which is -n. Find details in P.S: of this posting:
> https://www.mersenneforum.org/showthread.php?t=28910
>
> Same posting is on Lagrange's three square theorem.
> I describe there how I found original 1798 french text online on internet
> archive.
>
> I am not sure how to make foursquare(n) efficient (faster than factoring n).
> Perhaps the prove of theorem "Odd integer not being 8n+7 is sum of 3
> squares"
> on page 398 will help to get efficient threesquare1m4(n).
You could use
threesquare(n) = abs(qfsolve(matdiagonal([1,1,1,-n]))[1..3]);
but it is not faster.
But you can try this one:
foursquarep(n)=
{
for(i=1,sqrtint(n),
if(ispseudoprime(n-i^2),return(concat(i,threesquare(P-i^2)))))
}
or even
foursquaref(n)=
{
for(i=1,sqrtint(n),
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))))));
}
Cheers,
Bill.