Let m, n be positive integers.
Let $x^2+2mx-n=p^2$ for some p which is a positive integer.
How does one solve for x?
Sorry forgot this: x must be an integer.
Let m, n be positive integers.
Let $x^2+2mx-n=p^2$ for some p which is a positive integer.
How does one solve for x?
Sorry forgot this: x must be an integer.
We change notation slightly, to make it clear that what is called $p$ is variable.
Our equation can be rewritten as $(x+m)^2-m^2-n=y^2,$ and then as $(x+m)^2-y^2=m^2+n,$ or equivalently $[(x+m)-y][(x+m)+y]=m^2+n.$ If $m^2+n$ is of the form $4k+2$, there are no integer solutions. For suppose to the contrary that there is a solution $(x,y)$. Note that $(x+m)-y$ and $(x+m)+y$ differ by an even number $2y$. So they are both odd or both even. If they are both odd, then their product cannot have shape $4k+2$. And it cannot have shape $4k+2$ if both are even.
Now assume first that $m^2+n$ is odd. Let $s$ be any divisor of $m^2+n$, and let $t=(m^2+n)/s$. We can solve the system of linear equations $(x+m)-y=s$, $(x+m)+y=t$ for $x$ and $y$. In particular, we get $y=\frac{1}{2}(t-s)$. This is positive if, for example, we let $s$ be any positive divisor of $m^2+n$ which is less than $\sqrt{m^2+n}$. We also get positive $y$ if $s$ is a negative divisor of $m^2+n$ which is less than $-\sqrt{m^2+n}$.
If $m^2+n$ is a multiple of $4$, $s$ and $t$ must be chosen to be both even. Apart from that, the analysis is the same.
In both the case $m^2+n$ is even, and the case $m^2+n$ is divisible by $4$, all integer solutions of our Diophantine equation are obtained as described above from factors of $m^2+n$.
Remark: If we know the prime power factorization of $m^2+n$, we can find an expression for the number of solutions of our diophantine equation.
Given positive integers $m,n$ you want positive integers $x,p$ such that $x^2+2mx-n=p^2$ Rewrite as $x^2+2mx+m^2-p^2=n+m^2$ which is $(x+m+p)(x+m-p)=n+m^2$ Now for each way of factoring $n+m^2$, you get possible solutions. If $n+m^2=de$, then you have $x+m+p=d,\quad x+m-p=e$ which gives you $x=-m+(d+e)/2,\quad p=(d-e)/2$ For integers, you have to have $d,e$ both even, or both odd; for positive integers, you need $d\gt e$.
If $m$, $n$, and $p$ are known values, then
$x^2+2mx-n=p^2$
$\Longrightarrow x^2 +2mx - (p^2+n)=0$.
This can be solved using the quadratic formula, giving
$x=\pm \sqrt{m^2+p^2+n}-m$ .