How close is an odd power of two to a perfect square? Let $n \ge 1$ be an odd natural number. Define $$f(n)=\min \{\,\, |k| \,\,\, | \, k+2^n \,\,\,\text{is a square}\,\,,k \in \mathbb{Z}\}.$$
That is $f(n)$ measures how close is the power $2^n$ to a perfect square.
I guess that this notion was studied somewhere, but I couldn't find it naively on google.
Question: (a bit soft)
Does this function has a known name in the literature? Has it been studied somewhere? Is there a closed form formula for it, or at least some nice lower bounds on its values?
 A: Ineffectively, one can show that, given $\epsilon > 0$, there exists a positive constant $c(\epsilon)$ such that
$$
f(n) \geq c(\epsilon) \, 2^{(1/2-\epsilon)n}.
$$
This follows from the $p$-adic version of Roth's theorem, proved by Ridout, and represents the true state of affairs. I suspect that making this effective would be very hard and anything resembling a closed form is too much to hope for.
In terms of explicit lower bounds, one can prove that
$$
f(n) > 2^{0.26n},
$$
unless $n \in \{ 3, 15 \}$. This can be found in an old paper of Bauer et al; the proof uses Pade approximation to the binomial function. It is unlikely that one can get much of a bound via elementary methods.
A: There is Catalan’s conjecture and Michailescu’s theorem which states that $Y^p = 1 + X^q$ has only one solution for $X,Y >0$. Those numbers are $3^2= 1 + 2^3$. Since $2^{2n+1}$ cannot be a perfect square, $0$ cannot be a solution to $k$, which leaves $k=1$, as above as the nearest solution in absolute terms. I suppose in relative terms there will be plenty of odd powers of $2$ such that  $ \mid 2^{2n+1}/ Y^p \mid \lt 9/8 = 1 \pm \varepsilon$ where higher and higher odd powers of $2$ reduces $\varepsilon$ to an arbitrarily low number.
