Sub topic 10
Perfect-square discriminants and rational roots
This chapter assumes you can compute the discriminant b² − 4ac and apply the quadratic formula. It also assumes you can simplify a radical such as √72 to 6√2. Here you will learn to tell, before you finish solving, whether the roots are rational numbers, and to use that fact to factor and to check your work.
The core fact
A rational number is a number that can be written as a fraction of two integers. Start from the quadratic formula for ax² + bx + c = 0:
x = (−b ± √d) / (2a), where d = b² − 4ac
Suppose a, b and c are integers (or rational numbers). Then −b, 2a and d are all rational. Everything in the formula is rational except possibly √d. This gives a clean rule.
- The roots are rational exactly when √d is rational.
- For an integer d ≥ 0, √d is rational exactly when d is a perfect square, meaning d = k² for some integer k.
The second statement holds because the square root of an integer is either an integer or irrational. There is no in-between case. So you do not need to compute any decimals. You only need to decide whether d is a perfect square.
What each case looks like
When a, b and c are integers, the discriminant sorts the equation into four cases.
| Discriminant d | Roots | Example | Result |
|---|---|---|---|
| Positive perfect square | Two distinct rational roots | x² − 5x + 6 = 0, d = 1 | 2 and 3 |
| Positive, not a perfect square | Two distinct irrational real roots | x² − 2x − 1 = 0, d = 8 | 1 ± √2 |
| Zero | One repeated rational root | x² − 4x + 4 = 0, d = 0 | 2 |
| Negative | Two non-real complex roots | x² + 2x + 5 = 0, d = −16 | −1 ± 2i |
Zero counts as a perfect square (0 = 0²). That is why a repeated root of an integer-coefficient quadratic is always rational: it equals −b/(2a).
A full worked example
Solve 6x² + x − 2 = 0.
- Read off a = 6, b = 1, c = −2.
- Compute d = 1² − 4(6)(−2) = 1 + 48 = 49.
- Since 49 = 7², the roots are rational.
- Apply the formula: x = (−1 ± 7) / 12.
- The two roots are 6/12 = 1/2 and −8/12 = −2/3.
Check by substitution. For x = 1/2: 6(1/4) + 1/2 − 2 = 1.5 + 0.5 − 2 = 0. For x = −2/3: 6(4/9) − 2/3 − 2 = 8/3 − 2/3 − 2 = 0. Both work.
Why this connects to factoring
A root r of the quadratic gives a factor (x − r). Rational roots therefore give factors with rational coefficients. For the example above, the roots 1/2 and −2/3 give
6x² + x − 2 = 6(x − 1/2)(x + 2/3) = (2x − 1)(3x + 2)
You can verify the last form by expanding: 6x² + 4x − 3x − 2 = 6x² + x − 2.
This gives a practical test. For integer coefficients, the quadratic factors into two linear factors with integer coefficients exactly when d is a perfect square. You can use the discriminant to decide whether a factoring attempt is worth your time. If d = 8, no amount of trial and error will produce integer factors.
The reverse also holds. Take x² − 2x − 1, where d = 8. The roots are 1 + √2 and 1 − √2. The quadratic still factors, but only with irrational coefficients: (x − 1 − √2)(x − 1 + √2).
The decision as a flow
Preparing the equation
The test needs integer (or at least rational) coefficients. If an equation has fractions, multiply through by a common denominator first. Multiplying by a nonzero constant does not change the roots.
Take (1/2)x² − (1/6)x − 1/3 = 0. Multiply every term by 6 to get 3x² − x − 2 = 0. Then d = 1 + 24 = 25 = 5², and x = (1 ± 5)/6. The roots are 1 and −2/3. Substituting x = 1 into the original equation gives 1/2 − 1/6 − 1/3 = 0, as expected.
The equation must also be in standard form before you read off a, b and c. If you start from 2x² = 3 − 5x, move everything to one side to get 2x² + 5x − 3 = 0. Then d = 25 + 24 = 49, which is a perfect square, and x = (−5 ± 7)/4 gives 1/2 and −3.
Quick screens for perfect squares
For small discriminants you can recognize squares by memory (1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, ...). For larger values, two fast screens help you rule a number out.
- Last digit. A perfect square ends in 0, 1, 4, 5, 6 or 9. A discriminant ending in 2, 3, 7 or 8 cannot be a perfect square. This is why d = 8 fails at once.
- Remainder mod 4. Because d = b² − 4ac, the remainder of d on division by 4 equals that of b². A square leaves remainder 0 or 1 when divided by 4. So an integer d that is a discriminant is always 0 or 1 mod 4. A value of 2 or 3 mod 4 means you made an arithmetic error.
These screens can only rule numbers out. A number ending in 9, such as 29, may still not be a square. To confirm, estimate the square root and test the nearest integers: 29 lies between 5² = 25 and 6² = 36, so it is not a square.
Checking candidates with the rational root theorem
There is a second route to rational roots that does not need the discriminant. If a rational number p/q in lowest terms is a root of an integer-coefficient quadratic, then p divides c and q divides a. For 6x² + x − 2, the possible p are ±1 and ±2, and the possible q are 1, 2, 3 and 6. That gives a short list of candidates such as ±1/2 and ±2/3. The roots 1/2 and −2/3 are both on it.
The discriminant is usually quicker, because it answers yes or no with one calculation. The candidate list becomes useful for higher-degree polynomials, where no discriminant formula as simple as this one exists.
Checking it in code
Python's math.isqrt returns the integer square root exactly, so it avoids the rounding problems of math.sqrt when you test for perfect squares. The fractions.Fraction type keeps the roots exact.
from fractions import Fraction
from math import isqrt
def rational_roots(a, b, c):
"""Return the rational roots of ax^2 + bx + c = 0 for integer a, b, c.
Returns None when the roots are not rational.
"""
if a == 0:
raise ValueError("a must be nonzero")
d = b * b - 4 * a * c
if d < 0:
return None
s = isqrt(d)
if s * s != d:
return None
roots = {Fraction(-b - s, 2 * a), Fraction(-b + s, 2 * a)}
return sorted(roots)
for coeffs in [(6, 1, -2), (1, -2, -1), (1, -4, 4), (1, 2, 5)]:
result = rational_roots(*coeffs)
print(coeffs, None if result is None else [str(r) for r in result])The output is:
(6, 1, -2) ['-2/3', '1/2']
(1, -2, -1) None
(1, -4, 4) ['2']
(1, 2, 5) NoneUsing a set removes the duplicate when d = 0, so a repeated root is reported once. The function returns None for both irrational and complex roots. It answers only the question "are there rational roots?", not "are there real roots?".
Gotchas
The coefficients must be rational
The rule "perfect-square discriminant means rational roots" depends on a, b and c being rational. If they are not, it fails. Consider x² − 2√2·x + 2 = 0. Here d = 8 − 8 = 0, which is a perfect square, yet the repeated root is x = √2, which is irrational. Always check the coefficients before you apply the test.
A rational perfect square need not be an integer
If the coefficients are fractions, d may be a fraction such as 9/4 = (3/2)². This is why the cleanest approach is to clear fractions first, so that you only have to ask whether an integer is a perfect square.
Do not test the decimal
A calculator may show √d as 7 when d is 49, but it may also show 4.000000001 for a number that is not a square, or round a long decimal so that a non-square looks like a square. For large d, use exact integer arithmetic, as isqrt does above.
Rational roots are not always integers
The roots 1/2 and −2/3 above are rational but not integers. If you expect integer roots and the discriminant is a perfect square, check the numerators: the roots are integers only when 2a divides −b ± √d.
Irrational roots come in pairs
For integer coefficients and a non-square d, the roots have the form p + q√r and p − q√r, with p and q rational. They are conjugates of each other. If one root is 1 + √2, the other must be 1 − √2, so you can never get exactly one irrational root from an integer-coefficient quadratic.
Exercises
Exercise
Without solving the equation, decide whether 5x² − 7x − 6 = 0 has rational roots. Then find the roots and check one of them.
Show answer
With a = 5, b = −7, c = −6, d = 49 − 4(5)(−6) = 49 + 120 = 169 = 13², so the roots are rational. Then x = (7 ± 13)/10, giving x = 2 and x = −3/5. Check x = 2: 5(4) − 14 − 6 = 0. Check x = −3/5: 5(9/25) + 21/5 − 6 = 9/5 + 21/5 − 6 = 6 − 6 = 0.
Exercise
For which positive integers k does x² + 3x + k = 0 have rational roots?
Show answer
The discriminant is d = 9 − 4k. We need d to be a perfect square that is at least 0. Since 4k ≥ 4 for positive k, d ≤ 5, so the only perfect squares available are 0, 1 and 4. The value 9 − 4k is odd, so it cannot be 0 or 4. Setting 9 − 4k = 1 gives k = 2. For k = 2 the roots are x = (−3 ± 1)/2, which are −1 and −2. So k = 2 is the only positive integer that works.
Exercise
The equation x² − 2x − 1 = 0 has d = 8, so its roots are irrational. Without computing decimals, explain why x = 1 + √2 being a root forces 1 − √2 to be a root too, and say what rule this illustrates.
Show answer
The formula gives the roots (2 ± √8)/2 = 1 ± √2. The two roots differ only in the sign in front of √d, so one irrational root always comes with its conjugate. This illustrates the rule that, for rational coefficients and a non-square d, the irrational roots come in conjugate pairs p + q√r and p − q√r.