Dixon’s Algorithm for Finding Perfect Squares

in

It works by identifying sets of relations that multiply to give a perfect square on the right-hand side. The basic idea behind this algorithm is to choose random numbers between 1 and N (where N is your target number) and compute their squares modulo N. If these values are S-smooth, meaning all prime factors are less than some smoothness bound S, then we can use them in our calculations.

Let’s take an example to illustrate this algorithm: Suppose you want to find the perfect square root of 1024 (N=1024). First, choose a random number between 1 and N, say x = 375. Compute its square modulo N using the formula:

(x^2) % N

where % is the modulus operator. In this case, we get:

(375^2) % 1024 = 69

Now, let’s check if this value is S-smooth or not. For simplicity, let’s assume that S=3 (i.e., all prime factors are less than or equal to 3). The prime factorization of 69 is:

69 = 3 * 23

Since both 3 and 23 are less than or equal to 3, we can say that this value is S-smooth. Record the pair (x, x^2 % N) for later use. Repeat this process until you have r relations, where r is a number like 10k or something equally impressive.

Once you have your set of relations, it’s time to find the perfect square using linear algebra. This involves finding a subset of relations that multiply to give a perfect square on the right-hand side. To do this, create an exponent matrix and find a nonzero vector that satisfies Aˉy=ˉ0 modulo 2 (where A is your exponent matrix).

Let’s take another example: Suppose you have the following set of relations:

(x1, x1^2 % N) = (375, 69)
(x2, x2^2 % N) = (480, 230400)
(x3, x3^2 % N) = (512, 262144)

To create the exponent matrix A, we need to find the exponents of each relation that multiply to give a perfect square on the right-hand side. In this case:

(x1 * x3)^2 % N = (512 * 375^2) % 1024 = 69 * 262144 % 1024 = 0

So, the exponent matrix A is:

| | x1 | x2 | x3 |
|—|—|—|
| x1 | 2 | 0 | 5 |
| x2 | 0 | 9 | 0 |
| x3 | 5 | 0 | 2 |

To find a nonzero vector y that satisfies Aˉy=ˉ0 modulo 2, we can use linear algebra techniques. In this case:

A * (-y) = -(A * y) % N = 0 (modulo 2)

where y is the column vector of unknowns and % is the modulus operator. Solving for y gives us:

(-y) = A^-1 * (0) (modulo 2)

Since we’re working with a modular arithmetic, we can use the Chinese remainder theorem to solve this system of equations. In this case, we get:

-y = [(x3^4 % N), (-x1*x3^3 % N), (0)] (modulo 2)

where x3^4 and -x1*x3^3 are the solutions to the congruences modulo N. To find a perfect square, we can use this vector y to calculate:

(x1 * x3)^2 % N = (-y[0] * (x1 * x3)) ^ 2 % N = ((-y[0])^2 * (x1 * x3)^2) % N

In our example, we get:

((-y[0])^2 * (375 * 512)) % 1024 = (-1)^2 * (69 * 262144) % 1024 = 0

So the perfect square root of N is:

sqrt(N) = sqrt((-y[0])^2 * (x1 * x3)) % N = (-y[0] * (x1 * x3)) % N

In our example, we get:

sqrt(1024) = (-1 * 69 * 262144) % 1024 = 857

Note that this algorithm is not perfect and may require a large number of relations to find the correct answer. However, it’s much more efficient than brute force methods for finding perfect square roots.

SICORPS