<s>[INST] Number of solutions of an equation over finite fields Does anyone know of any result that deals with the following problem of counting the number of solutions of a certain algebraic equation over a finite field?
Let $p$ be an odd prime and $(a,b,c,d)\in\mathbb{F}_p^4$. How many solutions does the following equation have:
$$
ab^2 + cd^2 = bc^2 + da^2.
$$
And more generally, if $1\le m,n\le q-1$ are two integers, how many solutions does the equation 
$$
a^mb^n + c^md^n = b^mc^n + d^ma^n
$$
have?
 [/INST] The first equation can be worked out in an elementary way. Counting the solutions where $b=0$ or $d=0$ is straightforward. So let's consider the case $bd\ne0$. The equation rewrites as\begin{equation}
d(a-\frac{b^2}{2d})^2+b(c-\frac{d^2}{2b})^2=\frac{b^5+d^5}{4bd}.
\end{equation}
So, given given $b$ and $d$, and upon setting $a=\frac{x+b^2}{2d}$, $c=\frac{y+d^2}{2b}$, and replacing $d$ with $-d$, we have to count the $x,y\in\mathbb F_p$ with
\begin{equation}
bx^2-dy^2=b^5-d^5.
\end{equation}
If $b^5-d^5\ne0$, we have an ellipsis with $p-1$ points if $b/d$ is a square, and $p+1$ points otherwise. The former case happens $(p-1)(p-3)/2$ times, and the latter case $(p-1)^2/2$ times. In the remaining case $b^5-d^5=0$ we have solutions $x, y$ if and only if $b/d$ is a square, and the number of solutions is $2p-1$ for each such pair $b,d$.
Indeed, carying out the count we, we find that there are all together $(p^2 + 6p - 6)p$ solutions if $p\equiv1\pmod{10}$, and $(p^2 + 2p - 2)p$ solutions if $p\not\equiv1\pmod{10}$.
</s>