Pocklington's algorithm is a technique for solving a congruence of the form
x2\equiva\pmodp,
where x and a are integers and a is a quadratic residue.
The algorithm is one of the first efficient methods to solve such a congruence. It was described by H.C. Pocklington in 1917.[1]
(Note: all
\equiv
\pmodp
Inputs:
\pmodp
Outputs:
x2\equiva
x ≠ -x
Pocklington separates 3 different cases for p:
The first case, if
p=4m+3
m\inN
x\equiv\pmam+1
The second case, if
p=8m+5
m\inN
a2m+1\equiv1
x\equiv\pmam+1
a2m+1\equiv-1
42m+1\equiv-1
(4a)2m+1\equiv1
y\equiv\pm(4a)m+1
y2\equiv4a
x\equiv\pmy/2
x\equiv\pm(p+y)/2
The third case, if
p=8m+1
D\equiv-a
x2+D\equiv0
t1
u1
N=
2 | |
t | |
1 |
-D
2 | |
u | |
1 |
tn=
(t1+u1\sqrt{D | |
) |
n+(t1-u1\sqrt{D})n}{2}, un=
(t1+u1\sqrt{D | |
) |
n-(t1-u1\sqrt{D})n}{2\sqrt{D}}
tm+n=tmtn+Dumun, um+n=tmun+tnum and
2 | |
t | |
n |
-D
2 | |
u | |
n |
=Nn
4m+1
8m+1
tp\equiv
p | |
t | |
1 |
\equivt1, up\equiv
p | |
u | |
1 |
D(p-1)/2\equivu1
t1\equivtp-1t1+Dup-1u1 and u1\equivtp-1u1+t1up-1
tp-1\equiv1, up-1\equiv0
Let
p-1=2r
0\equivup-1\equiv2trur
tr
ur
ur
r=2s
0\equiv2tsus
ui
u1
um\equiv0
2 | |
t | |
m |
-D
2 | |
u | |
m |
\equivNm
2 | |
t | |
m |
tl\equiv0
-D
2 | |
u | |
l |
\equivNl
-D
l=2k
0\equivtl\equiv
2 | |
t | |
k |
+D
2 | |
u | |
k |
x2+D\equiv0
ukx\equiv\pmtk
The following are 4 examples, corresponding to the 3 different cases in which Pocklington divided forms of p. All
\equiv
x2\equiv43\pmod{47}.
This is the first case, according to the algorithm,
x\equiv43(47+1)/2=4312\equiv2
x2=22=4
Solve the congruence
x2\equiv18\pmod{23}.
23=4 ⋅ 5+3
m=5
x\equiv\pm186\equiv\pm8\pmod{23}
(\pm8)2\equiv64\equiv18\pmod{23}
Solve the congruence
x2\equiv10\pmod{13}.
13=8 ⋅ 1+5
m=1
102m+1\equiv103\equiv-1\pmod{13}
x\equiv\pmy/2\equiv\pm(4a)2/2\equiv\pm800\equiv\pm7\pmod{13}
(\pm7)2\equiv49\equiv10\pmod{13}
Solve the congruence
x2\equiv13\pmod{17}
x2-13=0
t1
u1
2 | |
t | |
1 |
+
2 | |
13u | |
1 |
t1=3,u1=1
t8
u8
t2=t1t1+13u1u1=9-13=-4\equiv13\pmod{17},
u2=t1u1+t1u1=3+3\equiv6\pmod{17}.
t4=-299\equiv7\pmod{17},u4=156\equiv3\pmod{17}
t8=-68\equiv0\pmod{17},u8=42\equiv8\pmod{17}.
Since
t8=0
0\equiv
2 | |
t | |
4 |
+
2 | |
13u | |
4 |
\equiv72-13 ⋅ 32\pmod{17}
3x\equiv\pm7\pmod{17}
x\equiv\pm8\pmod{17}
(\pm8)2=64\equiv13\pmod{17}