Problem: Given a positive integer $m$, which can be written as $m^2 = 4n^2 - 5n + 16$, where $n$ is an integer of any sign, find the maximum value of $|m - n|$.
For this, I assumed $|m - n| = k$ then $$k^2 = m^2 + n^2 - 2mn = 5n^2 - 5n + 16 - 2n\sqrt{4n^2 - 5n + 16}$$
Taking derivative to find increasing or decreasing intervals, keeping in mind that $4n^2 - 5n + 16$ must be a perfect square. I used wolfram to obtain values of $n$ for which the given expression was a perfect square, and it returned $n = 15,-15$ as the largest and smallest solutions, along with other solutions, and noting that the derivative is positive at $n=15$, this must be the point of maxima of $k$, thus $4(15)^2 - 5(15) + 16 =29^2$, which yields
$$k=|29-15| = 14$$
which is indeed the given answer.
My question is, how do I find values of $n$ for which $4n^2 - 5n + 16$ is a perfect square? I tried taking the expression modulo 4 and making cases to obtain something but didn't get anywhere. The problem is from IOQM 2023.
Completely different solutions to the problem are also welcomed.
Complete the square on the right hand side to get $m^2=(2n-5/4)^2+231/16$, or clearing denominators:
$$(4m)^2=(8n-5)^2+231$$
You can then write $231$ as the difference of two squares, and find all integer values of $m$ and $n$ which satisfy the diophantine equation.