Solution of Diophantine Equations Using Calculus Solve the equation in positive integers $$2^p+q^2=2^q+p^2$$
Here we see that $p=q$ is a solution otherwise let us assume that $q>p$, Now if we consider the function $$f(x)=2^x-x^2, x \geq 1$$ Now $$f'(x)=2^x \ln2-2x > 0$$ for $x \geq 1$ So we see that the function $f(x)=2^x-x^2$ is an increasing function for $x \geq 1$ So the above equation has no solutions except $p=q$
Is My Proof Correct?
 A: By your work $f(x)=2^x-x^2$ increases on $[4,+\infty).$ Here was your mistake.
Thus, for $\{p,q\}\subset[4,+\infty)$ the equation $f(p)=f(q)$ has a solution $\{(p,q)|p=q\}$ only.
Also, easy to see that $(2,4)$ and $(4,2)$ they are solutions and we got all possible solutions:
$$\{(2,4),(4,2),(p,p)|p\in\mathbb N\}.$$
A: Your strategy is totally correct but you need to be more precise.
The inequality you wrote is correct for $x$ bigger than or equal to $5$. So, you have to solve the equation when at least one of $p,q$, say $q$, belongs to $\{ 1,2,3,4 \}$ (Otherwise $p$ and $q$ must be equal).
In the case $q=2$, we have $4+2^p=p^2+4$, so $(2,4),(2,2)$ are two pairs of answers.
In the case $q=3$, we have $9+2^p=p^2+8$, so $(3,3)$ is a pair of answers.  (Note that $(p-1)(p+1)=2^p$ and this means $p=3$ because $(p-1,p+1)=2$.)
In the case $q=4$, we have $16+2^p=p^2+16$, so $(4,4),(4,2)$ are two pairs of answers.
In the case $q=1$, we have $1+2^p=p^2+2$, and $p^2+1=2^p$ implies that $p$ must be odd less than $5$. $(1,1)$ is trivial.
Now, we are done.
