I have a polynomial of the second degree $a\cdot n^2 + b \cdot n + c$ and I need to find out natural numbers $n$, such that $\sqrt{a\cdot n^2 + b \cdot n + c}$ is also a natural number.

After thinking about this problem, my idea was to rewrite it into $a\cdot n^2 + b \cdot n + c = x^2$ and rewrite it to look like a Pell's equation:

$$(2an + b)^2 - 4ax^2= b^2 - 4 ac$$ which kind of resembles $x^2 - n y ^2 = 1$, but not really close enough to for me to solve it.

Then I tried to find some similarities in solutions for particular cases. For example when I took the equation $\sqrt{3\cdot n^2 - 2 \cdot n - 1}$ and wrote the program, the couple of first values were: 1, 5, 65, 901, 12545 (with no visible pattern for me).

So how should I solve this problem?

  • $\begingroup$ Do you really want to have a general solution that works for all values of $a,b,c$? If you are eventually only interested in some special cases, it would be easier to tackle those. $\endgroup$ Jul 15, 2015 at 7:51
  • 1
    $\begingroup$ It's difficult to take your question seriously with that as your profile picture. $\endgroup$
    – user230734
    Jul 15, 2015 at 7:53
  • $\begingroup$ @JoonasIlmavirta if the general solution is too hard, you can show me how to come up with a solution for $3n^2 - 2n - 1$ $\endgroup$ Jul 15, 2015 at 8:09
  • $\begingroup$ If $c=k^2$ it is easy to rewrite in another Pell equation. In another case decided the same view through the Pell equation. $\endgroup$
    – individ
    Jul 15, 2015 at 8:41

2 Answers 2


If you wish to have an infinite number of integer solutions to,

$$an^2+bn+c = d^2\tag1$$

but not necessarily all of them, then one way is, yes, to solve a Pell equation. First, as pointed out in the other answer, you need a initial solution. Second, if you limit it to only integers, then $a$ must not be a square.

Given an initial $n,d$ to $(1)$, then an infinite more can be found as,

$$ax^2+bx+c = (-d+py)^2$$


$$x = n+qy$$

$$y = 2dp+(b+2an)q$$

and $p,q$ solve the Pell equation $p^2-aq^2 = 1$.


$$3n^2-2n-1 = d^2$$

with initial $n,d = 5,8$, you get,

$$3x^2-2x-1 = (-8+py)^2$$


$$x = 5+qy$$

$$y = 16p+28q$$

and $p,q$ is any solution to $p^2-3q^2=1$.

Note: This is an easy method to get an infinite number of solutions, but not all of them.

  • $\begingroup$ Any idea how can I find initial solution? $\endgroup$ Jul 15, 2015 at 18:00
  • $\begingroup$ @SalvadorDali: You can use mod arguments like in this answer. Or, since it is the smallest , then a simple program can quickly establish if it has a solution within a bound, say $|n|<1000$. If there is, the method above then guarantees there are an infinite more. $\endgroup$ Jul 16, 2015 at 2:49

With slight change of notation, you are looking for, given $a,b,c\in \mathbf{Z}$, points with integer co-ordinates on the curve $ax^2-y^2+bx+c=0$.

This is a conic. If you know one solution exists, then we can find infinitely many through rational parametrization. This is well-known (for example can be found in Silverman-Tate). Call this one solution point $Q_0$

Now fix a line $L$ whose equations has integer/rational coefficients. For a variable point $P\in L$ with RATONAL co-ordinates, write the equation of the line connecting $P$ with $Q_0$; as the intersection of a conic with line has 2 points you get the other point $P'$. This will be a rational point.(Convince yourself). So you get solutions you want.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.