ArticleslgStudy

computer science

Pocklington's algorithm

Pocklington's algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Pocklington's algorithm rather than just read about it. In short: Pocklington's algorithm is a technique for solving a congruence of the form x2≡a(modp), 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.

Key takeaways

  • Pocklington's algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Pocklington's algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Pocklington's algorithm from memory before moving on to harder problems.

Reference excerpt

Pocklington's algorithm is a technique for solving a congruence of the form

x2≡a(modp), 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.

The algorithm (Note: all ≡ are taken to mean (modp), unless indicated otherwise.) Inputs:

p, an odd prime a, an integer which is a quadratic residue (modp). Outputs:

x, an integer satisfying x2≡a. Note that if x is a solution, −x is a solution as well and since p is odd, x≠−x. So there is always a second solution when one is found.

Solution method Pocklington separates 3 different cases for p: The first case, if p=4m+3, with m∈ℕ, the solution is x≡±am+1. The second case, if p=8m+5, with m∈ℕ and

a2m+1≡1, the solution is x≡±am+1. a2m+1≡−1, 2 is a (quadratic) non-residue so 42m+1≡−1. This means that (4a)2m+1≡1 so y≡±(4a)m+1 is a solution of y2≡4a. Hence x≡±y/2 or, if y is odd, x≡±(p+y)/2. The third case, if p=8m+1, put D≡−a, so the equation to solve becomes x2+D≡0. Now find by trial and error t1 and u1 so that N=t12−Du12 is a quadratic non-residue. Furthermore, let

tn=(t1+u1D)n+(t1−u1D)n2,un=(t1+u1D)n−(t1−u1D)n2D. The following equalities now hold:

tm+n=tmtn+Dumun,um+n=tmun+tnumandtn2−Dun2=Nn. Supposing that p is of the form 4m+1 (which is true if p is of the form 8m+1), D is a quadratic residue and tp≡t1p≡t1,up≡u1pD(p−1)/2≡u1. Now the equations

t1≡tp−1t1+Dup−1u1andu1≡tp−1u1+t1up−1 give a solution tp−1≡1,up−1≡0. Let p−1=2r. Then 0≡up−1≡2trur. This means that either tr or ur is divisible by p. If it is ur, put r=2s and proceed similarly with 0≡2tsus. Not every ui is divisible by p, for u1 is not. The case um≡0 with m odd is impossible, because tm2−Dum2≡Nm holds and this would mean that tm2 is congruent to a quadratic non-residue, which is a contradiction. So this loop stops when tl≡0 for a particular l. This gives −Dul2≡Nl, and because −D is a quadratic residue, l must be even. Put l=2k. Then 0≡tl≡tk2+Duk2. So the solution of x2+D≡0 is got by solving the linear congruence ukx≡±tk.

Examples The following are 4 examples, corresponding to the 3 different cases in which Pocklington divided forms of p. All ≡ are taken with the modulus in the example.

Example 0 x2≡43(mod47). This is the first case, according to the algorithm, x≡43(47+1)/2=4312≡2, but then x2=22=4 not 43, so we should not apply the algorithm at all. The reason why the algorithm is not applicable is that a=43 is a quadratic non residue for p=47.

Example 1 Solve the congruence

x2≡18(mod23). The modulus is 23. This is 23=4⋅5+3, so m=5. The solution should be x≡±186≡±8(mod23), which is indeed true: (±8)2≡64≡18(mod23).

Example 2 Solve the congruence

x2≡10(mod13). The modulus is 13. This is 13=8⋅1+5, so m=1. Now verifying 102m+1≡103≡−1(mod13). So the solution is x≡±y/2≡±(4a)2/2≡±800≡±7(mod13). This is indeed true: (±7)2≡49≡10(mod13).

Example 3 Solve the congruence x2≡13(mod17). For this, write x2−13=0. First find a t1 and u1 such that t12+13u12 is a quadratic nonresidue. Take for example t1=3,u1=1. Now find t8, u8 by computing

t2=t1t1+13u1u1=9−13=−4≡13(mod17), u2=t1u1+t1u1=3+3≡6(mod17). And similarly t4=−299≡7(mod17),u4=156≡3(mod17) such that t8=−68≡0(mod17),u8=42≡8(mod17). Since t8=0, the equation 0≡t42+13u42≡72−13⋅32(mod17) which leads to solving the equation 3x≡±7(mod17). This has solution x≡±8(mod17). Indeed, (±8)2=64≡13(mod17).

References Leonard Eugene Dickson, "History Of The Theory Of Numbers" vol 1 p 222, Chelsea Publishing 1952

Worked examples

Example 1 — a first encounter with Pocklington's algorithm

Start with the simplest possible case. Write down what Pocklington's algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Pocklington's algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Pocklington's algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Pocklington's algorithm

In research
Pocklington's algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Pocklington's algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Pocklington's algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Modular arithmetic, Number theoretic algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Pocklington's algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Pocklington's algorithm” →

How to study Pocklington's algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Pocklington's algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Pocklington's algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Pocklington's algorithm in simple terms?

Pocklington's algorithm is a technique for solving a congruence of the form x2≡a(modp), 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.

Why does Pocklington's algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Pocklington's algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Pocklington's algorithm.

Tags

  • Modular arithmetic
  • Number theoretic algorithms

Keep exploring