Solve an equation with integer variables I am trying to find all the integers $(n,m)$ such that $$2^{2n+1} + 2^n + 1 = m^2$$.
With a simple python program, I find that $n=0$, $n=4$ are the only solutions less than $50$. However with the precision of number I can not get accurate results when $n > 50$. Does any one have an idea which could help me to solve this equation ? 
 A: Using the following code in MATLAB shows that besides $n = 0$ and $n = 4$, there is no other solution, at least up till $n = 512$ which is when MATLAB declares the LHS of the equation to be infinite. The use of functions digits and vpa allow for greater precision of numbers. These are helpful resources: Increase Precision of Numeric Calculations, vpa, digits
digits(150);
for n = 0:1:1000
    m = vpa(sqrt(vpa(power(2, 2*n + 1)) + vpa(power(2, n)) + 1));
    if (vpa(m) == vpa(floor(vpa(m))))
        n
        m
    end
end

A: Without loss of generality, we may assume that $m$ and $n$ are non-negative. We begin by rearranging the equation to read as follows:
$$
2^n(2^{n+1}+1)=(m-1)(m+1)
$$
This implies that $2^{n-1}$ exactly divides either $m-1$ or $m+1$. If it is the case that $2^{n-1}$ exactly divides $m-1$, we can write $m-1=k2^{n-1}$ for some odd natural number $k$. If $k\geq 3$, then:
$$
(m-1)(m+1)=k2^{n-1}(k2^{n-1}+2)=k^22^{2n-2}+k2^n\geq 9\cdot2^{2n-2}+3\cdot 2^{n}> 2^{2n+1}+2^n
$$
This is a contradiction. Thus, we know that $2^{n-1}$ exactly divides $m+1$. Write $m+1=k2^{n-1}$ for some odd natural number $k$. If $k\geq 3$, then we see the following:
$$
(m-1)(m+1)=(k2^{n-1}-2)k2^{n-1}=k^22^{2n-2}-k2^n\geq 9\cdot 2^{2n-2}-3\cdot 2^n
$$
The RHS of this chain inequality, $9\cdot 2^{2n-2}-3\cdot 2^n$, is greater than $2^{2n+1}+2^n$ if $n>4$. Thus, aside from the solutions $(m,n)=(2,0)$ and $(m,n)=(23,4)$, the only possible solutions are of the form $(2^{n-1}\pm 1,n)$, which obviously do not satisfy the Diophantine equation.
Therefore the only two solutions are the two that have already been found in the original posting of the problem.
EDIT: I forgot to mention you have to exhaustively search over the $n=0$ to $n=4$ range to complete the proof. Oops.
A: It appears that this is going to quickly turn into a Pell-like Diophantine equation.
First, notice that $2^{2n+1}$ can be expressed in terms of $2^n$. Because of this, consider the substitution $k=2^n$. Then try manipulating the resulting equation to give you a Pell-like equation. Once you do this, the method for solving the remaining problem is standard. You still need to ensure that the solution ends with $k$ being a power of 2, and I confess that I have not worked through the problem far enough to see if this will have a nice characterization.
EDIT: @WillJagy has performed the substitution and given the Pell-like equation, but I'm a bit rusty and haven't found the general solution to the Pell equation yet. If I had to solve the problem, I would find the recursive identities that the solutions must satisfy, and prove that $k$ cannot be a power of 2 if it is sufficiently large. If this isn't tractable, I would then find the exact solution to the recursion and then use some Binomial Theorem shenanigans to see if I can show that it's never a power of 2.
A: Suppose $n > 2$.  We have $m^2 -1 = (m-1)(m+1)\equiv 0 \mod 2^n$, so one of $m-1$ and $m+1$ is divisible by $2^{n-1}$ (the other is divisible by $2$ but no higher power of $2$).  By symmetry $m \to -m$, we may assume it is $m-1$.  Thus
$m = 1 + k 2^{n-1}$.  With this substitution the equation becomes
$$ 2^{2n} \left(2 - \frac{k^2}{4}\right) + (1-k) 2^n = 0$$
or 
$$ 2^{n-2} = \frac{k-1}{8-k^2}$$
Now $\gcd(k-1,8-k^2) = \gcd(k-1,8-k) = \gcd(k-1,7)$ is either $1$ or $7$.
$k-1$ must be even, so $k$ is odd and $8-k^2$ is odd (and can only be $\pm 1$ or $\pm 7$).  Only for $k=-3$ do we get $(k-1)/(8-k^2) = 4 $ a power of $2$.  This corresponds to the solution $n = 4$, $m = 1 - 3 \cdot 2^3 = -23$.
