To describe a quantum state accurately, real numbers are insufficient. Classical systems measure certainty with probabilities ranging from 0 to 1. However, quantum mechanics operates on amplitudes. An amplitude is a value that describes the state of a quantum system before measurement. Unlike standard probabilities, amplitudes can be negative or imaginary. This property allows quantum states to interfere with one another, constructing or canceling out outcomes in ways that classical probability cannot model.To work with amplitudes, we must use complex numbers. A complex number extends the traditional number line into a two-dimensional plane. This section introduces the arithmetic of complex numbers necessary for calculating quantum probabilities and rotations.The Structure of a Complex NumberA complex number $z$ consists of two distinct parts: a real part and an imaginary part. It is typically written in the following form:$$z = a + bi$$Here, $a$ represents the real component, while $b$ represents the imaginary component. The symbol $i$ is the imaginary unit, defined by the property that its square equals negative one:$$i^2 = -1$$In Python and many engineering contexts, the imaginary unit is often represented by j instead of i. For example, the number $3 + 4i$ is written in Python code as 3 + 4j.Understanding complex numbers requires visualizing them not on a line, but on a plane. The horizontal axis represents real numbers, while the vertical axis represents imaginary numbers. This geometric interpretation allows us to treat quantum states as vectors.{ "layout": { "title": "Geometric Representation of z = 3 + 4i", "xaxis": { "title": "Real Axis (Re)", "range": [-1, 5], "zeroline": true, "zerolinecolor": "#adb5bd" }, "yaxis": { "title": "Imaginary Axis (Im)", "range": [-1, 5], "zeroline": true, "zerolinecolor": "#adb5bd", "scaleanchor": "x", "scaleratio": 1 }, "showlegend": false, "plot_bgcolor": "#ffffff", "width": 600, "height": 500 }, "data": [ { "x": [0, 3], "y": [0, 4], "mode": "lines+markers", "type": "scatter", "line": { "color": "#1c7ed6", "width": 3 }, "marker": { "size": 10, "color": "#1c7ed6" } }, { "x": [3, 3], "y": [0, 4], "mode": "lines", "type": "scatter", "line": { "color": "#adb5bd", "dash": "dot", "width": 2 } }, { "x": [0, 3], "y": [4, 4], "mode": "lines", "type": "scatter", "line": { "color": "#adb5bd", "dash": "dot", "width": 2 } } ] }Plotting the complex number $3 + 4i$ on the complex plane. The vector length represents magnitude, and the angle from the x-axis represents phase.Calculating MagnitudeIn quantum computing, the most important property of a complex number is its magnitude (or modulus). The magnitude connects the abstract quantum amplitude to a probability.Geometrically, the magnitude is the distance from the origin $(0,0)$ to the point $(a,b)$. We calculate this using the Pythagorean theorem:$$|z| = \sqrt{a^2 + b^2}$$For the example $z = 3 + 4i$, the calculation is:$$|z| = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5$$This magnitude is significant because the probability of a specific quantum outcome is the square of the magnitude of its amplitude. If a state has an amplitude $\alpha$, the probability of measuring that state is $|\alpha|^2$.The Complex ConjugateTo perform mathematical operations like the inner product (which we use to calculate overlap between quantum states), we need the complex conjugate. The conjugate of a complex number $z$, denoted as $z^*$ or $\bar{z}$, is found by reversing the sign of the imaginary part.If $z = a + bi$, then:$$z^* = a - bi$$Multiplying a complex number by its conjugate always results in a non-negative real number, which equals the square of the magnitude:$$z \cdot z^* = (a + bi)(a - bi) = a^2 + b^2 = |z|^2$$This operation ensures that when we calculate probabilities in quantum mechanics, the result is always a real number between 0 and 1.Polar Coordinates and PhaseWhile the rectangular form $a + bi$ is useful for addition, the polar form is often better for multiplication and understanding quantum gates. In polar coordinates, a complex number is defined by:Radius ($r$): The magnitude $|z|$.Angle ($\theta$): The phase angle relative to the positive real axis.Using Euler's formula, we can express a complex number as:$$z = r e^{i\theta}$$In this notation, $e$ is the base of the natural logarithm. This format is standard in quantum mechanics because many quantum operations (gates) act as rotations. They change the phase angle $\theta$ without changing the magnitude $r$. This means the probability of measurement remains the same, but the state's relationship to other states changes.Python ImplementationYou will often use Python libraries like NumPy to handle these calculations. Python supports complex numbers natively.Here is how you can define complex numbers and calculate their properties in Python:import numpy as np # Defining a complex number (using j for imaginary unit) z = 3 + 4j # Calculating the real and imaginary parts real_part = np.real(z) imag_part = np.imag(z) # Calculating the magnitude (absolute value) magnitude = np.abs(z) # Calculating the conjugate conjugate = np.conj(z) print(f"Number: {z}") print(f"Magnitude: {magnitude}") print(f"Conjugate: {conjugate}")Running this code yields a magnitude of 5.0 and a conjugate of 3-4j.When working with polar coordinates, NumPy provides the angle function to retrieve the phase $\theta$ in radians:# Calculate phase angle theta = np.angle(z) # Convert back to rectangular form using Euler's formula logic # z = r * (cos(theta) + i * sin(theta)) z_reconstructed = magnitude * (np.cos(theta) + 1j * np.sin(theta))Mastering these basic operations is the first step toward building the linear algebra machinery required for quantum circuits. In the next section, we will group these complex numbers into vectors to represent the full state of a qubit.