1

$$a^{p-1} \equiv 1 \pmod p$$

Assuming the above expression is true, does it tell me anything about the congruence relation of the following expression:

$$a^{\frac{p-1}{2}} \pmod p)$$

I can't seem to come to a conclusion by using properties of modular exponentiation that I find online. My goal is to somehow relate the two so I can efficiently evaluate the second expression when using very large values.

Note: $a$ is some positive integer less than $p$, and $p$ is a prime number.

Bernard
  • 175,478
Jacob G.
  • 153

1 Answers1

2

Yes it can (we are assuming that $p \not \mid a$). We know that: $$(a^{\frac{p-1}{2}})^2 \equiv a^{p-1} \equiv 1 \pmod{p}$$ And since for any number $x$ such that $x^2 \equiv 1 \pmod{p}$ we have $p \mid x^2-1=(x-1)(x+1)$ and therefore $p \mid x-1$ or $p \mid x+1$ and therefore $x \equiv \pm 1 \pmod{p}$ we can conclude that: $$a^{\frac{p-1}{2}} \equiv \pm 1 \pmod{p}$$ Actually, by Euler's criterion we have even stronger result: $$a^{\frac{p-1}{2}} \equiv \left( \frac{a}{p}\right) \pmod{p}$$ Where $\left( \frac{a}{p}\right)$ denotes the Legendre symbol, i.e. it is $0$ when $p \mid a$, $1$ when $a$ is quadratic residue modulo $p$ and $-1$ when it isn't.

Bartek
  • 2,475
  • 1
    Thanks for the answer. I'm actually trying to calculate the Legendre symbol, but I'm looking for a way to do it efficiently (which is why I'm wondering if the two congruences that I listed are related). So given the first expression that I listed, is it possible to efficiently evaluate the latter using some property of modular arithmetic? I know it will be congruent to +-1 mod p, but I'm looking to get the exact value. – Jacob G. Jun 30 '19 at 00:04
  • 1
    @JacobG. The problem with the property: $$a^{p-1} \equiv 1 \pmod{p}$$ Is that by FLT it holds for all $a$ not divisible by $p$ so knowing that it holds tells us little about the value of the Legendre symbol (except for the fact that it is nonzero). Computing the Legendre symbol this way (i.e. by Euler criterion and using repeated squaring for exponentiation) is probably the most efficient method in terms of computational complexity. – Bartek Jun 30 '19 at 00:18
  • Thanks, I guess that means that there's no trick, unfortunately :) – Jacob G. Jun 30 '19 at 00:19
  • 2
    The efficient way to compute the Legendre symbol is via quadratic reciprocity. – Angina Seng Jun 30 '19 at 00:20
  • @LordSharktheUnknown Maybe there is some faster way by using it but it's not obvious to me how one would go about constructing such a fast algorithm. If $a$ is not prime one would first had to decompose it into its prime factors and that does not seem to be a fast process (repeated squaring gives a $O(\log p)$ solution - it's really hard to improve it since it is of the size of the input). – Bartek Jun 30 '19 at 00:25
  • 1
    @Bartek Learn about the Jacobi symbol. – Angina Seng Jun 30 '19 at 00:33
  • @Lord Shark the Unknown I know the Jacobi symbol, but still how this method is faster than the repeated squaring. It still yields an $O(\log p)$ solution. It may have a better constant but it's still asymptotically equivalent (and definitely simpler to implement). – Bartek Jun 30 '19 at 00:38
  • @Bartek Then why launch on a disquisition on the complexity of factorisation? – Angina Seng Jun 30 '19 at 00:39
  • @Lord Shark the Unknown I just forgot that the quadratic reciprocity holds for the Jacobi symbol as well. – Bartek Jun 30 '19 at 00:40
  • 1
  • @BillDubuque Thanks, but I don't think that helps me, unfortunately, as p is already prime in my example. I have a method of calculating the Legendre/Jacobi symbol quickly, but I was wondering if there was something quicker (seeing as how I can pick the value of p) – Jacob G. Jun 30 '19 at 00:51
  • @JacobG. Yes, I know, but I thought you might find it of interest anyhow. – Bill Dubuque Jun 30 '19 at 00:58