Inspired by Bill Dubuque and Aaron Meyerowitz' arguments in this question
https://mathoverflow.net/questions/32011/direct-proof-of-irrationality
I calculated the following polynomial identity: $$m^2[pa^2n+2abm+b^2n]^2=p(am+bn)^4+(m^2-pn^2)(-pa^4m^2+4a^2b^2m^2+4ab^3mn+b^4n^2).$$ (Sage proof)
It follows from this identity that if $gcd(m,n)=1$ and $(m/n)^2=p$ then $p$ is a square. Indeed, applying Bézout's identity we find $a,b$ with $am+bn=1$, and if moreover $m^2-pn^2 = 0$ then the identity becomes $$m^2[pa^2n+2abm+b^2n]^2=p.$$
This may or may not be a "direct"/"constructive" proof of the irrationality of $\sqrt{2}$ (which is the subject of discussion in the question I linked). But I am primarily interested in improving this proof:
Question 1: Is there any simpler such identity? I guess by "such an identity" I mean an identity of the form $$ P(a,b,m,n,p)^2=p(am+bn)^{k}+(m^2-pn^2)Q(a,b,m,n,p). $$ and by "simpler" I mean of lower degree or with fewer terms.
Alternatively, Question 2: Why does the identity work? How would one come up with it?
(Obviously I did come up with it myself, via a tortuous path that I won't bother describing here, but I am wondering if there is an elegant way.)