ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing
ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing

All Courses

Introduction to Quantum Computing
Chapter 1: From Bits to Qubits
Classical Computation Limits
Defining the Qubit
Dirac Notation Fundamentals
The Bloch Sphere Representation
Python Environment Setup Practice
Chapter 2: Linear Algebra for Quantum Mechanics
Complex Numbers in Quantum States
Vectors and State Spaces
Inner and Outer Products
Unitary Matrices and Operations
Eigenvalues and Eigenvectors
Numpy for Quantum Math Practice
Chapter 3: Single Qubit Gates and Superposition
The Concept of Superposition
Pauli Gates X Y and Z
The Hadamard Gate
Phase Gates and Rotation
Measurement and Collapse
Single Qubit Circuit Practice
Chapter 4: Multiple Qubits and Entanglement
Tensor Products
The CNOT Gate
Understanding Entanglement
Bell States
Bell State Construction Practice
Chapter 5: Basic Quantum Circuits
Reading Quantum Circuit Diagrams
The No-Cloning Theorem
Quantum Teleportation Logic
Superdense Coding Concept
Teleportation Circuit Practice

Complex Numbers in Quantum States

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 Number

A complex number zzz consists of two distinct parts: a real part and an imaginary part. It is typically written in the following form:

z=a+biz = a + biz=a+bi

Here, aaa represents the real component, while bbb represents the imaginary component. The symbol iii is the imaginary unit, defined by the property that its square equals negative one:

i2=−1i^2 = -1i2=−1

In Python and many engineering contexts, the imaginary unit is often represented by j instead of i. For example, the number 3+4i3 + 4i3+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.

Plotting the complex number 3+4i3 + 4i3+4i on the complex plane. The vector length represents magnitude, and the angle from the x-axis represents phase.

Calculating Magnitude

In 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)(0,0)(0,0) to the point (a,b)(a,b)(a,b). We calculate this using the Pythagorean theorem:

∣z∣=a2+b2|z| = \sqrt{a^2 + b^2}∣z∣=a2+b2​

For the example z=3+4iz = 3 + 4iz=3+4i, the calculation is:

∣z∣=32+42=9+16=25=5|z| = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5∣z∣=32+42​=9+16​=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 ∣α∣2|\alpha|^2∣α∣2.

The Complex Conjugate

To 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 zzz, denoted as z∗z^*z∗ or zˉ\bar{z}zˉ, is found by reversing the sign of the imaginary part.

If z=a+biz = a + biz=a+bi, then:

z∗=a−biz^* = a - biz∗=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⋅z∗=(a+bi)(a−bi)=a2+b2=∣z∣2z \cdot z^* = (a + bi)(a - bi) = a^2 + b^2 = |z|^2z⋅z∗=(a+bi)(a−bi)=a2+b2=∣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 Phase

While the rectangular form a+bia + bia+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:

  1. Radius (rrr): The magnitude ∣z∣|z|∣z∣.
  2. Angle (θ\thetaθ): The phase angle relative to the positive real axis.

Using Euler's formula, we can express a complex number as:

z=reiθz = r e^{i\theta}z=reiθ

In this notation, eee 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 rrr. This means the probability of measurement remains the same, but the state's relationship to other states changes.

Python Implementation

You 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.

© 2026 ApX Machine Learning