## How to solve Diophantine equations in $F_{p}$?

### Remember to vote up questions/answers you find interesting or helpful (requires 15 reputation points)

For example, how to solve the equation `$\sum^{p-1}_{i}x_{i}^{2}=0$` in $F_{p}$? This is not a homework problem. I think it should have a definite answer, so not an open problem. I just don't know how to solve it.

-
Thanks for the answers! I want to ask is there any good bound for the number of solutions(sorry forgot to post in first place)? – Changwei Zhou Apr 6 2010 at 21:57

1
The number of solutions up to simultaneous scaling by a non-zero element of $\mathbb{F}_p$ (if p>3) should be $\frac{p^{p-2}-1}{p-1}$ if $p=1 \pmod{4}$ and $\frac{p^{p-2}-1}{p-1}+p^{\frac{p-3}{2}}$ if $p=3 \pmod{4}$. – damiano Apr 6 2010 at 22:15
damiano, how can you show that? I did some numerical work and conjectured it but I have no idea how such things are proven. – Michael Lugo Apr 6 2010 at 22:22

2
The way I computed it, was by using the Weil conjectures. In this case you can argue your way through using the fact that as soon as you have a solution you can find all the remaining ones by projection away from it (like in Bjorn's answer). What remains to show is what happens when the projection never contains a line (case 1) or when it does contain at least one (and hence two) (case 2). – damiano Apr 6 2010 at 22:28

2
The number of solutions was first worked out by Victor Amande Lebesgue (the number theorist, not the Lebesgue famous for his integration theory) in 1838 and was used for proving the quadratic reciprocity law. A simplified version of his proof was recently published by W. Castryck, A shortened classical proof of the quadratic reciprocity law, Amer. Math. Monthly (2007). – Franz Lemmermeyer Apr 7 2010 at 9:14
show 2 more comments

## 3 Answers

There is a deterministic polynomial-time algorithm for finding solutions to diagonal equations of degree less than or equal to the number of variables over finite fields. See Christiaan van de Woestijne's thesis.

(A solution of your example equation can be found much more simply, however: try small integers, not necessarily distinct... . And for quadratic forms, the other solutions can be found by drawing lines through the point and intersecting with the quadric hypersurface: there will either be one more intersection point, or a whole line of points.)

-

1
Hi! I really thanks for the link of the paper. I will read it. – Changwei Zhou Apr 6 2010 at 22:03

3
Sorry for the impertinent remark, but a deterministic algorithm for finding all solutions to an equation in the variables $x_1,\ldots,x_n$ over $\mathbb{F}_q$ is obtained by plugging in all $q^n$ possible values and counting how many give solutions. I can well believe the van de Woestijne's algorithm is better than this, but can you say exactly how? – Pete L. Clark Apr 6 2010 at 23:07
I don't really understand the part "the other solutions can be found by drawing lines through the point and intersecting with the quadric hypersurface: there will either be one more intersection point, or a whole line of points", I will read the paper. – Changwei Zhou Apr 6 2010 at 23:35
@Pete: Good point! I forgot to write the words "polynomial time" (not to mention "over finite fields"!) It's fixed now. – Bjorn Poonen Apr 7 2010 at 0:00

1
To amplify on what Bjorn said -- if you have one solution you can use it to rationally parametrize all others via pencils of line. So the real problem is there a fast (i.e. polynomial time algorithm in log of the size of the finite field) algorithm to find one point. It turns out that if you are given a quadratic non-residue (generator of the 2-sylow subgroup of $F^*$) then there is a deterministic poly time algorithm to find a solution. This is still an open problem but van de Woestijne found a clever way around this for diagonal forms. – Victor Miller Apr 7 2010 at 1:08
show 2 more comments

### You can accept an answer to one of your own questions by clicking the check mark next to it. This awards 15 reputation points to the person who answered and 2 reputation points to you.

You want to know if the sum of $p-1$ squares can be equal to 0 mod $p$. I'll assume that you don't want to allow the trivial (all-zeroes) solution.

If $k$ is a quadratic residue mod $p$, not equal to $1$, then this is simple; take $x_1$ such that $x_1^2 = k$, take $x_2 = \ldots = x_{p-k+1} = 1$, and take $x_{p-k+2} = \ldots = x_{p-1} = 0$.

So the equation $x_1^2 + \cdots + x_{p-1}^2 = 0$ has solutions mod $p$ as long as there exists a quadratic residue mod $p$ which is not equal to $1$. The number of quadratic residues mod $p$ is $\phi(p)/2$, where $\phi$ is Euler's totient function; if $\phi(p)/2 \ge 2$, or $\phi(p) \ge 4$, then there is at least one non-$1$ quadratic residue mod p. Now for a prime, $\phi(p) = p-1$, so that means your equation has solutions when $p-1 \ge 4$, i. e. when $p \ge 5$. We can check by brute force that $x_1^2 = 0 \mod 2$ and $x_1^2 + x_2^2 = 0 \mod 3$ have only the trivial solutions. So the equation $x_1^2 + \cdots + x_{p-1}^2 = 0 \mod p$ has nontrivial solutions for all primes $p \ge 5$.

(Basically, this is a more explicit version of the second paragraph of Bjorn Poonen's answer.)

-

1
In fact, what I was trying to hint at by "small integers" was your solution with k=4 (for p at least 5); i.e., 2^2 + 1^2 + 1^2 + ... + 1^2 + 0^2 + 0^2 = p. (No need to count quadratic residues!) – Bjorn Poonen Apr 6 2010 at 22:56

This answer is tangential in the sense that it is speaking of the existence of solutions rather than counting them all. But I rather suspect that you would find this interesting.

Suppose you have a quadratic form in at least thee variables over $\mathbb F_p$. Then the Chevalley-Warning Theorem would tell you that it has a nontrivial solution.

If you want to check out more, I refer you to the first chapter of J.-P. Serre's "A Course in Arithmetic", rather than the wikipedia page linked above.

-

Hi! I am reading the book "A course in arithmetic". I finished about 4 chapters by now. Thanks! – Changwei Zhou Jul 21 2010 at 3:23
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 38, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9382911920547485, "perplexity_flag": "head"}