The Square Root Method
When a quadratic equation has no term, such as , or is already written as a square equal to a number, such as , the fastest solution is to take the square root of both sides. The only thing to remember is that a positive number has two square roots, one positive and one negative.
The basic rule
on its own means the non-negative root (Square Roots), so , not . The comes from the equation: both and .
Isolate the square first
(The last equation has the complex solutions ; see The Discriminant and Complex Roots.)
Note: Do not take the square root term by term. does not give . Isolate first: , .
A squared binomial
If the equation is , take the root of both sides and then solve the two linear equations:
This is the last step of completing the square, which turns any quadratic into this form. It is also why the quadratic formula has a .
Simplify the radical when you can (Simplifying Radicals): gives .
In Python
math.sqrt returns the non-negative root, so the code adds the minus version itself. For whole numbers, math.isqrt gives an exact integer square root and lets you tell whether the answer is a whole number:
import math
def solve_square(a, c):
"""Solve a·x² + c = 0."""
k = -c / a
if k < 0:
return []
if k == 0:
return [0.0]
r = math.sqrt(k)
return [-r, r]
print(solve_square(3, -48))
print([round(x, 4) for x in solve_square(2, -14)])
print(solve_square(1, 9))
for n in [16, 50, 1_000_000_007 ** 2]:
r = math.isqrt(n)
print(n, "perfect square" if r * r == n else "not a perfect square", r)[-4.0, 4.0]
[-2.6458, 2.6458]
[]
16 perfect square 4
50 not a perfect square 7
1000000014000000049 perfect square 1000000007
math.isqrt works on integers of any size without rounding, which math.sqrt (a float) cannot do for numbers beyond about .
SymPy gives exact, simplified roots:
import sympy as sp
x = sp.symbols("x")
print(sp.solve(sp.Eq(x**2, 50), x))
print(sp.solve(sp.Eq((2*x + 1)**2, 5), x))
print(sp.solve(x**2 + 9, x))[-5*sqrt(2), 5*sqrt(2)]
[-1/2 + sqrt(5)/2, -sqrt(5)/2 - 1/2]
[-3*I, 3*I]
In software
- Time to fall. An object dropped from rest falls , so the time to fall a height is . Only the positive root is a time. A game uses this to time a falling-platform sound or to decide whether a character can survive a drop.
- Circle and sphere tests. A point is on a circle of radius around the origin when . Given , the square root method gives the two values , which is how code draws a circle one column at a time.
- Skip the root. To compare distances, compare squared distances: is the same test as (both sides are non-negative) and avoids a
sqrtcall in a hot loop. Collision code does this everywhere (collision geometry).
import math
g = 9.81
for d in [1.0, 5.0, 20.0]:
print(f"fall {d:4.1f} m takes {math.sqrt(2 * d / g):.3f} s")
r = 5
print("circle points at x = 3:", (3, math.sqrt(r*r - 3*3)), (3, -math.sqrt(r*r - 3*3)))
dx, dy = 3.0, 4.5
print("inside radius 5?", dx*dx + dy*dy < r*r)fall 1.0 m takes 0.452 s
fall 5.0 m takes 1.010 s
fall 20.0 m takes 2.019 s
circle points at x = 3: (3, 4.0) (3, -4.0)
inside radius 5? False
Exercises
Exercise 1: Isolate and solve
Solve .
Answer
Solution
, , .
Exercise 2: Irrational roots
Solve and simplify the radical.
Answer
Solution
Exercise 3: Squared binomial
Solve .
Answer
or
Solution
Exercise 4: No real solution?
Which of these have real solutions? (a) (b) (c)
Answer
(b) has one solution ; (c) has ; (a) has none.
Solution
Exercise 5: How high was the drop?
A dropped phone hits the floor after 0.55 s. Use with to find the height, then solve back for from that height in code to check.
Answer
About 1.484 m.
Solution
import math
g, t = 9.81, 0.55
d = 0.5 * g * t * t
print("height:", round(d, 4), "m")
print("time back from height:", round(math.sqrt(2 * d / g), 4), "s")height: 1.4838 m
time back from height: 0.55 s
Test yourself
Solve .
What is the first step to solve ?
- Take the square root of both sides
- Subtract 7 from both sides
- Divide by
- Factor 39
Solve .
- or
- only
- or