How do we define how many lines lie on a given hypersurface in $\mathbb{F}_q^n$ Given the following surface, for example:
 $$\mathbb{H} = \{(z_1,z_2,z_3,z_4,z_5)\in \mathbb{F}_{p^2}: z_1 - z_1^p - z_2z_3^p + z_2^pz_3 - z_4z_5^p + z_4^pz_5 = 0\}$$  in $\mathbb{F}^5_{p^2}$. We know that it contains $p^9$ points. How do we define how many lines do these points form? Is there an established method/algorithm? 
 A: Any line in $\Bbb{F}_{p^2}^5$ has the following parametrized form
$$
L: P(t)=(z_1,z_2,z_3,z_4,z_5)=(a_1,a_2,a_3,a_4,a_5)+t(v_1,v_2,v_3,v_4,v_5),
$$
where $P(0)=(a_1,a_2,a_3,a_4,a_5)$ is some reference point on the line, $t$ is a parameter ranging over $\Bbb{F}_{p^2}$, and $\vec{v}=(v_1,v_2,v_3,v_4,v_5)$ is a non-zero vector pointing in the direction of the line. This presentation is by no means unique. We can multiply $\vec{v}$ with a non-zero constant and/or use any one of the $p^2$ points on the line as a reference point.
Anyway, the line $L$ is contained in the hypersurface $\Bbb{H}$, iff the point $P(t)$ satisfies the equation for all $t\in\Bbb{F}_{p^2}$. Let's plug it in! We get the polynomial
$$
F(t)=c_{p+1}t^{p+1}+c_pt^p+c_1t+c_0,
$$
where
$$
\begin{aligned}
c_0&=a_1 - a_1^p + a_2^p a_3 - a_2 a_3^p + a_4^p a_5 - a_4 a_5^p,\\
c_1&=v_1 - a_3^p v_2 + a_2^p v_3 - a_5^p v_4 + a_4^p v_5,\\
c_p&=-v_1^p + a_3 v_2^p - a_2 v_3^p + a_5 v_4^p - a_4 v_5^p,\\
c_{p+1}&=v_2^p v_3 - v_2 v_3^p + v_4^p v_5 - v_4 v_5^p.
\end{aligned}
$$
Because $F(t)$ has degree $\le p+1$ and must have $p^2$ zeros, it must be the zero polynomial. In other words we need to study the solutions of the system $c_0=c_1=c_p=c_{p+1}=0$.
The first equation $c_0=0$ simply states that the reference point must be on the hypersurface. We observe that given any values to all the other parameters $a_i, 1\le i\le 5$, $v_i,1<i\le5$, the equation $c_1=0$ holds for a unique value of $v_1$ (we can trivially solve it, as the equation is linear in the $v_i$s). The next equation $c_p=0$ is simply the Frobenius conjugate of the equation $c_1=0$, and gives no new constraints nor information.
The last equation $c_{p+1}=0$ is more interesting. We see (as we did in the other question) that the terms $v_2^pv_3$ and $-v_2v_3^p$ are negative Frobenius conjugates of each other, so their difference is in the kernel 
$$V=\{z\in\Bbb{F}_{p^2}\mid z^p=-z\}$$ of the trace $tr:\Bbb{F}_{p^2}\to\Bbb{F}_p, x\mapsto x+x^p.$ Observe that $V$ is a 1-dimensional vector space over the prime field $\Bbb{F}_p$.
This motivates the introduction of the function
$$
G:\Bbb{F}_{p^2}^2\to V, G(x,y)=xy^p-x^py.
$$
We will need to count the value distribution of $G(x,y)$. For all $v\in V$
let's denote by
$$
G_v=\left|\{(x,y)\in\Bbb{F}_{p^2}^2\mid G(x,y)=v\}\right|
$$
the number of times $G$ takes value $v$.
By homogeneity of $G$
$$G(\lambda x, \lambda y)=\lambda^{p+1}G(x,y).$$
Raising to power $p+1$ is the norm map $N:\Bbb{F}_{p^2}\to\Bbb{F}_p$. This is known to take all the non-zero values exactly $p+1$ times. We can thus deduce that $G_v=G_{v'}$ whenever $v\neq0\neq v'$.
We also easily see that $G(x,y)=0$ iff either $x=0$ or $y=0$ or $x^{p-1}=y^{p-1}\neq0$. Because the field $\Bbb{F}_{p^2}$ contains all the roots of unity of order $p-1$ the last case gives us $p-1$ solutions $x$ for all $y\neq0$. Therefore
$$
G_0=1+2(p^2-1)+(p-1)(p^2-1)=p^3+p^2-p.
$$
This implies that for all $v\in V, v\neq0$ we have
$$
G_v=\frac{p^4-G_0}{p-1}=p^3-p.
$$
The equation $c_{p+1}=0$ can be rewritten in the form
$$G(v_2,v_3)+G(v_4,v_5)=0.$$
In view of the above consideration we see that the number of solutions of this is
$$
N_{p+1}=(p-1)G_{v\neq0}^2+G_0^2=p^7+p^4-p^3.
$$
The trivial solution $v_2=v_3=v_4=v_5=0$ (implying that $v_1=0$ also) will not give us any lines. Because we can scale the direction vector by any non-zero multiplier without changing the line, we see that the lines on $\Bbb{H}$ point at
$$
N:=\frac{N_{p+1}-1}{p^2-1}=p^5+p^3+p^2+1
$$
different directions.
Let's take stock. No matter what the reference point $P(0)\in\Bbb{H}$ is, there will be $N$ lines through it contained in $\Bbb{H}$. The last four components of the directional vectors $\vec{v}$ take the same $N$ combinations (independent from $P(0)$) (equating scalar multiples as those really are homogeneous coordinates) and only the first component $v_1$ depends on the point $P(0)$ and it can be solved from the equation $c_1=0$.
To conclude: Each of the $p^9$ points on $\Bbb{H}$ is contained on $N$ lines along the hypersurface. As each line contains $p^2$ points, the total number of lines is thus
$$
\frac{p^9}{p^2}N=p^{12}+p^{10}+p^9+p^7.
$$
