When the discriminant is negative, the quadratic formula needs the square root of a negative number, and i supplies it: the roots come as a mirror-image pair p + qi and p − qi. The same mirror image, the conjugate, is how complex numbers are divided.
Solve a quadratic with a negative discriminant, giving its two complex roots p + qi and p − qi, and check them by substitution.
Explain why the two roots are conjugates, mirror images in the real axis, whose real part is the x-coordinate of the vertex.
Show that a complex number times its conjugate is the square of its modulus, and use that to divide complex numbers.
Solve quadratics in Python with cmath.sqrt and numpy.roots, and explain why math.sqrt refuses a negative number.
In review. The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
The question
The parabola \({x^2 - 4x + 3}\) of lesson M01.3.3 crosses the \(x\)-axis at 1 and 3. Lift it by 2 and it clears the axis: \({x^2 - 4x + 5}\) has no real zeros, and the quadratic formula of M01.3.3 stopped there. Yet NumPy, asked for its roots, prints [2.+1.j 2.-1.j]. It does the same for the course’s loss \({L(w)}\), which is \({7.5w^2 - 21w + 14.75}\), printing two roots that both start with 1.4 and carry a small multiple of j. Where do these roots come from, and do they tell us anything about the parabola, or about the best slope of the course’s line?
From the last lesson
1. What are the modulus and the argument of \({-2}\)?
Show answer
The modulus is 2 and the argument is \(\pi\): the point lies on the negative real axis, a half turn from the positive one. So \({-2 = 2e^{i\pi}}\), and its square roots will need \(i\).
2. What is \(e^{i\pi}\)?
Show answer
\({\cos\pi + i\sin\pi = -1}\): the point of the unit circle half a turn round from 1.
Intuition
The quadratic formula of M01.3.3 needs the square root of the discriminant \({D = b^2 - 4ac}\). For \({x^2 - 4x + 5}\) that is \({16 - 20 = -4}\), and on the number line \({-4}\) has no square root. Among the complex numbers it has two: \({(2i)^2 = 4i^2 = -4}\), and \({(-2i)^2 = -4}\) as well. Let the formula use them:
\[
x = \frac{4 \pm 2i}{2} = 2 \pm i .
\]
M01.9.4-F1
The lifted parabola misses the \(x\)-axis, so it has no real zeros. Its two roots, \({2 + i}\) and \({2 - i}\), live in the complex plane: mirror images in the real axis, with the real part 2 of the vertex.
The two roots are not on the graph, because the graph shows only real inputs \(x\). They live in the complex plane, one above the real axis and one below it: mirror images. And the graph does leave a trace of them. Their shared real part, 2, is the \(x\) of the vertex, and the higher the vertex sits above the axis, the further apart the two roots are.
Build it up
Step 1. Square roots of a negative number. Take a positive number \(d\). Then \({(i\sqrt{d})^2 = i^2 d = -d}\), and \({(-i\sqrt{d})^2 = -d}\) too, so \({-d}\) has the square roots \(i\sqrt{d}\) and \({-i\sqrt{d}}\). There are no others. If \({s^2 = -d}\), then \({s^2 - (i\sqrt{d})^2 = 0}\), and the difference of two squares, \({(s - t)(s + t) = s^2 - t^2}\) from exercise 3 of M01.1.2, factors this:
\[
(s - i\sqrt{d})(s + i\sqrt{d}) = 0 .
\]
A product of two complex numbers can only be 0 if one of them is 0, because the length of a product is the product of the lengths (M01.9.2). So \({s = i\sqrt{d}}\) or \({s = -i\sqrt{d}}\). We write \({\sqrt{-d}}\) for the first, the one above the real axis: \({\sqrt{-4} = 2i}\).
Step 2. The formula with \({D < 0}\). Put \({\sqrt{D} = i\sqrt{-D}}\) into the quadratic formula and split the top in two:
So the roots are \({p + qi}\) and \({p - qi}\), with \({p = -\frac{b}{2a}}\) and \({q = \frac{\sqrt{-D}}{2a}}\). For \({x^2 - 4x + 5}\): \({p = \frac{4}{2} = 2}\) and \({q = \frac{\sqrt{4}}{2} = 1}\).
Step 3. Conjugates. The two roots differ only in the sign of the imaginary part. The conjugate of \({z = a + bi}\) is \({z^* = a - bi}\), read “z star”. Many textbooks write it with a bar, \(\bar{z}\); this course keeps the bar for means (M01.1.4). In the plane, \(z^*\) is the mirror image of \(z\) in the real axis: the same length, and the opposite angle.
Step 4. A number times its conjugate is real. Multiply out:
\[
\begin{aligned}
z\,z^* &= (a + bi)(a - bi) \\
&= a^2 - abi + abi - b^2 i^2 \\
&= a^2 + b^2 = \abs{z}^2 .
\end{aligned}
\]
The picture says the same: the lengths multiply to \(\abs{z}^2\), and the angles \(\theta\) and \({-\theta}\) add to 0, so the product lies on the positive real axis. For \({z = 3 + 4i}\): \({(3 + 4i)(3 - 4i) = 9 + 16 = 25}\). The sum is real too: \({z + z^* = 2a}\).
M01.9.4-F2
A number and its conjugate are mirror images in the real axis. Their product multiplies the lengths, \({5 \times 5}\), and the angles cancel, so it is the real number 25.
Step 5. Dividing. Since \({z\,z^* = \abs{z}^2}\), the number \(z^* / \abs{z}^2\) times \(z\) is \({\abs{z}^2 / \abs{z}^2 = 1}\). So dividing by \(z\) is multiplying by
In the plane, \(\frac{1}{z}\) has length \(\frac{1}{5}\) and angle \({-53.13^\circ}\): it undoes both the stretch and the turn of \(z\). To divide \(u\) by \(z\), multiply \(u\) by \(\frac{1}{z}\).
The formal statement
NoteDefinitions and results
The conjugate of \({z = a + bi}\) is \({z^* = a - bi}\). For every \(z\), \({z\,z^* = \abs{z}^2}\) and \({z + z^* = 2\operatorname{Re} z}\), both real; for \({z \neq 0}\), \({\frac{1}{z} = \frac{z^*}{\abs{z}^2}}\).
Quadratics. Let \({a \neq 0}\), \(b\) and \(c\) be real, with \({D = b^2 - 4ac < 0}\). Then \({ax^2 + bx + c = 0}\) has the two complex roots \({p + qi}\) and \({p - qi}\), where
\[
p = -\frac{b}{2a}, \qquad q = \frac{\sqrt{-D}}{2a} .
\]
They are conjugates, and \(p\) is the \(x\)-coordinate of the vertex.
Why, from the completed square. Lesson M01.3.3 wrote the quadratic as \({a(x - h)^2 + k}\) with \({h = -\frac{b}{2a}}\), and found that a root must solve
\[
(x - h)^2 = \frac{D}{4a^2} .
\]
When \({D < 0}\), the right-hand side is a negative number, \({-\frac{-D}{4a^2}}\). By Step 1 its square roots are \({\pm i\frac{\sqrt{-D}}{\sqrt{4a^2}}}\), and \(\sqrt{4a^2}\) is \(2a\) or \({-2a}\), whichever is positive; with \(\pm\) in front, both give the same pair. So \({x = h \pm \frac{\sqrt{-D}}{2a}i}\), as claimed. (If \(a\) is negative, \(q\) is negative and the same two roots come out in the other order.)
A second way to read the same pair: \(\frac{D}{4a^2}\) equals \({-\frac{k}{a}}\), so the roots are \({h \pm i\sqrt{k/a}}\). The real part is where the vertex is. For a parabola that opens upwards (\({a > 0}\)), the imaginary part grows with \(k\), the height of the vertex above the axis.
Every quadratic has two roots. With a positive discriminant there are two real roots; with a zero one, a single root counted twice, where the vertex touches the axis; with a negative one, a conjugate pair. So in \(\mathbb{C}\) every quadratic has exactly two roots, counting a repeated root twice. The fundamental theorem of algebra says the same for every degree: a polynomial of degree \({d \geq 1}\) has \(d\) roots in \(\mathbb{C}\), counting repeats (Beck and others, Theorem 1.1.4). Its proof needs far more than this course, so it is stated here, not proved.
A family whose roots lie on the unit circle. Take \({x^2 - 2\cos\theta\,x + 1}\), for an angle \(\theta\) whose sine is not 0. Here \({a = 1}\), \({b = -2\cos\theta}\) and \({c = 1}\), so
using \({\cos^2\theta + \sin^2\theta = 1}\) (M01.5.2). That is negative, \({p = \cos\theta}\) and \({q = \frac{\sqrt{4\sin^2\theta}}{2}}\), which is \(\sin\theta\) up to its sign. So the two roots are \({\cos\theta + i\sin\theta}\) and \({\cos\theta - i\sin\theta}\): the points \(e^{i\theta}\) and \({e^{-i\theta}}\) of M01.9.3. Lesson M03.1 meets this quadratic again: its roots are the eigenvalues of a rotation of the plane by \(\theta\), which is why NumPy reports complex eigenvalues for a rotation.
M01.9.4-F5
For \({\theta = 60^\circ}\) the roots are \(e^{i\theta}\) and \({e^{-i\theta}}\), a conjugate pair on the unit circle whose real part is \({\cos\theta = 0.5}\).
Worked example
Solve \({x^2 - 4x + 5 = 0}\), and check the answer two ways.
Here \({a = 1}\), \({b = -4}\) and \({c = 5}\), so the discriminant is \({D = (-4)^2 - 4 \times 1 \times 5}\), which is \({16 - 20 = -4}\). It is negative, so there is no real root. Its square root is \({\sqrt{-4} = 2i}\), because \({(2i)^2 = -4}\). The formula gives
\[
x = \frac{4 \pm 2i}{2} = 2 \pm i .
\]
M01.9.4-F3
The worked example as a trace: discriminant, square root, formula, and the whole top halved.
Check by substitution. For \({2 + i}\): \({(2 + i)^2 = 4 + 4i + i^2 = 3 + 4i}\), so
For \({2 - i}\) every \(i\) changes sign: \({(2 - i)^2 = 3 - 4i}\), and \({(3 - 4i) - (8 - 4i) + 5 = 0}\). (A curiosity: \({(2 + i)^2}\) is the course’s \({3 + 4i}\).)
Check by the sum and the product. M01.3.3 showed that two real zeros add up to \({-\frac{b}{a}}\) and multiply to \(\frac{c}{a}\). A conjugate pair does the same: \({p + qi}\) and \({p - qi}\) add up to \({2p = -\frac{b}{a}}\), and by Step 4 they multiply to \({p^2 + q^2}\), which is \({\frac{b^2 - D}{4a^2}}\); since \({b^2 - D = 4ac}\), that is \(\frac{c}{a}\). Here \({(2 + i) + (2 - i) = 4}\), which is \({-\frac{-4}{1}}\), and \({(2 + i)(2 - i) = 4 - i^2 = 5}\), which is \(\frac{5}{1}\). So \({\big(x - (2 + i)\big)\big(x - (2 - i)\big)}\), multiplied out, is \({x^2 - 4x + 5}\).
The course’s loss. M01.3.3 found \({L(w) = 7.5(w - 1.4)^2 + 0.05}\), with \({D = 441 - 442.5 = -1.5}\). The roots are \({1.4 \pm i\sqrt{0.05/7.5}}\), about \({1.4 \pm 0.0816i}\): the numbers NumPy printed in the hook. Their real part, 1.4, is the best slope; the small imaginary part says that the lowest loss, 0.05, sits only a little above 0. No slope gives a loss of exactly 0, because no line passes through all four points.
Code
A solver from scratch. It computes the discriminant and branches on its sign; a complex root is returned as a pair (real part, imaginary part), as in M01.9.1.
import mathdef solve(a, b, c):"""The two roots of a x^2 + b x + c = 0, each as a pair (real part, imaginary part).""" d = b * b -4* a * c # the discriminant p =-b / (2* a)if d >=0: q = math.sqrt(d) / (2* a)return (p - q, 0.0), (p + q, 0.0) # two real roots (the same one twice when d is 0) q = math.sqrt(-d) / (2* a) # -d is positive, so math.sqrt can take itreturn (p, q), (p, -q) # a conjugate pairprint(solve(1, -4, 3))print(solve(1, -4, 5))first, second = solve(7.5, -21, 14.75)print(round(first[0], 4), round(first[1], 4))
Division on pairs, by the conjugate: multiply the top by the conjugate of the bottom, and divide both parts by the squared length of the bottom.
def multiply(z, u): a, b = z c, d = ureturn (a * c - b * d, a * d + b * c)def conjugate(z):return (z[0], -z[1]) # the mirror image in the real axisdef divide(u, z): top = multiply(u, conjugate(z)) # u times the conjugate of z size = z[0] **2+ z[1] **2# |z| squared, a real numberreturn (top[0] / size, top[1] / size)print(multiply((3, 4), conjugate((3, 4))))print(divide((1, 0), (3, 4)))print(divide((-1, 7), (3, 4)))
(25, 0)
(0.12, -0.16)
(1.0, 1.0)
The last line undoes the product of M01.9.1: \({(-1 + 7i) / (3 + 4i)}\) is \({1 + i}\). Now the library. Python writes \(i\) as j, the cmath module takes square roots of negative numbers, and the complex type has .conjugate() and / built in.
import cmatha, b, c =1, -4, 5root = cmath.sqrt(b * b -4* a * c) # the square root of -4print(root, (-b + root) / (2* a), (-b - root) / (2* a))z =3+4jprint(z.conjugate(), z * z.conjugate(), 1/ z)
2j (2+1j) (2-1j)
(3-4j) (25+0j) (0.12-0.16j)
The math module works with real numbers only, so it refuses a negative input with a ValueError, while cmath answers:
NumPy finds the roots of a polynomial from its coefficients, highest power first. It computes them as the eigenvalues of a small matrix built from the coefficients, which is why complex answers come out naturally. The second line is the family above with \({\theta = 60^\circ}\), where \({2\cos\theta = 1}\):
import numpy as npprint(np.roots([1, -4, 5]))print(np.roots([1, -1, 1]))print(cmath.exp(1j* math.pi /3))
In the turn-and-scale explorer of lesson M01.9.2, drag \(z\) to \({2 + i}\) and \(u\) to \({2 - i}\), the two roots of the worked example. Their product lands on the real axis at \({5 + 0i}\): the angles, about \(26.57^\circ\) and \({-26.57^\circ}\), cancel, and the lengths \(\sqrt{5}\) and \(\sqrt{5}\) multiply to 5. Their sum is \({4 + 0i}\). Those are \(c\) and \({-b}\) of \({x^2 - 4x + 5}\), as the check by the sum and the product said.
Pitfalls
M01.9.4-F4
Wrong beside right. Halving only part of \({4 \pm 2i}\) puts the roots twice as far apart, and substitution catches it.
“\({\frac{4 \pm 2i}{2}}\) is \({2 \pm 2i}\).”
The whole top is divided by 2, not just the 4: the answer is \({2 \pm i}\). Substitution catches the slip. \({(2 + 2i)^2 = 8i}\), so \({(2 + 2i)^2 - 4(2 + 2i) + 5}\) is \({8i - 8 - 8i + 5 = -3}\), not 0.
“\({\sqrt{-4} = -2}\).”
Squaring \({-2}\) gives \(4\), not \({-4}\). No real number squares to a negative number (M01.9.1). The square roots of \({-4}\) are \(2i\) and \({-2i}\), and \({\sqrt{-4}}\) means \(2i\).
“math.sqrt(-4) should give 2j.”
The math module works with real numbers only, so it raises a ValueError; that makes an unexpected negative number fail loudly instead of turning quietly into a complex one. When complex answers are wanted, use cmath.sqrt, which gives 2j.
“The conjugate of \({3 + 4i}\) is \({-3 + 4i}\).”
Only the sign of the imaginary part changes: \({(3 + 4i)^* = 3 - 4i}\), the mirror image in the real axis. The number \({-3 + 4i}\) is the mirror image in the imaginary axis, and \({-3 - 4i}\) is \({-z}\), the half turn.
Check yourself
Recall
1. What are the square roots of \({-9}\)?
Show answer
\(3i\) and \({-3i}\): both square to \({9i^2 = -9}\).
2. Solve \({x^2 + 4 = 0}\).
Show answer
\({x^2 = -4}\), so \({x = 2i}\) or \({x = -2i}\).
3. What is the conjugate of \({-2 + 5i}\), and where is it in the plane?
Show answer
\({-2 - 5i}\): the mirror image of \({-2 + 5i}\) in the real axis.
4. Work out \({(3 + 4i)(3 - 4i)}\).
Show answer
\({9 + 16 = 25}\), which is \({\abs{3 + 4i}^2}\): a number times its conjugate is the square of its length.
1.★ Solve \({x^2 + 2x + 5 = 0}\), and check the roots with their sum and their product.
Show solution
\({D = 4 - 20 = -16}\), and \({\sqrt{-16} = 4i}\). So
\[
x = \frac{-2 \pm 4i}{2} = -1 \pm 2i .
\]
The sum is \({(-1 + 2i) + (-1 - 2i) = -2}\), which is \({-\frac{b}{a}}\). The product is \({(-1)^2 + 2^2 = 5}\), a number times its conjugate, which is \(\frac{c}{a}\).
2.★★ Work out \({\frac{-1 + 7i}{3 + 4i}}\) with the conjugate. Then explain the answer with lengths and angles.
Show solution
Multiply the top by the conjugate of the bottom, and divide by \({\abs{3 + 4i}^2 = 25}\):
and \({\frac{25 + 25i}{25} = 1 + i}\). With lengths and angles: \({-1 + 7i}\) has length \(5\sqrt{2}\) and angle \(98.13^\circ\), and \({3 + 4i}\) has length 5 and angle \(53.13^\circ\). Dividing divides the lengths and subtracts the angles: length \(\sqrt{2}\) and angle \(45^\circ\), which is \({1 + i}\). Division undoes the product of M01.9.1.
3.★★★ A quadratic \({x^2 + bx + c}\) with real \(b\) and \(c\) has the root \({3 + 4i}\). Find \(b\) and \(c\), and explain why the other root must be \({3 - 4i}\).
Show solution
The root \({3 + 4i}\) is not real, so the discriminant cannot be positive or 0, since then both roots would be real. It is negative, and the formula gives the roots as \({p + qi}\) and \({p - qi}\). One of them is \({3 + 4i}\), so \({p = 3}\) and the other is \({3 - 4i}\). Now use the sum and the product:
So the quadratic is \({x^2 - 6x + 25}\). Check: \({D = 36 - 100 = -64}\), \({\sqrt{-64} = 8i}\), and \({\frac{6 \pm 8i}{2} = 3 \pm 4i}\).
Summary card
A negative discriminant gives a mirror-image pair of roots.
M01.9.4-F1
Lifted clear of the axis, two roots in the plane.
If \({D = b^2 - 4ac < 0}\), the roots are \({p \pm qi}\), with \({p = -\frac{b}{2a}}\) and \({q = \frac{\sqrt{-D}}{2a}}\).
The conjugate \({z^* = a - bi}\) is the mirror image of \(z\) in the real axis.
\({z\,z^* = \abs{z}^2}\), so \({\frac{1}{z} = \frac{z^*}{\abs{z}^2}}\); for example \({\frac{1}{3 + 4i} = 0.12 - 0.16i}\).
Every quadratic has two roots in \(\mathbb{C}\), counting a repeated root twice.
Sources and next steps
Sources. Each was opened and checked against this lesson on 12 November 2026.
Jay Abramson and others, Algebra and Trigonometry 2e, Section 2.5 Quadratic Equations, OpenStax. The quadratic formula; its Table 1, where a negative discriminant gives “two complex solutions”; and Example 10, \({x^2 + x + 2 = 0}\), solved as \({\frac{-1 \pm i\sqrt{7}}{2}}\). Section 2.4: the complex conjugate of \({a + bi}\) is \({a - bi}\), and a quotient is found by multiplying the top and the bottom by the conjugate of the bottom.
Matthias Beck, Gerald Marchesi, Dennis Pixton and Lucas Sabalka, A First Course in Complex Analysis, edition 1.6. Theorem 1.1.4, the fundamental theorem of algebra: every nonconstant polynomial of degree \(d\) has \(d\) roots in \(\mathbb{C}\), counting multiplicity. Section 1.3: the conjugate (Definition 1.3.1, written there with a bar) as the reflection in the real axis, \({\abs{z}^2 = z\bar{z}}\) (Proposition 1.3.3), and \({z^{-1} = \bar{z}/\abs{z}^2}\).
Python Software Foundation, math and cmath, Python 3.12 documentation. The math functions cannot be used with complex numbers, and raise ValueError for invalid operations such as sqrt(-1.0), so that an unexpected complex number is caught early; cmath.sqrt returns the square root of a complex number.
NumPy reference, numpy.roots, version 2.5: the roots of a polynomial from its coefficients, highest power first, computed as the eigenvalues of the companion matrix. It belongs to NumPy’s older polynomial tools; the page recommends numpy.polynomial for new code.
Next. This closes the module and the course. Complex numbers return in M03.1, where the roots of \({x^2 - 2\cos\theta\,x + 1}\) appear as the eigenvalues of a rotation, and in the Fourier transform of M10.9.