Conditions for maximum period of quadratic congruential method (PRNG)
What's exactly "trial and error method" applied in this situation?


$\newcommand{\mymod}{\operatorname{modulo}}$As I understand, "trial and error method" here means checking all cases from a few simple natural or known perspectives until we have found a satisfactory solution or proof. It is useful and efficient in this situation because the number of cases $\mymod 2$ or $\mymod 4$ or $\mymod 9$ is very small.

What you have done seems pretty good.




  Why does $dx^2+ax+c\equiv d(x+a_1)^2 + c_1(\mymod{p^e})$ hold when $d \not\equiv 0\,(\mymod{p})$ ?


Prime $p\not=2$ since it has been assumed $p\ge5$. Since $d \not\equiv 0\,(\mymod p)$, $2d$ and $p^e$ are relatively prime, which implies $2d$ is invertible $\mymod p^e$. Let $(2d)d'\equiv1\,(\mymod p^e)$ fro some $d'$. Then

$$\begin{aligned}
dx^2+ax+c
&amp;\equiv dx^2+2dd'ax + c\\
&amp;\equiv d(x+d'a)^2 -d(d'a)^2+c\ (\mymod p^e)\\
\end{aligned}$$

Letting $a_1=d'a$ and $c_1=-d(d'a)^2+c$, we are done.