Bill Allombert on Sat, 18 Nov 2023 09:49:33 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: question on finding exhaustive search algorithm for a^2+b^2 = N
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: question on finding exhaustive search algorithm for a^2+b^2 = N
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Sat, 18 Nov 2023 09:49:04 +0100
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1700297346; c=relaxed/relaxed; bh=y+Jh605igHGm4+Ys6zGhtPph850ydwAXfOSdjZCb4LA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=eqnONiM9rA+YHvKmIMnbDkPT0tuO+xiM257tQil3MUnxUVoUQBKYp1smQwlAsO3SeXR2iRJ6frXd7yAjzt2etdYSA5//LQczc4Cm2wAsdxf/Y3YRxqDQbVVYee5obtnOQ/gxsp23gu+5nvxgvCxXwPIkBM7rilDg32cwYqtG6+061XaNdmpZ/iLPtN/xYtosWTYBUviDxktF4hV9C2Tw10moMBu4Qq0B7q/nNmn0WMwa4n6jXPmkbpBNB9uecukNgh+1DUK1FhryQH6O3xSx47okBuNQIZ7c0q1wOWJJzt2fzegg7RL67ERkJNKgSPGXYaPXhrIJeZ7wS6gNC2RMeT4L1G3SdgatAI+eHvFOv7nYm4CYV0tYl4nLKMA+pn/+zi0l8G3DYBJytlywpglJI4PTMJfMbwTAZPdY/1mcstYYNg/8NPPp8MuLXrd8414SrEmXJAMofEohQ4uHyvyogNrFtiD7LkYPp8xLvaaGu0Q8EiM8p0WOLuSoR6JpWlrc1llSSwEyVkwwZ+lJ83hlnHo83jATc+lergWkAvyKFAYECQXgYtbhJE+LkJqI3ll7N46gdD/XckdN78yfiJNdsTeYTYRsfSQBcT4VLWE5PnNu7LV+opeJT8xzO6moMzZ3Cjf3L+yFoI62hBRS2hFm0b+PUFURt2SEsEdanjAiyrs=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1700297346; cv=none; b=comjTQ2p+BPB7SjKG3oCDp8Bh0kTgBJxz+JZM6DiCV04G7GSZPjCQpjiWASSceHR8bjzBqB4cSMwzCiZ+bGl9/zrh0vqsrcqi5zxfEiVr2RmWl4tCv3hQ30LAoaHiyccAqKzC5SQf65nlSwlPKd6Eb38OlWsLdK3awF7lRkC18YkNmoG0myM6TVVfiXQbG38LkzlqWygQpqk8bcsLqu02hWp6WrKUJYCTEP6Jgc2a6V86Yj2NYdhA+uYGsrA+8aRJsl8hWg9ce+6iNV5KaseRYOiisBv8vDshJIBUF/M2ngvdeHhFwtvxG/OXtdXTrYxVy9fpf2zcjBUmUpNLdsdHXrhmLAQBuqKPNKIMFbIkATjaRBvqztcmECDbn4qiKuOUIaJfldDmrNczbwQCBly0ksUSKEnwggkFlK01L1hLMtRIPWa2i8tuWOBP42Z6I/NSK4y3CntAukZHswmJpJ7XRCG+agZj251ciE0Yo4Ye8twzVVX6GU3Trk2GjEhX8ifw0J0Sd4Iu93YJ40KcpsIz1DLCSnbhU20LiYPdsICipV9rbn5+SS4QQ4iYbz1yWPd8wbsxPQtn7Gl9wVyhM8HykPXmymRQ0pYB1ziw2Gcl4L418efmS3yzIbB5T2RqoShKaa2UG2mVdOxWMO13iXN/ST3xm87yvOu0cRPvudG0w8=
- Authentication-results: smail; arc=none
- Delivery-date: Sat, 18 Nov 2023 09:49:33 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1700297346; bh=y+Jh605igHGm4+Ys6zGhtPph850ydwAXfOSdjZCb4LA=; h=Date:From:To:Subject:References:In-Reply-To:From; b=o1Mq/Dr4ifBZgAhMG5RzBCuMvRBirpiKIl1bekWdTQhJn+RzMlLkDuAZdjviBs8yo rpbyGd+wrkapUIWtepPrLm726Jk7Vab0RXWxxEVFUqO20MiyCpIBKZgSZrDYPYcJ0b Ca0PPH/7cAjIfcxzISnroP4MawLyuambDfrCzps2bIJ9dYsal1bmYLZdwne2otagvh 5lybbkvKww52OfPBKKv+yqz9F6J91E5hj3KyNAhSIfazNcsdx/eEbdjWBwK8ZJxynL ViTlGyfw5hm1BXQj5ip9yvLNJN+U3tBazVNGYSFKH/349l7qCYUATvznjSughJ4ohr TJUf7h5xjyYF66Ed+PCmX9bzTvBiZoYD4Mi6bX6bFT92vmmAyTMTEOFtuJvjAlMkAf VH/z92P7AzJwHJv6Md/rFGcKVRBCVOhwcZmpyMR8vxSej1DBhQq34WU28jsZl3wXX6 67Junxq8xYE/jmah4K7Us9otTeHv79PR/zjIJgrWxny+oLamn5s2l+YYSJgVN/gLYs Oqesd5Oc0Nx8iFeQ0y+PpnizAJwLYM8GKaLtrMwR5eJVri9FfYTls+XkROEsJtL86H z9jXQeK+GzB4qZxZipmOtHO/BejXU8zYaEZPW+Wd5j71HTftbdHihUtpFy6ZXLrHKS aVrIJcgqiGO57wNGmOk674bg=
- In-reply-to: <c7cf4c64-6785-4a19-82f3-cd68c0ee4d52@gmail.com>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <c7cf4c64-6785-4a19-82f3-cd68c0ee4d52@gmail.com>
On Fri, Nov 17, 2023 at 05:11:55PM -0800, American Citizen wrote:
> Thank you all for being patient with me.
>
> I wrote an algorithm to find two squares summing to N
>
> sol2(N) = Set(abs(vecsort(qfbsolve(Qfb(1,0,1),N,3),,4)))
This is not quite right. For each solution [a,b], qfbsolve returns one
of [a,b], [-b,a], [-a,-b], [b,-a] and also one of
[b,a], [-a,b], [-b,-a], [a,-b]
so taking the absolute value you get one of
[a,b], [b,a] and one of [b,a], [a,b]
so you will get twice the same solution half of the time.
> Carefully writing a program which exhaustively searches comes up with the
> following 32 solutions:
>
> [[64, 1087], [103, 1084], [167, 1076], [191, 1072], [236, 1063], [281,
> 1052], [292, 1049], [359, 1028], [449, 992], [512, 961], [568, 929], [601,
> 908], [607, 904], [664, 863], [673, 856], [743, 796], [796, 743], [856,
> 673], [863, 664], [904, 607], [908, 601], [929, 568], [961, 512], [992,
> 449], [1028, 359], [1049, 292], [1052, 281], [1063, 236], [1072, 191],
> [1076, 167], [1084, 103], [1087, 64]]
Your list includes both [64, 1087] and [1087, 64].
If you want both [a,b] and [b,a] do that
sol2(N) = Set(concat([[x,Vecrev(x)]| x <- abs(qfbsolve(Qfb(1,0,1),N,3))]))
if you want only [a,b] with a<=b, do
sol2(N) = Set([vecsort(x)| x <- abs(qfbsolve(Qfb(1,0,1),N,3))])
? sol2(5*13*17*29*37)
%56 = [[64,1087],[103,1084],[167,1076],[191,1072],[236,1063],[281,1052],[292,1049],[359,1028],[449,992],[512,961],[568,929],[601,908],[607,904],[664,863],[673,856],[743,796]]
? #%
%57 = 16
Cheers,
Bill