![]() |
![]() |
#1 |
Mar 2016
32×47 Posts |
![]()
Let f(n)=an²+bn+c = 0 mod p
with n element of N and p prime. n=? Is there a better way than calculating f(n) for n=0 ...p-1 Thanks if you spend me some lines. |
![]() |
![]() |
![]() |
#2 |
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
276516 Posts |
![]()
Solve it like you were taught in elementary school, only remember that operations are mod p.
Instead of "there is no square root for negative numbers -> there is no solution" you will use "D is not a quadratic character -> there is no solution". |
![]() |
![]() |
![]() |
#3 |
Dec 2012
The Netherlands
32·7·29 Posts |
![]()
Yes, in this subforum already!
https://www.mersenneforum.org/showthread.php?t=22058 |
![]() |
![]() |
![]() |
#4 | |
Jan 2020
22×32 Posts |
![]() Quote:
About efficiently computing square roots modulo a large prime (hundreds of digits or more), there are two good algorithms by Tonelli-Shanks and by Cipolla. Last fiddled with by 0scar on 2021-07-06 at 11:46 |
|
![]() |
![]() |
![]() |
#5 | |
Mar 2016
32·47 Posts |
![]() Quote:
b²-4ac is a quadratic residue, but not always a square. ![]() |
|
![]() |
![]() |
![]() |
#6 | |
Dec 2012
The Netherlands
32×7×29 Posts |
![]() Quote:
"Prime Numbers , a computational perspective" |
|
![]() |
![]() |
![]() |
#7 |
Mar 2016
32·47 Posts |
![]()
Let an²+bn+c = 0 mod p
If I want to calculate the discriminant, can I first calculate a*=a mod p, b*=b mod p and c*=c mod p and then discr=(b*)²-4a*c* ? |
![]() |
![]() |
![]() |
#8 | |
Dec 2012
The Netherlands
32×7×29 Posts |
![]() Quote:
That is what we mean by Propostion 22 here |
|
![]() |
![]() |
![]() |
#9 |
Mar 2016
32×47 Posts |
![]()
@Nick, thanks a lot for your work and help.
an useful implementation in c and gmp of tonelli-shanks algorithm is: http://www.codecodex.com/wiki/Shanks-Tonelli_algorithm Let : 2ax+b≡y(mod4an) I did not understand, how you solve it. gcd (2a,4an)=2a>1 so the inverse does not exist. Dividing by 4a seems to be possible x/2=(y-b)*(4a)⁻¹ mod (n) with a=/=0 multiplying with 2 is x =(y-b)*(2a)⁻¹ mod n Is that ok ? Last fiddled with by bhelmes on 2021-07-09 at 20:36 |
![]() |
![]() |
![]() |
#10 |
Dec 2012
The Netherlands
182710 Posts |
![]()
We have \(2ax+b-y\equiv 0\pmod{4an}\) and \(\gcd(2a,4an)=2a\neq 1\).
If 2a does not divide b-y then there is no solution. If instead b-y=2at for some integer t then \(x\equiv -t\pmod{2n}\). |
![]() |
![]() |