# finding perfect squares solutions for the following case

I was working on a number theory problem and create a equation. I tried research on this, but tbh I don't even know what should I google for... Here's my cases.

$$n = \sqrt{N * \frac{1+\sqrt{4k^2+1}}{2}}$$ $$m = \sqrt{N * \frac{\sqrt{4k^2+1}-1}{2}}$$

Where N is a given integer, m, n are both unknown integers, k has a given range of [0, 10] and k is a real number.

My question is, What is the fastest way to find such k that create integers m and n?

• Why would you expect the answer(s) to be unique? With $N=1$, for instance, then $k=2\sqrt 3$ works as does $k=6\sqrt 2$
– lulu
Commented Mar 18, 2019 at 19:42
• @lulu Ohh it doesn't have to be unique, should I change the 'n is an unknown integer' into 'unknown integers? Commented Mar 18, 2019 at 19:46
• Your header refers to "unique" solutions, but maybe you meant something else?
– lulu
Commented Mar 18, 2019 at 19:47
• @lulu just changed that, thanks for that. Commented Mar 18, 2019 at 19:48
• In any case: for a fixed $N$, I'd compute the expression with $k=\frac 89$, and compute it for $k=9$. Then, for each integer between the two values you get you can easily find a solution $k$ that gives you that integer.
– lulu
Commented Mar 18, 2019 at 19:48

Given the range in $$k$$, you have $$1+\frac {\sqrt{337}}{18} \le \frac {1+\sqrt{1+4k^2}}2\le 1+\frac {5\sqrt{13}}2$$ The left side is a little more than $$2$$ and the right a little more than $$10$$. The range of $$n$$ that is available is from $$\left\lceil\sqrt{\left(1+\frac {\sqrt{337}}{18}\right)N}\right\rceil$$ to $$\left\lfloor\sqrt{\left(1+\frac {5\sqrt{13}}2\right)N}\right\rfloor$$ inclusive. Choose your $$n$$ and solve the equation for $$k$$.
For your new problem with $$m,n$$, note that the radicands differ by $$N$$, so we can write $$n^2-m^2=N=(n+m)(n-m)$$. The two factors $$n+m$$ and $$n-m$$ have the same parity, so if $$N$$ is divisible by $$2$$ and not $$4$$ there is no solution. Otherwise, each way of factoring $$N$$ into two factors of the same parity give a solution to $$n=\sqrt {aN+\frac N2}, m=\sqrt{aN-\frac N2}$$. For each factorization, you can see if $$a$$ is in the range at the top of my post. If it is, $$k$$ will be in range, otherwise not.
• It is just the standard factoring of the difference of squares. You can multiply it out to see it works. For example, if $N=24=2^33$ we can have $n+m=12,n-m=2,n=7,m=5, n^2-m^2=49-25=24$ or $n+m=5,n-m=4,n=5,m=1,n^2-m^2=5^2-1^2=24$ Commented Mar 18, 2019 at 20:57