Quantum Linear Algebra

Introduction

Quantum linear algebra is the mathematical framework that underpins quantum computing. It defines how qubits behave, how quantum operations are performed, and how measurements extract information. This foundation is especially critical in Quantum Machine Learning, where operations on quantum states mirror classical linear algebra operations—but in exponentially larger spaces.


Core Concepts

1. Qubits as Vectors

  • A single qubit is a vector in a 2D complex Hilbert space.
  • Standard basis states:
    \[|0\rangle = \begin{bmatrix}1 \ 0\end{bmatrix}, \quad |1\rangle = \begin{bmatrix}0 \ 1\end{bmatrix}
    \]
  • A general qubit state: \[
    |\psi\rangle = \alpha|0\rangle + \beta|1\rangle, \quad \text{where} \ |\alpha|^2 + |\beta|^2 = 1
    \]
  • This normalization ensures that the total probability of all outcomes is 1.

2. Quantum Gates as Matrices

  • Quantum gates are unitary matrices: \(U^\dagger U = I\)
  • They represent reversible operations on qubits.
  • Examples:
  • Hadamard Gate (creates superposition): \[
    H = \frac{1}{\sqrt{2}}\begin{bmatrix}1 & 1 \ 1 & -1\end{bmatrix}
    \]
  • Pauli-X Gate (quantum NOT): \[
    X = \begin{bmatrix}0 & 1 \ 1 & 0\end{bmatrix}
    \]
  • Pauli-Y and Pauli-Z Gates, as well as rotation gates (e.g., RX, RY, RZ), are also commonly used.

3. Tensor Products

  • Multi-qubit states are constructed via tensor (Kronecker) products.
  • For two qubits: \[
    |0\rangle \otimes |0\rangle = |00\rangle = \begin{bmatrix}1 \ 0 \ 0 \ 0\end{bmatrix}
    \]
  • The tensor product exponentially increases the state space:
  • 1 qubit → 2D
  • 2 qubits → 4D
  • 3 qubits → 8D
  • … and so on

4. Measurement

  • Measurement projects a quantum state onto one of the basis vectors, collapsing the superposition.
  • For a qubit in state \(|\psi\rangle = \alpha|0\rangle + \beta|1\rangle\), the probabilities are: \[
    P(0) = |\alpha|^2, \quad P(1) = |\beta|^2
    \]
  • The result is a classical bit, and post-measurement, the original quantum state is lost.

Applications in Quantum AI

Quantum AI algorithms rely heavily on linear algebra operations:

  • Quantum matrix-vector multiplication simulates neural network layers.
  • Eigenvalue decomposition is essential in algorithms like QPE (Quantum Phase Estimation).
  • The HHL algorithm solves linear systems, useful for regression and optimization tasks.
  • Variational Quantum Circuits (VQCs) model trainable matrix operations with unitary gates, analogous to layers in neural networks.

Sample Matrix Operation in PennyLane

import pennylane as qml
from pennylane import numpy as np

dev = qml.device("default.qubit", wires=1)

@qml.qnode(dev)
def apply_hadamard():
    qml.Hadamard(wires=0)
    return qml.state()

print(apply_hadamard())

This code applies a Hadamard gate to a qubit to create a superposition and returns the resulting quantum state vector.


Summary

Quantum linear algebra is more than a mathematical concept—it is the operational core of how quantum systems compute and process information. Every quantum algorithm, classifier, and neural network you will build leverages these matrix and vector transformations under the hood.


➡️ Next: Quantum-enhanced Algorithms