ArticleslgStudy

computer science

Williams's p + 1 algorithm

Williams's p + 1 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 Williams's p + 1 algorithm rather than just read about it. In short: In computational number theory, Williams's p + 1 algorithm is an integer factorization algorithm, one of the family of algebraic-group factorisation algorithms. It was invented by Hugh C.

Key takeaways

  • Williams's p + 1 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 Williams's p + 1 algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Williams's p + 1 algorithm from memory before moving on to harder problems.

Reference excerpt

In computational number theory, Williams's p + 1 algorithm is an integer factorization algorithm, one of the family of algebraic-group factorisation algorithms. It was invented by Hugh C. Williams in 1982. It works well if the number N to be factored contains one or more prime factors p such that p + 1 is smooth, i.e. p + 1 contains only small factors. It uses Lucas sequences to perform exponentiation in a quadratic field. It is analogous to Pollard's p − 1 algorithm. In fact, it is also able to find p if p − 1 is smooth, in which case it degenerates into a slow version of Pollard's algorithm.

Algorithm Choose some integer A greater than 2 which characterizes the Lucas sequence:

V0=2,V1=A,Vj=AVj−1−Vj−2 where all operations are performed modulo N. Then any odd prime p divides gcd⁡(N,VM−2) whenever M is a multiple of p−(D/p), where D=A2−4 and (D/p) is the Jacobi symbol. For different values of M we calculate gcd⁡(N,VM−2), and when the result is not equal to 1 or to N, we have found a non-trivial factor of N. To find a p with a smooth p + 1 we require that (D/p)=−1, that is, D should be a quadratic non-residue modulo p. But as we don't know p beforehand, trying more than one value of A may be required before finding a solution. If (D/p)=+1, this algorithm degenerates into a slow version of Pollard's p − 1 algorithm. This happens 50% of the time.

Calculation of Lucas terms The values of M used are successive factorials, and VM is the M-th value of the sequence characterized by VM−1. To find the M-th element V of the sequence characterized by B, we proceed in a manner similar to left-to-right exponentiation:

x := B y := (B ^ 2 − 2) mod N for each bit of M to the right of the most significant bit do if the bit is 1 then x := (x × y − B) mod N y := (y ^ 2 − 2) mod N else y := (x × y − B) mod N x := (x ^ 2 − 2) mod N V := x

Continuation There is a "second stage" extension to William's p+1 algorithm much like there is for p-1 and Lenstra ECM. After the steps above (which is now called a "stage 1"), a continuation allows one to find p+1 with a relaxed condition: instead of requiring that p + 1 has all its factors less than B, we require it to have all but one of its factors less than some B1 (same as the regular B), and the remaining factor less than some B2 ≫ B1.

Example With N=112729 and A=5, successive values of VM are:

V1 of seq(5) = V1! of seq(5) = 5 V2 of seq(5) = V2! of seq(5) = 23 V3 of seq(23) = V3! of seq(5) = 12098 V4 of seq(12098) = V4! of seq(5) = 87680 V5 of seq(87680) = V5! of seq(5) = 53242 V6 of seq(53242) = V6! of seq(5) = 27666 V7 of seq(27666) = V7! of seq(5) = 110229. At this point, gcd(110229-2,112729) = 139, so 139 is a non-trivial factor of 112729. Notice that p+1 = 140 = 22 × 5 × 7. The number 7! is the lowest factorial which is multiple of 140, so the proper factor 139 is found in this step. Using another initial value, say A = 9, we get:

V1 of seq(9) = V1! of seq(9) = 9 V2 of seq(9) = V2! of seq(9) = 79 V3 of seq(79) = V3! of seq(9) = 41886 V4 of seq(41886) = V4! of seq(9) = 79378 V5 of seq(79378) = V5! of seq(9) = 1934 V6 of seq(1934) = V6! of seq(9) = 10582 V7 of seq(10582) = V7! of seq(9) = 84241 V8 of seq(84241) = V8! of seq(9) = 93973 V9 of seq(93973) = V9! of seq(9) = 91645. At this point gcd(91645-2,112729) = 811, so 811 is a non-trivial factor of 112729. Notice that p−1 = 810 = 2 × 5 × 34. The number 9! is the lowest factorial which is multiple of 810, so the proper factor 811 is found in this step. The factor 139 is not found this time because p−1 = 138 = 2 × 3 × 23 which is not a divisor of 9! As can be seen in these examples we do not know in advance whether the prime that will be found has a smooth p+1 or p−1.

Generalization Based on Pollard's p − 1 and Williams's p+1 factoring algorithms, Eric Bach and Jeffrey Shallit developed techniques to factor n efficiently provided that it has a prime factor p such that any kth cyclotomic polynomial Φk(p) is smooth. The first few cyclotomic polynomials are given by the sequence Φ1(p) = p−1, Φ2(p) = p+1, Φ3(p) = p2+p+1, and Φ4(p) = p2+1.

References

Williams, H. C. (1982), "A p+1 method of factoring", Mathematics of Computation, 39 (159): 225–234, doi:10.2307/2007633, JSTOR 2007633, MR 0658227

External links P + 1 factorization method at Prime Wiki

Worked examples

Example 1 — a first encounter with Williams's p + 1 algorithm

Start with the simplest possible case. Write down what Williams's p + 1 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 Williams's p + 1 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 Williams's p + 1 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 Williams's p + 1 algorithm

In research
Williams's p + 1 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 Williams's p + 1 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
Williams's p + 1 algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Integer factorization algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Williams's p + 1 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 “Williams's p + 1 algorithm” →

How to study Williams's p + 1 algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Williams's p + 1 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 Williams's p + 1 algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Williams's p + 1 algorithm in simple terms?

In computational number theory, Williams's p + 1 algorithm is an integer factorization algorithm, one of the family of algebraic-group factorisation algorithms. It was invented by Hugh C.

Why does Williams's p + 1 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 Williams's p + 1 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 Williams's p + 1 algorithm.

Tags

  • Integer factorization algorithms

Keep exploring