Complex Numbers - RPIQuantumComputing/QuantumCircuits GitHub Wiki
What are Complex Numbers?
You must have heard about complex numbers from high school algebra class, especially when you were dealing with quadratic equations. When $b^2 - 4ac < 0$ from good old quadratic equation $x_{1, 2} = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$, you know that the quadratic equation you are solving has complex solutions. On this page, you will expand your knowledge of complex numbers to be capable of quantum computing.
Definition
To understand complex numbers, we must first understand real and imaginary numbers. Real numbers, denoted as $\mathbb{R}$, contain rational and irrational numbers. They can represent continuous quantities, but they cannot represent some of the roots of quadratic equations (e.g., $x^2 + 1 = 0$). Now, to describe the roots of this equation, mathematicians have created a new number set called imaginary numbers. The basic unit of an imaginary number is denoted as $i$ where $i^2 = -1$. We can represent all imaginary numbers by putting a real scalar right next to the imaginary unit, just like $bi$ where $b \in \mathbb{R}$. So, we can say that imaginary numbers are as compact as real numbers. Finally, we can add those two number sets to create a new system called complex numbers, denoted by $\mathbb{C}$. Complex numbers are usually expressed by $a + bi$, where $a, b \in \mathbb{R}$. $a$ from this expression is the real part of the complex number, and $b$ is the imaginary part of the complex number since it is right next to the imaginary unit.
Complex Plane
Complex planes are just a way of mapping complex numbers onto a plane. Just like we would map real numbers onto a number line, we can plot complex numbers on a complex plane; hence we need two real numbers to express a complex number. To construct a complex plane, we need to put the real number line horizontally and the complex number line vertically. And just like how we would plot points on the $xy$ plane, we can think of complex numbers as a 'coordinate' to plot a point on the complex plane. For instance, let's say we want to plot a point $3 + 4i$ on a complex plane. The real part of this number is $3$, and the imaginary part is $4$. We can put a point where we would normally put a point at $(3, 4)$ on the $xy$ plane. How about $-7 + \sqrt{3}i$? We can plot a point where $(-7, \sqrt{3})$ would go. Mathematically, people usually denote $\Re(a + bi) = a$ for the real part of a complex number and $\Im(a + bi) = b$ for the imaginary part of the complex number.
Euler's Formula
Finally, we reach a point where complex numbers become very interesting. We are going to take a deep look at how we can think of complex numbers in terms of a circle. You might have heard about the Taylor series from calculus class. If you don't know what it is, I recommend you find a resource to understand on your time and will. A function $f(x) = e^x$ can be expressed in terms of the Taylor series as:
$$ e^x = \sum_{n = 0}^{\infty}\frac{x^n}{n!} = 1 + x + \frac{x^2}{2} + \frac{x^3}{6} + \frac{x^4}{24} + \cdots $$
Now, we put $ix$ instead of $x$ in $f(x)$. Remember that $i^2 = -1$ (or, $i = \sqrt{-1}$), so we can derive that $i^3 = -i$, $i^4 = 1$, and so on, repeating every 4th.
$$ e^{ix} = \sum_{n = 0}^{\infty}\frac{(ix)^n}{n!} = 1 + ix - \frac{x^2}{2} - \frac{ix^3}{6} + \frac{x^4}{24} + \cdots $$
Every time $n$ is even, we can see that the term has no imaginary unit. On the other hand, every time $n$ is odd, there is an imaginary unit. We can group those terms by whether they have an imaginary unit or not.
$$ e^{ix} = \left( 1 - \frac{x^2}{2!} + \frac{x^4}{24} - \frac{x^6}{720} + \cdots \right) + i \left(x - \frac{x^3}{6} + \frac{x^5}{120} - \frac{x^7}{5040} + \cdots \right) $$
Notice that this form looks familiar. It is a complex number! Since it is well-known that the real part of this expression is the Taylor expansion of $\cos(x)$ and the imaginary part is the Taylor expansion of $\sin(x)$. Thus, we can write:
$$ e^{ix} = \cos(x) + i \sin(x) $$
Recall from trigonometry from high school, we can write complex numbers in terms of angles. For instance, $e^{i(0)} = 1$, $e^{i \left( \frac{\pi}{2} \right)} = i$, $e^{i (\pi)} = -1$, $e^{i \left( \frac{3 \pi}{2} \right)} = -i$, and so on. However, we cannot represent all complex numbers using this. We put a scalar $r$ that can be in front of $e^{ix}$, so we can scale the circle, just like polar coordinates. For any given radius $r$ or angle $x$ (or $\theta$) in $r e^{ix}$, there must be a corresponding $a$ and $b$ such that $a + bi$.
Since we know that $e^{i \pi} = -1$, by just moving $-1$ to the left-hand side, you can obtain $e^{i \pi} + 1 = 0$, which is Euler's identity.