Complex Numbers
If you have already studied complex numbers, you can skip this page.
Learning about complex numbers requires some knowledge of vectors. If you have not studied vectors, please go to the Vector page.
Complex Numbers
Introduction
Note
The following introduction method is from the People's Education Press High School Mathematics A Edition, Compulsory Book 2.
From the perspective of equations, whether the square root of a negative real number can be taken is equivalent to whether the equation \(x^2+a=0 (a>0)\) has a solution, which can be further reduced to whether the equation \(x^2+1=0\) has a solution.
Looking back at the expansion process of existing number sets, we can see that each expansion is closely related to practical needs. For example, to measure the diagonal of a square and to solve equations like \(x^2-2=0\) that have no solution in the set of rational numbers, people expanded the set of rational numbers to the set of real numbers. After the number set expansion, the addition and multiplication operations defined in the set of real numbers are consistent with those originally defined in the set of rational numbers, and both addition and multiplication satisfy the commutative and associative laws, while multiplication satisfies the distributive law over addition.
Following this idea, to solve the problem that equations like \(x^2+1=0\) have no solution in the real number system, we imagine introducing a new number \(\mathrm{i}\) such that \(x=\mathrm{i}\) is a solution to the equation \(x^2+1=0\), i.e., \(\mathrm{i}^2=-1\).
Think: After adding the newly introduced number \(\mathrm{i}\) to the set of real numbers, we want the number \(\mathrm{i}\) and real numbers to still perform addition and multiplication operations as real numbers do, and we hope that addition and multiplication satisfy the commutative and associative laws, and multiplication satisfies the distributive law over addition. So, after expanding the real number system, what numbers does the new number system consist of?
According to the above idea, multiply the real number \(b\) by \(\mathrm{i}\), and denote the result as \(b\mathrm{i}\); add the real number \(a\) to \(b\mathrm{i}\), and denote the result as \(a+b\mathrm{i}\). Note that all real numbers and \(\mathrm{i}\) can be written in the form \(a+b\mathrm{i}(a,b\in \mathbf{R})\), so these numbers are all in the expanded new number set.
Definition
We define numbers of the form \(a+b\mathrm{i}\), where \(a,b\in \mathbf{R}\), as complex numbers, where \(\mathrm{i}\) is called the imaginary unit. The set of all complex numbers is called the set of complex numbers, denoted by \(\mathbf{C}\).
Complex numbers are usually denoted by \(z\), i.e., \(z=a+b\mathrm{i}\). This form is called the algebraic form of a complex number. Here, \(a\) is called the real part of the complex number \(z\), denoted as \(\operatorname{Re}(z)\), and \(b\) is called the imaginary part of \(z\), denoted as \(\operatorname{Im}(z)\). Unless otherwise specified, \(a,b\in \mathbf{R}\).
For a complex number \(z\), it is a real number if and only if \(b=0\); it is an imaginary number if \(b\not = 0\); it is a purely imaginary number if \(a=0\) and \(b\not = 0\).
The relationship between purely imaginary numbers, imaginary numbers, real numbers, and complex numbers is shown in the following diagram.
Properties and Operations
Geometric Meaning
We know that numbers of the form \(a+b\mathrm{i}\) are called complex numbers, and we have given definitions and classifications. We can also explore deeper properties.
We placed all real numbers on the number line and found that points on the number line correspond one-to-one with real numbers. We consider doing the same for complex numbers.
First, we define equality of complex numbers: two complex numbers \(z_1=a+b\mathrm{i},z_2=c+d\mathrm{i}\) are equal if and only if \(a=c\) and \(b=d\).
This definition is very natural and will not be explained in detail here.
That is, we can represent a complex number \(z=a+b\mathrm{i}\) with a unique ordered real pair \((a,b)\). Thus, recalling the Cartesian coordinate system, we find that the set of complex numbers corresponds one-to-one with the set of points in the Cartesian coordinate system. Well, we have found one geometric meaning of complex numbers.
This Cartesian coordinate system is no longer ordinary because the points in it have a special meaning—representing a complex number. Therefore, we call such a Cartesian coordinate system the complex plane, with the \(x\)-axis called the real axis and the \(y\)-axis called the imaginary axis. We further state: The set of complex numbers corresponds one-to-one with the set of all points in the complex plane.
Considering the knowledge of plane vectors we have learned, we find that the coordinate representation of a vector is also an ordered real pair \((a,b)\). Clearly, the complex number \(z=a+b\mathrm{i}\) corresponds to the point \(Z(a,b)\) in the complex plane, and it also corresponds to the plane vector \(\overrightarrow{OZ}=(a,b)\). Thus, we have found another geometric meaning of complex numbers: The set of complex numbers corresponds one-to-one with the set of vectors in the complex plane (with the real number \(0\) corresponding to the zero vector).
Thus, we transfer vector knowledge to complex numbers and define the modulus of a complex number as the modulus of the corresponding vector. The modulus of the complex number \(z=a+b\mathrm{i}\) is \(|z|=\sqrt{a^2+b^2}\).
For convenience, we often refer to the complex number \(z=a+b\mathrm{i}\) as point \(Z\) or vector \(\overrightarrow {OZ}\), and we stipulate that equal vectors represent the same complex number.
Moreover, from vector knowledge, we find that imaginary numbers cannot be compared in size (but real numbers can).
Addition and Subtraction
For complex numbers \(z_1=a+b\mathrm{i},z_2=c+d\mathrm{i}\), define the addition rule as follows:
Clearly, the sum of two complex numbers is still a complex number.
Considering vector addition, we find that complex addition conforms to the vector addition rule, which also proves the correctness of the geometric meaning of complex numbers.
It can also be verified that complex addition satisfies the commutative law and associative law. That is:
Subtraction, as the inverse operation of addition, can be derived from the addition rule and the definition of complex equality:
This also conforms to vector subtraction.
Multiplication, Division, and Conjugate
For complex numbers \(z_1=a+b\mathrm{i},z_2=c+d\mathrm{i}\), define the multiplication rule as follows:
It can be seen that multiplying two complex numbers is similar to multiplying two polynomials, only needing to replace \(\mathrm{i}^2\) with \(-1\) and combine the real and imaginary parts separately.
Complex multiplication is similar to the vector cross product form in vectors.
It is easy to see that complex multiplication satisfies the commutative law, associative law, and distributive law over addition, i.e.:
- \(z_1z_2=z_2z_1\)
- \((z_1z_2)z_3=z_1(z_2z_3)\)
- \(z_1(z_2+z_3)=z_1z_2+z_1z_3\)
Since these laws are satisfied, we find that multiplication formulas in the real number field are also applicable in the complex number field.
Division is the inverse operation of multiplication. We can derive it as follows:
Since vectors do not have division, we do not discuss the relationship with vectors here.
To rationalize the denominator, we multiplied by \(c-d\mathrm{i}\), which is a meaningful expression.
For a complex number \(z=a+b\mathrm{i}\), we call \(a-b\mathrm{i}\) the complex conjugate of \(z\), usually denoted as \(\bar z\). We can find that if two complex numbers are conjugates, they are symmetric about the real axis.
For complex numbers \(z,w\), the complex conjugate has the following properties:
- \(z\cdot\bar{z}=|z|^2\)
- \(\overline{\overline{z}}=z\)
- \(\operatorname{Re}(z)=\dfrac{z+\bar{z}}{2}\), \(\operatorname{Im}(z)=\dfrac{z-\bar{z}}{2}\)
- \(\overline{z\pm w}=\bar{z}\pm\bar{w}\)
- \(\overline{zw}=\bar{z}\bar{w}\)
- \(\overline{z/w}=\bar{z}/\bar{w}\)
Argument and Principal Argument
If we set the real unit \(1\) as the horizontal positive direction and the imaginary unit \(\mathrm{i}\) as the vertical positive direction, we obtain the complex plane from the perspective of Cartesian coordinates.
The position of a complex number \(z\) can also be determined using polar coordinates \((r, \theta)\). The modulus \(r\) of the complex number \(z\) has been mentioned earlier.
The angle \(\theta\) from the positive real axis to the vector corresponding to a nonzero complex number \(z=x+\mathrm{i}y\) satisfies:
This is called the argument of the complex number \(z\), denoted as:
Any nonzero complex number \(z\) has infinitely many arguments, so \(\arg z\) is actually a set. Using the uppercase \(\operatorname{Arg} z\) to denote one specific value satisfying:
We call \(\operatorname{Arg} z\) the principal argument or principal value of the argument. The argument is the principal argument plus an integer multiple (which can be zero or negative) of \(2k\pi\), i.e., \(\arg z = \{\operatorname{Arg} z + 2k\pi \mid k\in \mathbf Z\}\).
Note that the sum of two principal arguments is not necessarily a principal argument, but the sum of two arguments is always a valid argument.
Complex numbers with modulus less than \(1\) form the unit circle in the complex plane. Complex numbers with modulus equal to \(1\) are called unit complex numbers, and all unit complex numbers form the unit circumference in the complex plane. When no confusion arises, the unit circumference is sometimes also called the unit circle.
From the polar coordinate perspective, multiplication and division of complex numbers become simple. For complex multiplication, multiply the moduli and add the arguments. For complex division, divide the moduli and subtract the arguments.
Euler's Formula
Euler's formula 1
For any real number \(x\), we have
After supplementing the definitions of complex exponential functions and complex trigonometric functions, this formula can be extended to all complex numbers.
Exponential Functions and Trigonometric Functions
For a complex number \(z=x+\mathrm{i}y\), the function \(f(z)=\mathrm{e}^x(\cos y+\mathrm{i}\sin y)\) satisfies \(f(z_1+z_2)=f(z_1)f(z_2)\). This leads to the definition of the complex exponential function:
The complex exponential function is completely consistent with the real exponential function on the set of real numbers. In the complex plane, it has the following properties:
- Positive modulus: \(|\exp z|=\exp x>0\).
- Argument: \(\arg(\exp z)=\{y + 2k\pi \mid k\in\mathbf Z\}\).
- Addition theorem: \(\exp (z_1+z_2)=\exp (z_1)\exp (z_2)\).
- Periodicity: \(\exp z\) is a periodic function with fundamental period \(2\pi \mathrm{i}\). If the period of a function \(f(z)\) is an integer multiple of a certain period, that period is called the fundamental period.
Complex trigonometric functions (also simply called trigonometric functions) are defined as follows:
If we take \(z\in\mathbf{R}\), then by Euler's formula, we have:
Complex trigonometric functions are completely consistent with real trigonometric functions on the set of real numbers. 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 hold, such as the sum of squares equals \(1\), or angle sum and difference formulas.
- Periodicity: The sine and cosine functions have a fundamental period of \(2\pi\).
- Zeros: All zeros of the real sine and cosine functions constitute all zeros of the complex sine and cosine functions. This extension does not introduce new zeros.
- Unbounded modulus: The modulus of complex sine and cosine functions can be greater than any given positive number, unlike real sine and cosine functions, which are limited to the range of \(1\).
Three Forms of Complex Numbers
Using the perspective of Cartesian coordinates and polar coordinates, we can write complex numbers in three forms.
The algebraic form of a complex number is used to represent any complex number.
The algebraic form is convenient for calculating the four operations of addition, subtraction, multiplication, and division.
The trigonometric form and exponential form of a complex number are used to represent nonzero complex numbers.
These two forms are more convenient for calculating multiplication and division of complex numbers and subsequent operations. If only high school functions are used, the trigonometric form can be used. If the complex exponential function is introduced, the equivalent exponential form is more convenient.
Roots of Unity
Consider the solutions to the equation \(x^n=1\) in the complex sense. Clearly, there are \(n\) such solutions, called \(n\)-th roots of unity. According to complex plane knowledge, the \(n\)-th roots of unity divide the unit circle into \(n\) equal parts.
Let \(\omega_n=\exp\dfrac{2\pi \mathrm{i}}{n}\) (i.e., the unit complex number with argument \(2\pi/n\)). Then the solution set of \(x^n=1\) is \(\{\omega_n^k\mid k=0,1\cdots,n-1\}\), where
Unless otherwise specified, the \(n\)-th root of unity usually refers to the first solution starting counterclockwise from \(1\), i.e., \(\omega_n\) above. Other solutions can be expressed as powers of \(\omega_n\).
Why is the \(n\)-th root of unity usually referred to as the first one?
Mainly for convenience in applications. All \(n\)-th roots of unity can be expressed as powers of the first \(n\)-th root of unity \(\omega_n\); moreover, for any \(k < n\), the complex number \(\omega_n\) is not a \(k\)-th root of unity.
Primitive Roots of Unity
In fact, among the \(n\)-th roots of unity, more than just \(\omega_n\) satisfy similar properties. The set
is called the \(n\)-th primitive roots of unity. According to the above expression, there are \(\varphi(n)\) primitive \(n\)-th roots of unity, where \(\varphi(n)\) is the Euler totient function.
Any primitive root of unity \(\omega\) has the same properties as \(\omega_n\) above: for any \(0<k<n\), the \(k\)-th power of \(\omega\) is not \(1\), meaning \(\omega\) is not a \(k\)-th root of unity. Therefore, using any primitive root of unity, all roots of unity can be generated.
To understand the structure of primitive \(n\)-th roots of unity, consider the following property of roots of unity:
Property
For integers \(n\) and \(k\), let \(d=\gcd(n,k)\). Then \(\omega_n^k = \omega_{n/d}^{k/d}\).
Proof
Direct calculation shows
This shows that as long as \(\gcd(n,k)\neq 1\), then \(\omega_n^k\) must be a \(\dfrac{n}{\gcd(n,k)}\)-th (primitive) root of unity. Therefore, the roots of unity \(\omega_n^k\) satisfying the aforementioned property must satisfy \(\gcd(n,k)=1\). This is why primitive roots of unity are defined as above.
Additionally, as a simple corollary of these analyses, we have:
Theorem
When \(k\) traverses the divisors of \(n\), all primitive \(k\)-th roots of unity exactly form a partition of the \(n\)-th roots of unity. Moreover, for \(\ell\perp n\), the mapping \(x\mapsto x^\ell\) gives a bijection between the \(n\)-th roots of unity, preserving the above partition: it maps primitive \(k\)-th roots of unity (for \(k\mid n\)) to primitive \(k\)-th roots of unity.
Although there are many choices for primitive roots of unity, the first root \(\omega_n\) is the most commonly used in algorithm competitions due to its simplicity. For some scenarios, to improve computational efficiency, one may also consider using primitive roots of unity modulo a prime instead of \(\omega_n\) in the complex field.
Complex Numbers in Programming Languages
Complex Numbers in C
In the C99 standard, there is the <complex.h> header.
In the <complex.h> header, three types are provided: double complex, float complex, and long double complex.
The arithmetic operators '+', '-', '*', and '/' can be used for any mix of floating-point numbers and complex numbers. When one side of an expression is complex, the result is complex.
The header <complex.h> provides the imaginary unit I. When this header is included, the uppercase letter I cannot be used as a variable name.
For a single 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.
All functions have three versions depending on the type. For example, the creal function has creal, crealf, and creall for handling double, float, and long double types, respectively. Functions without a suffix default to handling double type. All functions below follow this rule and will not be specifically mentioned.
These functions return general floating-point numbers. Ordinary floating-point numbers can be directly assigned to complex numbers, but complex numbers cannot be directly assigned to floating-point numbers; instead, the extraction operations mentioned 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 sine, ccos computes cosine, and ctan computes tangent.
The cpow function computes the power function, csqrt computes the square root, casin computes the arcsine, cacos computes the arccosine, and catan computes the arctangent. These functions compute the principal values of multi-valued functions.
Complex Numbers in C++
In C, <ctype.h> becomes <cctype> in C++, and almost all headers follow this naming convention.
However, <complex.h> does not follow this; C++ does not have a <ccomplex> header. Complex numbers in C++ are directly in <complex>, and its contents are completely different from C.
Interestingly, this is because the first version of C++, C++98, already had <complex>, while C language added it in C99.
In C++, complex types are defined using complex<float>, complex<double>, and complex<long double>. Due to object-oriented polymorphism, the function names below are unique and do not require suffixes like f or l.
A complex object has member functions real and imag to access the real and imaginary parts.
A complex object has non-member functions real, imag, abs, and arg, which return the real part, imaginary part, modulus, and argument.
A complex object also has non-member functions: norm for the square of the modulus, and conj for the complex conjugate.
A complex object also has non-member functions exp, log (principal value of the natural logarithm), log10 (principal value of the base-10 logarithm, not present in C), pow, sqrt, sin, cos, and tan, with the same meanings as in C.
In C++14 and later, the literal operators std::literals::complex_literals::""if, ""i, ""il are defined. For example, inputting 100if, 100i, and 100il will return 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 allows us to conveniently write complex declarations like auto z = 4.0 + 3i.
References and Links
- Complex number - Wikipedia
- Euler's formula - Wikipedia
- Complex number arithmetic - cppreference.com
- std::complex - cppreference.com
-
For more introduction to Euler's formula, you can refer to two videos: Euler's formula and elementary group theory and Differential equations introduction - Chapter 5: Understanding \(\mathrm{e}^{\mathrm{i}\pi}\) in 3.14 minutes. ↩
本页面最近更新:,更新历史
发现错误?想一起完善? 在 GitHub 上编辑此页!
本页面贡献者:OI-wiki
本页面的全部内容在 CC BY-SA 4.0 和 SATA 协议之条款下提供,附加条款亦可能应用