TITLE: Non trivial solution over $\mathbb{Z}_p$
QUESTION [5 upvotes]: Suppose p is an odd prime. Prove that
$a_1x_1^2 + a_2x_2^2 + a_3x_3^2 + a_4x_4^2 + a_5x_5^2 = 0$
always have non-trivial solution over $\mathbb{Z}_p$ for any choice of $a_i$ in $\mathbb{Z}$. where $\mathbb{Z}_p$ is the p-adic integers

REPLY [3 votes]: If $p \mid a_i$ for some $i$, then $x_i=1$ and $x_j=0$ for $j \not =i$ gives a non-trivial solution over $\mathbb{Z}_p$.
Otherwise suppose $p \nmid a_i, i=1, 2, 3, 4, 5$.
If $p \equiv 1 \pmod{4}$, then $\left(\frac{-1}{p}\right)=1$, so there exists $c \in \mathbb{Z}_p$ s.t. $c^2 \equiv -1 \pmod{p}$. Consider $\left(\frac{a_i}{p}\right), i=1, 2, 3, 4, 5$. By Pigeonhole principle, we must have $\left(\frac{a_i}{p}\right)=\left(\frac{a_j}{p}\right)$ for some $i \not =j$. 
If $\left(\frac{a_i}{p}\right)=\left(\frac{a_j}{p}\right)=1$, then $\exists b_i, b_j \in \mathbb{Z}_p$ such that $b_i^2 \equiv a_i \pmod{p}$ and $b_j^2 \equiv a_j \pmod{p}$. Now take $x_i=b_i^{-1}, x_j=b_j^{-1}c$ and $x_k=0$ for $k \not =i, j$. This gives a non-trivial solution, since we have $a_1x_1^2+a_2x_2^2+a_3x_3^2+a_4x_4^2+a_5x_5^2 \equiv (b_i)^2(b_i^{-1})^2+(b_j)^2(b_j^{-1}c)^2 \equiv 0 \pmod{p}$.
If $\left(\frac{a_i}{p}\right)=\left(\frac{a_j}{p}\right)=-1$, let $n$ be a quadratic non-residue $\pmod{p}$, so that $\left(\frac{na_i}{p}\right)=\left(\frac{na_j}{p}\right)=1$, then $\exists b_i, b_j \in \mathbb{Z}_p$ such that $b_i^2 \equiv na_i \pmod{p}$ and $b_j^2 \equiv na_j \pmod{p}$. Now take $x_i=b_i^{-1}, x_j=b_j^{-1}c$ and $x_k=0$ for $k \not =i, j$. This gives a non-trivial solution, since we have $n(a_1x_1^2+a_2x_2^2+a_3x_3^2+a_4x_4^2+a_5x_5^2) \equiv (b_i)^2(b_i^{-1})^2+(b_j)^2(b_j^{-1}c)^2 \equiv 0 \pmod{p}$ and $p \nmid n$.
If $p \equiv 3 \pmod{4}$, then $\left(\frac{-1}{p}\right)=-1$. Thus $\left(\frac{a_i\left(\frac{a_i}{p}\right)}{p}\right)=1$, so $\exists b_1, b_2, b_3, b_4, b_5 \in \mathbb{Z}_p$ s.t. $a_i \equiv \left(\frac{a_i}{p}\right)b_i^2 \pmod{p}, i=1, 2, 3, 4, 5$. Let $x_i=b_i^{-1}y_i$, so that 
\begin{align}
& a_1x_1^2+a_2x_2^2+a_3x_3^2+a_4x_4^2+a_5x_5^2 \\
& \equiv \left(\frac{a_1}{p}\right)y_1^2+\left(\frac{a_2}{p}\right)y_2^2+\left(\frac{a_3}{p}\right)y_3^2+\left(\frac{a_4}{p}\right)y_4^2+\left(\frac{a_5}{p}\right)y_5^2 \pmod{p}
\end{align} 
Clearly a non-trivial solution for the expression in $y_i$ to be $0 \pmod{p}$ would correspond to a non-trivial solution for $x_i$.
If $\left(\frac{a_i}{p}\right)=-1, \left(\frac{a_j}{p}\right)=1$ for some $i, j$, then let $y_i=y_j=1$, $y_k=0$ for $k \not =i, j$, then $\left(\frac{a_1}{p}\right)y_1^2+\left(\frac{a_2}{p}\right)y_2^2+\left(\frac{a_3}{p}\right)y_3^2+\left(\frac{a_4}{p}\right)y_4^2+\left(\frac{a_5}{p}\right)y_5^2 \equiv \left(\frac{a_i}{p}\right)+\left(\frac{a_j}{p}\right) \equiv 0 \pmod{p}$.
Otherwise $\left(\frac{a_1}{p}\right)=\left(\frac{a_2}{p}\right)=\left(\frac{a_3}{p}\right)=\left(\frac{a_4}{p}\right)=\left(\frac{a_5}{p}\right)$, so we have 
\begin{align}
& \left(\frac{a_1}{p}\right)y_1^2+\left(\frac{a_2}{p}\right)y_2^2+\left(\frac{a_3}{p}\right)y_3^2+\left(\frac{a_4}{p}\right)y_4^2+\left(\frac{a_5}{p}\right)y_5^2 \\
& \equiv \left(\frac{a_1}{p}\right)(y_1^2+y_2^2+y_3^2+y_4^2+y_5^2) \pmod{p}
\end{align} 
By Lagrange's four-square theorem, we can write $p=m_1^2+m_2^2+m_3^2+m_4^2, m_1, m_2, m_3, m_4 \in \mathbb{Z}$. We clearly have $0 \leq m_1^2, m_2^2, m_3^2, m_4^2 \leq p$, and $m_i$ are not all $0$, so they are not all divisible by $p$. Now take $y_i \equiv m_i \pmod{p}$ for $i=1, 2, 3, 4$ and $y_5=0$. This then gives a non-trivial solution, and we are done.
Edit: Actually we do not even need Lagrange's four-square theorem. Let $q$ be the smallest quadratic non-residue $\pmod{p}$. Then $1, q-1, -q$ are all quadratic residues $\pmod{p}$, so we have $r^2 \equiv q-1 \pmod{p}$ and $s^2 \equiv -q \pmod{p}$ for some $r, s \in \mathbb{Z}_p$. Then take $y_1=1, y_2=r, y_3=s, y_4=y_5=0$, and we have a non-trivial solution, so we are done.