Solving Prime Algorithm Unit Circle on Zp - Complexity?

  • Thread starter khotsofalang
  • Start date
  • Tags
    Prime
In summary: But if you want all the residues, why go through that much trouble? Just square all the values....There might be an algorithm to do that, but I'm not sure. It would probably be O(p^2).
  • #1
khotsofalang
21
0
Let x1 + x2 =1 be a unit circle upon a finite field Zp where p is prime. Is there any algorithm which can give all the possible solutions (x1,x2) an element of Zp*Zp as well as the total number of such solutions? If exists, what is the complexity of it?
 
Last edited:
Physics news on Phys.org
  • #2
I take the problem as: find the solutions (a, b) of
[tex]a^2+b^2\equiv1\pmod p[/tex], p prime.

Looping through all possible a and b would take time O(p^2 M(log p)) and very little space.

Enumerating the squares mod p and combining would take time something like O(p) and space O(p log p).

I can't think of any clever ways to do this.
 
  • #3
If p > 2, then clearly you must have that p is odd and you can therefore deduce that a^2 + b^2 is even (it is 1 mod p, after all) so you don't have to consider (a, b) where a and b have opposite parity. This is 50% of the candidate solutions.

Also, clearly the order of a and b don't matter... you're looking for two-sets of numbers (possibly 1-sets, but you can just use two-bags instead and no problem). This is 50% of the original number of ordered pairs and 25% of the remaining candidates.

All of this doesn't lower the complexity any, but it's better than a "dumb" search of all p^2 solutions. Using these methods, you can check only 1/4 of all solutions. Still pretty brute-force, but not bad. I don't think this is what CRGreathouse was recommending, just to clarify, but I thought I'd go ahead and make this explicit.

I'll think about this some more. It seems like some trick should be forthcoming...
 
  • #4
I was suggesting calculating all the squares mod p and putting them in a structure that would let you query "3" and get {} or query "5" and get {45, 56} -- in this case working mod 101.

Then you loop over the squares n, querying squares[p+1-n]. If it's nonempty, then the Cartesian product of squares[n] and squares[p+1-n] are solutions.

Enumerating squares takes p steps (no multiplication or division is really needed, but if the numbers are small it might actually be faster to just square and reduce).

Looping over the squares takes about p/2 loops, each of which takes 1-2 lookups and appending 0, 2, or 4 elements to a list.
 
  • #5
The 'number of solutions' is actually pretty easy: the trick is that any line intersects the circle in at most two points. (Exactly two points, if you count irrational and infinite points, as well as multiplicity) So, if you choose a point P on the circle, you can name any other point Q by the line passing through P and Q...

(for p > 2, you can show that through P, the circle has two asymptotes and one tangent line, thus there are p-1 points)
 
  • #6
Hurkyl said:
The 'number of solutions' is actually pretty easy: the trick is that any line intersects the circle in at most two points. (Exactly two points, if you count irrational and infinite points, as well as multiplicity) So, if you choose a point P on the circle, you can name any other point Q by the line passing through P and Q...

(for p > 2, you can show that through P, the circle has two asymptotes and one tangent line, thus there are p-1 points)

It looks like primes of the form 4n + 3 have p + 1 solutions, where primes of the form 4n + 1 have p - 1 solutions.
 
  • #7
CRGreathouse said:
It looks like primes of the form 4n + 3 have p + 1 solutions, where primes of the form 4n + 1 have p - 1 solutions.
Oh right, I knew that. I just got that wrong a couple weeks ago. :redface: The points at infinity have projective coordinates [itex](1 : \sqrt{-1} : 0)[/itex], and so to be rational, -1 must be a square mod p.
 
  • #8
I was wondering if it would help to figure out which values [tex]1 - b^2[/tex] are congruent to quadratic residues mod p, for each b = 0, 1, ... p-1.

If p is odd, and [tex]1 - b^2[/tex] is reduced to a value r between 0 and p-1, then a criterion by Euler says that r is a quadratic residue iff [tex]r^{(p-1)/2} \equiv 1[/tex] (mod p). Then again, you don't get the actual solution.
 
  • #9
Dodo said:
I was wondering if it would help to figure out which values [tex]1 - b^2[/tex] are congruent to quadratic residues mod p, for each b = 0, 1, ... p-1.

If p is odd, and [tex]1 - b^2[/tex] is reduced to a value r between 0 and p-1, then a criterion by Euler says that r is a quadratic residue iff [tex]r^{(p-1)/2} \equiv 1[/tex] (mod p). Then again, you don't get the actual solution.

But if you want all the residues, why go through that much trouble? Just square all the values. (If they're large enough that squaring is a trouble, just add 2n+1 to the last value and subtract as needed to reduce.)
 
  • #10
Hmm, right; actually calculating the powers in Euler's criterion is pretty expensive. So this reduces to list the squares, as you mentioned at the beginning.

One other thing. Leaving aside obvious solutions where one of a,b is zero, there are (p-1)/2 quadratic residues; so it seems that only 2 values of a for each one of b are possible (namely, a and -a), in order to total p-1 or p+1 solutions. So really you only need to run the squares up to half the list, I think.
 
  • #11
Dodo said:
so it seems that only 2 values of a for each one of b are possible (namely, a and -a), in order to total p-1 or p+1 solutions. So really you only need to run the squares up to half the list, I think.

Good point.
 

FAQ: Solving Prime Algorithm Unit Circle on Zp - Complexity?

1. What is a prime algorithm unit circle on Zp?

A prime algorithm unit circle on Zp is a mathematical concept that involves finding all the prime numbers within a given range on the number line, also known as Zp. These prime numbers are then arranged in a circular pattern, forming a unit circle.

2. What is the purpose of solving a prime algorithm unit circle on Zp?

The purpose of solving a prime algorithm unit circle on Zp is to identify and understand the patterns and relationships between prime numbers. This can help in developing more efficient algorithms for prime number generation, which has many applications in cryptography and computer science.

3. How complex is the process of solving a prime algorithm unit circle on Zp?

The complexity of solving a prime algorithm unit circle on Zp depends on the size of the range and the chosen algorithm. Generally, it can be a computationally intensive process, especially for larger ranges. However, with the use of efficient algorithms and computing methods, the complexity can be reduced.

4. What are some common challenges when solving a prime algorithm unit circle on Zp?

Some common challenges when solving a prime algorithm unit circle on Zp include handling large numbers, dealing with potential computational errors, and selecting the most suitable algorithm for a given range. Additionally, the complexity of the problem can make it challenging to find an optimal solution.

5. What are some real-world applications of solving a prime algorithm unit circle on Zp?

Solving a prime algorithm unit circle on Zp has many real-world applications, including cryptography, data encryption, and computer security. It is also used in the development of efficient algorithms for prime number generation, which has applications in various fields such as computer science, physics, and engineering.

Back
Top