A Quadratic Diophantine Equation

(New Question of the Week)

One of the strengths of the Math Doctors is the breadth of knowledge represented by our volunteers; we are all different. I have tended here to show the topics that I myself deal with, because those are what I can say most about; but whereas I focus mostly on elementary math through calculus and some other college topics, several of us are much stronger than I on higher math, such as number theory. Here I want to show an example of such a question; it will also demonstrate how two of us can give different answers that complement one another.

The problem

This question came to us in February, from Josh, an undergraduate college student who didn’t initially tell us enough of his background to be sure what kind of answer would be suitable. The question, however, was advanced enough to suggest that a full explanation would be appropriate. He helpfully followed our advice to show both the problem and what thoughts he had about it:


Find all rational numbers x such that 3x^2-5x+9 is the square of a rational number.

Thought process:

Rational numbers are of the form m/n where m and n are integers. Therefore 3x^2-5x+9 = (m/n)^2 where x is also of the form m/n.

I guess my problem is where to start the solution. My initial thought is to find where (3x^2-5x+9)^(1/2)=m/n then find where x is both rational and gives a rational solution.

First solution: Recurrence relation for a Pell equation

Doctor Jacques was the first to answer:

Hi Josh,

As I don’t know your background, there is a possibility that you will not understand what I’m going to explain. If this is the case, please tell me more about the context of the question; maybe I could think about this a little more and come up with a more elementary explanation (although I doubt it).

We could indeed write x = m/n and work with integers, but I think this will introduce new questions about divisibility and simplification of fractions and will not give something simpler; we will use integers at some point, but not at the beginning.

We have the equation:

3x² – 5x + 9 = q²

where x and q are rational numbers. As is often the case with quadratic equations, we start by completing the square. After multiplying by 12 and some manipulations, we get:

(6x)² – 60x + 108 = 12q² = 3r²

(6x-5)² + 83 = 3r²

u² – 3r² = -83 ……………………………. [1]

with u = 6x – 5 and r = 2q (if q is rational, r is rational and conversely).

This equation is a Pell-type equation. The solution involves working in the ring of (algebraic) integers of the field ℚ[√3]. This field has the following characteristics:

  • The ring of integers is the set {x + y√3 | x, y ∈ℤ}
  • It is a unique factorization domain

The bottom line of this is that we can write:

u² – 3r² = (u + r√3)(u – r√3)

and use (more or less) the rules of normal arithmetic.

The first thing to do is to solve the equation

u² – 3r² = 1 …………………………….. [2].

By trial and error, we find easily that the smallest solution is u = -2, r = 1, defining the number v = -2 + √3. (Don’t worry about the sign of u, I chose it to have the smallest possible v > 1, but we can change the signs of u and r in the equation).

The reason for this is that if α = u + r√3 gives a solution of [1], then αv gives another solution, and it can be proved that all integer solutions arise in this way. Indeed, we have:

(u + r√3)(u – r√3)(-2 + √3)(-2 – √3) = -83

(u + r√3)(-2 + √3)(u – r√3)(-2 – √3) = -83

((-2u+3r) + (u – 2r)√3)((-2u+3r) – (u – 2r)√3) = -83

and this shows that β = (-2u+3r) + (u – 2r)√3 gives another solution. Now, as the ring of integers is ℤ[√3], and (obviously) -83 is an (algebraic) integer, all rational solutions of [1] are the integer solutions. In particular, the largest possible denominator of x = (u + 5)/6 is 6.

The procedure to find all solutions is therefore as follows. Starting with one solution u[1], r[1] of [2], we find all solutions using the recurrence relations:

u[n+1] = -2u[n] + 3r[n]

r[n+1] = u[n] -2r[n]

As we can change the signs of u and r in [2], each solution gives two values for x : (± u + 5)/6. (You could also change the sign of the radical in v, but that will give you the same solutions in a different order.)

All that remains to do is to find at least one solution of [1]. In this case, we are lucky, because, in the derivation of [1], 83 arose as 3*6² – 5², which means that u = 5, r = 6 is a solution. This solution gives the values x = 5/3 and x = 0, corresponding to q = 3. (Alternately, you could simply notice that x = 0 is a solution, and work backwards to find u and r).

Using the recurrence relations above, we find that the next solution is u = 8, r = -7, giving the solutions x = 13/6 and x = -½, with q = 7/2.

Please feel free to write back if you require further assistance.

Doctor Jacques

Doctor Jacques previously answered a similar problem in a similar way, which you can read at Quadratic Diophantine Equation. Some details that he skipped over here can be seen there.

For ease of comparison with what will follow, let me change notation, using y in place of his q. He is finding rational solutions (x, y) of the equation 3x² – 5x + 9 = y²; his first solutions are (5/3, 3) and (0, 3), which are obtained from u = 5, r = 6 by the equations x = (± u + 5)/6 and y = r/2.  Then he finds subsequent pairs (u, r) using the recurrence relation, so that the next pair is (-2u + 3r, u – 2r).  The second solution is therefore that u = -2(5) + 3(6) = 8, and r = (5) – 2(6) = -7, from which he gets x = (±8 + 5)/6 = 13/6 or -1/2, and y = -7/2. So these solutions are (13/6, -7/2) and (-1/2, -7/2). We can check these, and verify that they work.

It turned out that Josh didn’t have the background to follow the deeper number theory parts that justify the work, but could follow the main ideas:

Thank you very much Jacques!

I am currently a second year college student studying Mathematics. I am currently taking Calc 3. I have also taken Discrete Mathematics where we touched on ℤ, ℚ, and other simple sets of numbers. I ‘m unfamiliar with the term rings. Other than that the math behind everything seems logical. I’ll just have to do some studying on rings to understand working with ℚ[√3].

Second solution: Intersections with a rational slope

But Doctor Vogler saw that this method doesn’t give all solutions; he took an entirely different approach, applying conclusions that had been explained in a previous answer of his:

Hi Josh,

I think that Doctor Jacques’ solution will only give you solutions where u and r are integers. For rational solutions, I would suggest using the method I described in this answer from the Ask Dr. Math archives:

Rational Solutions to Two Variable Quadratic Equation

In your case, there is an obvious solution at x = 0, y = 3. So every other solution (r, s) will lie on a line

y = x(s-3)/r + 3

with rational slope and which passes through the point (0, 3). Conversely, every line y = mx + 3 with rational slope and which passes through the point (0, 3) will intersect your quadratic curve

3x^2-5x+9 = y^2

at exactly two points. One of those two points is (0, 3), which means that we can solve for the other:

3x^2-5x+9 = (mx+3)^2

3x^2-5x+9 = m^2*x^2+6mx+9

3x^2-5x = m^2*x^2+6mx

(3-m^2)x^2-(5+6m)x = 0

((3-m^2)x-(5+6m))x = 0

So one solution is x = 0, which we already knew, and the other is

x = (5+6m)/(3-m^2)

and then we can solve for y = mx+3

y = (9+5m+3m^2)/(3-m^2)

So every rational solution has this form for some rational number m, and every rational m gives you a rational solution. Of course, there are other formulas that also have this property; for example, you could replace m by t+1 and get a new formula with the same properties.

Doctor Vogler

So whereas Doctor Jacques’ solution consisted of a sequence of pairs obtained by a recurrence, Doctor Vogler’s is a parametric solution giving a pair for every rational number m.

Incidentally, Doctor Vogler has discussed integer solutions of Pell equations here, using the same ideas as Doctor Jacques:

Solving with the Pell Equation

Pell Pairs of Positive Integer Solutions

Do the two solutions agree?

I have an immediate, obvious question: are they the same solution? If Doctor Vogler is right, his solution should include pairs that can’t be obtained from Doctor Jacques’ solution, but the latter should all be obtainable from the former.

I put Doctor Jacques’ answer into a spreadsheet (starting with the sequence of u and r, obtaining x and y from them, and verifying the equation. Then I obtained m from x and y, using the fact that y = mx + 3, so that m = (y – 3)/x.

Then I put in Doctor Vogler’s answer, using these values of m, and obtained the same (x, y) pairs, also finding (u, r) from each to go full circle. This demonstrated that the latter solution includes all of the former; the one little surprise was that the solution (0, 3), arising from u = 5, r = 6, yields an indeterminate (0/0) value for m; so I had to get m in a different way, using x = (5+6m)/(3-m^2) to determine that if x = 0, m = -5/6. (This is not really a surprise once you think about it!)

Finally, I chose some other values for m, to see what happened; for example, with m = 1/2, I get (32/11, 49/11). From this solution, I found that u = 6x – 5 = 137/11, and r = 2y = 98/11. This confirms that we can have non-integer values for u and r; and clearly the recurrence relation will only obtain integer values. So Doctor Vogler was right about the incompleteness of that solution.

Although our typical interaction with a student involves just one Math Doctor answering, when more than one of us gets involved, approaching a problem from multiple perspectives, it often enriches the result. We don’t think of ourselves as rivals, but as colleagues working together, occasionally correcting one another, more often supplementing, and often learning from one another.

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.