If you have already studied complex numbers, you may skip this page.
Studying complex numbers requires some foundation in vectors; if you have not studied vectors, please visit the vector page.
Complex Numbers
Introduction
Note
The following introduction is adapted from the People's Education Press High School Mathematics, Version A, Compulsory 2.
From the perspective of equations, whether a negative real number has a square root is whether the equation has a solution; this can in turn be reduced to whether the equation has a solution.
Looking back at the extensions of number sets that we have already seen, we can see that each extension was closely related to practical needs. For example, to measure the diagonal of a square and to address the fact that equations such as have no solution in the rational numbers, people extended the rational number set to the real number set. After this extension, the addition and multiplication operations defined over the real numbers remain consistent with the addition and multiplication operations previously defined over the rational numbers; addition and multiplication both satisfy commutativity and associativity, and multiplication satisfies distributivity over addition.
Following this idea, to solve the problem that equations such as have no solution over the reals, we imagine introducing a new number such that is a solution of , that is, such that .
Think about this: after adding the newly introduced number to the real numbers, we hope that and the real numbers can still be added and multiplied in the same way as real numbers, and that addition and multiplication still satisfy commutativity and associativity, while multiplication satisfies distributivity over addition. What numbers make up the new number system obtained by extending the real number system?
Following the idea above, denote the product of the real number and by , and the sum of the real number and by . Notice that every real number and can be written in the form , so all these numbers belong to the extended number set.
Definition
We define a number of the form , where , as a complex number. Here is called the imaginary unit, and the set of all complex numbers is called the complex number set, denoted by .
A complex number is usually denoted by , namely . This form is called the algebraic form of a complex number. Here is called the real part of the complex number , denoted by , and is called the imaginary part of , denoted by . Unless otherwise specified, .
For a complex number , it is real if and only if ; it is imaginary if ; and it is purely imaginary if and .
The relationships among purely imaginary numbers, imaginary numbers, real numbers, and complex numbers are shown below.
Properties and Operations
Geometric Meaning
We now know that numbers of forms such as are called complex numbers, and we have given their definitions and classifications; we can also explore their deeper properties.
We place all real numbers on the number line and observe that points on the number line correspond one-to-one with real numbers. Let us handle complex numbers in the same way.
First, we define equality of complex numbers: two complex numbers are equal if and only if and .
This definition is quite natural, so we will not explain it further here.
In other words, using the unique ordered pair of real numbers , we can represent a complex number . Thinking of the Cartesian coordinate system, we can see that the set of complex numbers is in one-to-one correspondence with the set of points in the Cartesian coordinate system. Thus, we have found one geometric interpretation of complex numbers.
This Cartesian coordinate system is no longer ordinary, because its points have a special meaning: they represent complex numbers. We therefore call such a Cartesian coordinate system the complex plane; the -axis is called the real axis, and the -axis is called the imaginary axis. More precisely: the set of complex numbers is in one-to-one correspondence with the set of all points in the complex plane.
Recalling what we learned about plane vectors, we find that the coordinate representation of a vector is also an ordered pair of real numbers . Clearly, the complex number corresponds to the point in the complex plane, and therefore also to the plane vector . Thus we have found another geometric interpretation of complex numbers: the set of complex numbers is in one-to-one correspondence with the set of vectors in the complex plane (the real number corresponds to the zero vector).
We can transfer our knowledge of vectors to complex numbers and define the modulus of a complex number as the modulus of the vector corresponding to that complex number. The modulus of the complex number is .
For convenience, we often call the complex number the point or the vector , and stipulate that equal vectors represent the same complex number.
From our knowledge of vectors, we also find that imaginary numbers cannot be compared by size (while real numbers can).
Addition and Subtraction
For complex numbers , define addition as follows:
Clearly, the sum of two complex numbers is still a complex number.
Taking the addition of vectors into account, we find that complex-number addition follows the rules of vector addition. This also confirms the correctness of the geometric interpretation of complex numbers.
It can likewise be verified that complex-number addition satisfies commutativity and associativity, namely:
Subtraction is the inverse operation of addition. Using the addition rules and the definition of equality of complex numbers, we can derive the subtraction rule:
This also agrees with vector subtraction.
Multiplication, Division, and Conjugates
For complex numbers , define multiplication as follows:
We can see that multiplying two complex numbers is similar to multiplying two polynomials: we only need to replace with and combine the real and imaginary parts separately.
Complex-number multiplication is similar in form to the vector product.
It follows that complex multiplication satisfies commutativity, associativity, and distributivity over addition, namely:
Since the laws of operation hold, we can see that the multiplication formulas from the real number field also apply in the complex number field.
Division is the inverse operation of multiplication. We can derive its rule as follows:
Since vectors do not have division, we will not discuss the relationship with vectors here.
To rationalize the denominator, we multiplied by ; this expression has an important meaning.
For the complex number , call the complex conjugate of , usually denoted by . We can see that if two complex numbers are conjugates of each other, they are symmetric about the real axis.
For complex numbers , complex conjugation has the following properties
- ,
Argument and Principal Argument
If we set the real unit as the positive horizontal direction and the imaginary unit as the positive vertical direction, we obtain the complex plane from the Cartesian-coordinate perspective.
The position of a complex number can also be determined using polar coordinates . As mentioned earlier, is the modulus of the complex number .
For the nonzero complex number , the angle between the positive direction of the real axis and its corresponding vector satisfies:
This is called the argument of the complex number , denoted by:
Any nonzero complex number has infinitely many arguments, so is in fact a set. We use the capitalized to denote one particular value satisfying:
is called the principal value of the argument or the principal argument. The arguments are obtained by adding an arbitrary integer multiple of (which may be zero or negative) to the principal argument; that is, .
Note that the sum of two principal arguments is not necessarily a principal argument, whereas the sum of two arguments is always a valid argument.
The set of complex numbers with modulus less than forms the unit disk in the complex plane. A complex number with modulus equal to is called a unit complex number, and all unit complex numbers form the unit circle in the complex plane. When there is no risk of confusion, the unit circle is sometimes also called the unit disk.
From the polar-coordinate perspective, multiplication and division of complex numbers become very simple: for multiplication, multiply the moduli and add the arguments; for division, divide the moduli and subtract the arguments.
Euler's Formula
Euler's formula(Euler's formula)1
For any real number , we have
After defining the complex exponential and complex trigonometric functions, this formula can be extended to all complex numbers.
Exponential and Trigonometric Functions
For the complex number , the function satisfies . This gives the definition of the complex exponential function:
On the real numbers, the definition of the complex exponential function is exactly the same as that of the real exponential function. In the complex plane it has the following properties:
- Always positive modulus: .
- Argument: .
- Addition theorem: .
- Periodicity: is a periodic function with fundamental period . If a function has a period that is an integer multiple of another period, that period is called a fundamental period.
The definitions of complex trigonometric functions (also simply called trigonometric functions) are as follows:
For , Euler's formula gives:
On the real numbers, the definitions of the complex trigonometric functions are exactly the same as those of the real trigonometric functions. In the complex plane they have the following properties:
- Parity: the sine function is odd, and the cosine function is even.
- Trigonometric identities: the usual trigonometric identities all hold, such as the sum of squares being , or the sum-and-difference formulas for angles.
- Periodicity: the sine and cosine functions have fundamental period .
- Zeros: all zeros of the real sine and real cosine functions together form all zeros of the complex sine and complex cosine functions. This extension introduces no new zeros.
- Unbounded modulus: the modulus of the complex sine and cosine functions can exceed any given positive number; unlike their real counterparts, they are no longer restricted to the range .
Three Forms of Complex Numbers
Using the Cartesian-coordinate and polar-coordinate perspectives, we can write a complex number in three forms.
The algebraic form of a complex number is used to represent any complex number.
The algebraic form is convenient for computing the four operations of addition, subtraction, multiplication, and division of complex numbers.
The trigonometric form and exponential form of a complex number are used to represent nonzero complex numbers.
These two forms are more convenient for computing multiplication and division, as well as the operations that follow. If we use only functions familiar from high school, we can use the trigonometric form. If we introduce the complex exponential function, it is more convenient to write the equivalent exponential form.
Roots of Unity
Consider the solutions of over the complex numbers. Clearly, there are such solutions, and all solutions are called -th (complex) roots of unity(-th root of unity). From the geometry of the complex plane, the -th roots of unity divide the unit circle into equal parts.
Let (the unit complex number whose argument is ). Then the solution set of is , where
Unless otherwise specified, an -th root of unity in general discussion means the first solution encountered counterclockwise from , namely the above; all other solutions can be represented by powers of .
Why, when mentioning the -th roots of unity, do we usually mean specifically the first one?
Mainly for convenience in applications. All -th roots of unity can be expressed as powers of the first -th root of unity ; moreover, for any , the complex number is not a -th root of unity.
Primitive Roots of Unity
In fact, among the -th roots of unity, more than just have similar properties. The elements of the set
are called -th primitive roots of unity(-th primitive root of unity). From the expression above, all -th primitive roots of unity number in total, where is the Euler totient function.
Every primitive root of unity has the same properties as the above: for every , the power of with exponent is not ; in other words, is not a -th root of unity. Therefore, any primitive root of unity can be used to generate all roots of unity.
To understand the structure of the -th primitive roots of unity, we need the following property of roots of unity:
Property
For integers and , let . Then .
Proof
Direct calculation gives
This shows that whenever , is necessarily an -th (primitive) root of unity. Therefore, a root of unity with the property described above must satisfy . This is precisely why primitive roots of unity have the definition given above.
As a simple consequence of this analysis, we also have:
Theorem
As ranges over the divisors of , all -th primitive roots of unity form exactly a partition of the -th roots of unity. Moreover, for , the map is a bijection among the -th roots of unity and preserves the partition above: it still maps the -th primitive roots of unity to the -th primitive roots of unity.
Although there are many choices of primitive roots of unity, because the first root has the simplest form, is still the most commonly used one in algorithm competitions. In some settings, to improve computational efficiency, one may also use a primitive root of unity modulo a given modulus in place of in the complex field.
Complex Numbers in Programming Languages
Complex Numbers in C
The C99 standard provides the <complex.h> header.
The <complex.h> header provides three types: double complex, float complex, and long double complex.
The arithmetic operators '+', '-', '*', and '/', can be used in any mixture of floating-point and complex numbers. If one end of an expression is a complex number, the result is a complex number.
The <complex.h> header provides the imaginary unit I; when this header is included, the uppercase letter I cannot be used as a variable name.
For an individual complex number, <complex.h> provides several operations: the creal function extracts the real part, cimag extracts the imaginary part, cabs computes the modulus, and carg computes the principal argument.
There are three versions of each function depending on the type. For example, the creal function has three versions, creal, crealf, and creall, for handling double, float, and long double, respectively. The version with no suffix handles double by default. All functions below follow this rule, so it will not be stated separately.
These functions all return ordinary floating-point numbers. An ordinary floating-point number can be assigned directly to a complex number, but a complex number cannot be assigned directly to a floating-point number; one of the extraction operations above must be used.
The conj function computes the complex conjugate and returns a complex number.
The cexp function computes the complex exponential, clog computes the principal value of the logarithm, csin computes the sine, ccos computes the cosine, and ctan computes the tangent.
The cpow function computes powers, csqrt computes square roots, casin computes the inverse sine, cacos computes the inverse cosine, and catan computes the inverse tangent. All of these functions compute the principal values of multivalued functions.
Complex Numbers in C++
In C, <ctype.h> becomes <cctype> in C++; almost all header files follow this naming convention.
However, <complex.h> is an exception: C++ has no <ccomplex> header. In C++, complex numbers are provided directly by <complex>, whose contents are completely different from those of C.
This is interesting. The reason is that <complex> already existed in the first version of C++, C++98, whereas the C language did not add it until C99.
In C++, complex types are defined using complex<float>, complex<double>, and complex<long double>. Because of object-oriented polymorphism, the functions below have unique names and do not need f or l suffixes.
A complex-number object has member functions real and imag, which can access the real and imaginary parts.
A complex-number object has the non-member functions real, imag, abs, and arg, which return the real part, imaginary part, modulus, and argument.
A complex-number object also has the non-member functions: norm for the square of the modulus, and conj for the complex conjugate.
A complex-number object also has the non-member functions exp, log (the principal value of the logarithm with base ), log10 (the principal value of the logarithm with base 10, which C does not have), pow, sqrt, sin, cos, and tan; their meanings are the same as in C.
In C++14 and later, the literal operators std::literals::complex_literals::""if, ""i, ""il are defined. For example, entering 100if, 100i, and 100il returns std::complex<float>{0.0f, 100.0f}, std::complex<double>{0.0, 100.0}, and std::complex<long double>{0.0l, 100.0l}, respectively. This makes it convenient to write complex declarations such as auto z = 4.0 + 3i.
References and Links
- Complex number - Wikipedia
- Euler's formula - Wikipedia
- Complex number arithmetic - cppreference.com
- std::complex - cppreference.com
Footnotes
-
For more information about Euler's formula, see the two videos Euler's Formula and Elementary Group Theory and An Introduction to Differential Equations - Chapter 5: Understanding in 3.14 Minutes. ↩