Solving Prime Algorithm Unit Circle on Zp - Complexity?

  • Context: Graduate 
  • Thread starter Thread starter khotsofalang
  • Start date Start date
  • Tags Tags
    Prime
Click For Summary

Discussion Overview

The discussion revolves around finding all possible solutions (x1, x2) on a unit circle defined by the equation x1 + x2 = 1 within a finite field Zp, where p is a prime number. Participants explore algorithms for determining these solutions, their complexity, and the implications of various mathematical properties related to prime numbers and quadratic residues.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant proposes the problem as finding solutions (a, b) to the equation a^2 + b^2 ≡ 1 (mod p) and discusses the complexity of brute-force methods.
  • Another participant suggests that for odd primes p > 2, solutions can be reduced by considering only pairs (a, b) with the same parity, effectively halving the candidate solutions.
  • A different approach involves calculating all squares mod p and using a data structure to efficiently query potential solutions based on these squares.
  • Some participants mention that the number of solutions can be derived from geometric properties, noting that lines intersect the circle at most twice and discussing specific cases for primes of the form 4n + 3 and 4n + 1.
  • There is a discussion about using Euler's criterion to determine quadratic residues, although some participants express skepticism about the efficiency of this method compared to simply listing squares.
  • One participant notes that for each quadratic residue, there are typically two corresponding values of a, leading to a total of p-1 or p+1 solutions, suggesting that only half the list of squares needs to be computed.

Areas of Agreement / Disagreement

Participants express various methods and insights regarding the problem, but there is no consensus on a single algorithm or approach. Multiple competing views and techniques are presented, indicating that the discussion remains unresolved.

Contextual Notes

Some participants highlight the limitations of their proposed methods, such as the dependence on the parity of solutions and the computational complexity of certain approaches. The discussion also reflects uncertainty regarding the efficiency of different algorithms and the implications of specific properties of prime numbers.

khotsofalang
Messages
21
Reaction score
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
I take the problem as: find the solutions (a, b) of
a^2+b^2\equiv1\pmod p, 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.
 
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...
 
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.
 
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)
 
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.
 
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 (1 : \sqrt{-1} : 0), and so to be rational, -1 must be a square mod p.
 
I was wondering if it would help to figure out which values 1 - b^2 are congruent to quadratic residues mod p, for each b = 0, 1, ... p-1.

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

If p is odd, and 1 - b^2 is reduced to a value r between 0 and p-1, then a criterion by Euler says that r is a quadratic residue iff r^{(p-1)/2} \equiv 1 (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.
 

Similar threads

Replies
4
Views
7K
  • · Replies 12 ·
Replies
12
Views
10K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 31 ·
2
Replies
31
Views
3K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
7K