Sub topic 1
Perfect Squares and What a Square Root Undoes
Prerequisites
This chapter assumes you can do the following:
- Multiply and divide integers and fractions.
- Use exponents and square a number, such as 7² = 49.
- Find prime factorizations and factor pairs.
- Read basic algebraic expressions with variables.
- Solve linear equations and simple quadratic equations.
The code examples use Python 3.8 or later, because they rely on math.isqrt.
Squaring and the idea of undoing it
To square a number is to multiply it by itself. Squaring 6 gives 6 · 6 = 36, written 6² = 36. The name comes from geometry. A square with side length 6 has area 36.
A square root runs this process backward. If squaring turns 6 into 36, a square root of 36 is a number that turns back into 36 when squared. You start with the area and ask for the side length.
A number r is a square root of n if r² = n. For n = 36 there are two such numbers, 6 and −6, because both (6)² and (−6)² equal 36. The next chapter explains how the radical symbol picks one of them. For now, remember that squaring loses information about sign. Undoing it needs a convention.
Perfect squares
A perfect square is an integer that is the square of an integer. The first fifteen positive perfect squares are worth memorizing, since you will recognize them constantly when simplifying radicals.
| n | n² |
|---|---|
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
| 4 | 16 |
| 5 | 25 |
| 6 | 36 |
| 7 | 49 |
| 8 | 64 |
| 9 | 81 |
| 10 | 100 |
| 11 | 121 |
| 12 | 144 |
| 13 | 169 |
| 14 | 196 |
| 15 | 225 |
Some details are easy to get wrong:
- 0 and 1 count. 0² = 0 and 1² = 1, so both are perfect squares.
- Negative integers are not perfect squares. A real number squared is never negative, so no real number r satisfies r² = −4.
- The word "perfect" refers to the integer root. The number 2 is not a perfect square, but it still has square roots. They just are not integers.
- Fractions and decimals can be perfect squares too. 9/16 is the square of 3/4, and 0.25 is the square of 0.5. In most simplifying work, though, "perfect square" means a whole number.
Patterns that help you spot them
Perfect squares grow by consecutive odd numbers. The gap from 1 to 4 is 3, from 4 to 9 is 5, from 9 to 16 is 7, and so on. This works because (n + 1)² − n² = 2n + 1.
The last digit also gives a quick filter. A perfect square can only end in 0, 1, 4, 5, 6, or 9. So 2,837 cannot be a perfect square, because it ends in 7. The test only rules numbers out. A number ending in 4 or 9, such as 14 or 19, can still fail to be a perfect square.
What a square root undoes
Squaring and taking a square root are inverse operations on non-negative numbers. Squaring 5 gives 25, and the square root of 25 returns 5. Going the other direction also works, since the square root of 49 is 7 and 7² is 49.
The diagram shows why the inverse is not perfect. Two different inputs, 5 and −5, land on the same output, 25. Once you have 25, nothing records which one you started with. Whatever rule you pick for the square root must return a single answer. The convention is that it returns the non-negative one. Later chapters develop this into the identity √(x²) = |x|.
Working in both directions
The rule has two parts:
- If a ≥ 0, then (√a)² = a. Squaring undoes the root.
- If a ≥ 0, then √(a²) = a. The root undoes squaring.
Part 2 is where mistakes happen. With a = −3, the expression a² is 9, and the root of 9 is 3, which is not −3. So the second statement requires a to be non-negative. For arbitrary a, the correct statement is √(a²) = |a|.
Testing for perfect squares
You have several ways to decide whether n is a perfect square.
Memorized list. For small numbers, compare n against the table above.
Prime factorization. A positive integer is a perfect square exactly when every prime in its factorization has an even exponent. This works because squaring doubles every exponent. For example:
- 144 = 2⁴ · 3². Both exponents are even, so 144 is a perfect square, and 144 = (2² · 3)² = 12².
- 180 = 2² · 3² · 5¹. The exponent of 5 is odd, so 180 is not a perfect square.
This idea is the foundation for simplifying radicals later. The even part of a factorization can be pulled out of a root. The odd leftover stays inside.
Computation. Take the integer square root and square it. If you get n back, n is a perfect square.
import math
for n in [49, 50, 2]:
r = math.isqrt(n)
print(n, 'perfect square' if r * r == n else 'not a perfect square', r, math.sqrt(n))Running it prints:
49 perfect square 7 7.0
50 not a perfect square 7 7.0710678118654755
2 not a perfect square 1 1.4142135623730951math.isqrt(n) returns the largest integer r with r² ≤ n. For 50 that is 7, since 7² = 49 ≤ 50 < 64 = 8². The last column, math.sqrt(n), is a floating-point approximation of the true root.
Here is the factorization test as a function:
def is_perfect_square_by_factors(n):
"""True when every prime in n's factorization has an even exponent."""
if n < 0:
return False
if n < 2:
return True # 0 and 1 are perfect squares
f = 2
while f * f <= n:
count = 0
while n % f == 0:
n //= f
count += 1
if count % 2 == 1:
return False
f += 1
return n == 1 # a leftover n > 1 is a prime with exponent 1
for n in [144, 180, 0, 1, 49, 50]:
print(n, is_perfect_square_by_factors(n))It prints True for 144, 0, 1, and 49, and False for 180 and 50. After the loop ends, any remaining n greater than 1 is a single prime that appears once, which is an odd exponent. That is why the function ends with return n == 1.
Edge cases to keep straight
| Input | Square root in the reals | Notes |
|---|---|---|
| 0 | 0 | The only number with exactly one square root. |
| 1 | 1 (and −1) | Perfect square. Its principal root is 1. |
| Positive non-square, such as 2 | Exists, not an integer | Two roots, ±1.414…, neither a whole number. |
| Negative, such as −4 | None | No real number squares to a negative. |
| Fraction 9/16 | 3/4 | Take the root of numerator and denominator. |
| Decimal 0.04 | 0.2 | Check by squaring: 0.2 × 0.2 = 0.04. |
Three more points are worth noticing:
- Counting roots. Every positive number has two real square roots, one positive and one negative. Zero has one. Negative numbers have none among the real numbers. (Complex numbers extend this, but that is outside this tutorial.)
- Solving x² = 9. The equation has two solutions, x = 3 and x = −3. This differs from asking for "the square root of 9," which names one number, 3. Students often mix up these two questions.
- Library behavior. Python's
math.isqrt(-1)andmath.sqrt(-1)both raiseValueError. The error matches the mathematics, which is that no real answer exists.
Why this matters for later chapters
Nearly everything ahead depends on the skills here. Estimating a root such as √50 means finding the perfect squares on either side, 49 and 64. Simplifying √72 means spotting the perfect-square factor 36 inside it, so you need the table of squares memorized and the even-exponent idea ready. And the non-negative convention is what makes the absolute value appear when variables show up under a radical.
A short summary of the working model:
- Squaring multiplies a number by itself. A square root searches for numbers that give a target when squared.
- Perfect squares are the integers that have integer square roots.
- Even exponents in the prime factorization identify perfect squares.
- Squaring loses the sign, so undoing it requires a convention. That convention is the subject of the next chapter.
Exercise
Decide whether each number is a perfect square, and justify your answer using prime factorization: (a) 225, (b) 252, (c) 1,296.
Show answer
(a) 225 = 3² · 5². Both exponents are even, so it is a perfect square, and 225 = 15². (b) 252 = 2² · 3² · 7¹. The exponent of 7 is odd, so it is not a perfect square. (c) 1,296 = 2⁴ · 3⁴. Both exponents are even, so it is a perfect square, and 1,296 = (2² · 3²)² = 36².
Exercise
A student writes √((−7)²) = −7 because "the root cancels the square." What is wrong, and what is the correct value? Also, how many real solutions does x² = 49 have?
Show answer
The cancelling rule √(a²) = a only holds when a ≥ 0. Here (−7)² = 49, and the non-negative square root of 49 is 7, so √((−7)²) = 7 = |−7|. The equation x² = 49 has two real solutions, x = 7 and x = −7, because both square to 49.
Exercise
Without a calculator, name the two consecutive perfect squares that surround 150, and give the value of math.isqrt(150) in Python.
Show answer
12² = 144 and 13² = 169, so 144 ≤ 150 < 169. The function math.isqrt(150) returns the largest integer whose square is at most 150, which is 12.