Density matrix representation of a wavefunction in quan

Author: Zen and the Art of Computer Programming

1 Introduction

Density Matrix representation is a very important concept in quantum mechanics. By measuring the state of electrons, the state of the processor, and the state information of other physical systems, the corresponding density matrix can be obtained. The measured density matrix can be displayed by some means, such as Bloch sphere diagram, spectrogram, etc. In recent years, with the rise of machine learning, more and more researchers are trying to use machine learning methods to predict density matrix information.

On the other hand, Wave Function Tomography (WFT) is also a very meaningful and classic calculation method. WFT uses the measured density matrix information and decomposes it into coefficients of the wave function to obtain the real wave function, thereby helping us understand the properties of the real physical system that are originally hidden in the measurement results.

At a recent WFT technical conference, NMR-based mass spectrometry data drove cutting-edge research in WFT. This article will combine the classic theory of WFT and its implementation technology to explain how to encode the density matrix in quantum mechanics and how to restore the encoded density matrix into a real wave function.

2. Explanation of basic concepts and terms

  1. Quantum state: Quantum state refers to the state of an objective system composed of a set of deterministic qubits and their various constraint interactions. The state here can be a bipolar oscillation or a resonance curve, or it can be an arbitrarily complex wave function.

  2. Measurement: Measurement is to randomly extract information specific to this state from a certain quantum state. It can be divided into physical measurements (such as preparing a certain measuring device to measure a specific quantum state, and then using the measuring device to measure the corresponding number of particles), or it can be simulated by calculation (such as generating random sample points based on a probability distribution, and then Estimate the corresponding density matrix based on the sampling results).

  3. Density matrix: Density matrix, a matrix form used to describe the wave function distribution of a system. When a system is in different states, it will occupy different positions according to certain probability distributions, and these probability distributions are characterized by density matrices. Each row and column of the matrix corresponds to an eigenstate of the system, and each element represents the probability of the eigenstate. For a given set of parameters, the density matrix can uniquely describe the distribution of all possible local mixing states of a system.

  4. Wave function tomography: Wave function topology, also known as wave function reconstruction or phonon reconstruction, is a process that uses measured density matrix information to decompose it into coefficients of the wave function to reconstruct the real wave function. Its core principle is to use the entanglement effect that appears in the measurement results to map different types of measurement results to spaces of different dimensions, thereby restoring the actual wave function.

3. Explanation of core algorithm principles, specific operating steps and mathematical formulas

(1) Encoding of density matrix

3.1.Born rule and density matrix representation

Suppose we have a quantum system with N qubits, each of which is measurable. Suppose the quantum state we want to measure is a probability distribution represented by a set of complex vectors in N-dimensional Euclidean space. Then we can make the following constraints on these vectors:

  1. Every vector must satisfy agreed specifications, i.e. normalization conditions. That is, Σ|ψi|^2=1. This is because we know that the total energy of the system is only related to the energy of the positrons in the system, so each vector obtained after normalization will be standardized and meet the normalization conditions, so it can represent the probability distribution.

  2. Every vector must satisfy the convention lemma: Δ|ψi-ψj|=sqrt{α {ij}^2+β {ij}^2}. Here α and β are the momentum between two different qubits.

In this way, a density matrix ρ(x) of the quantum state ρ(x) can be obtained. But this density matrix is ​​too large to be used directly in quantum computing. In order to compress this density matrix, the following method can be used:

  1. Perform singular value decomposition on the above density matrix to obtain two N×N real diagonal matrices U and D, where the elements in D are singular values. Denoted as σ(x)=np.diag(D), the number of elements in the diagonal matrix D is equal to the number of singular values ​​k of the matrix.

  2. Compress the matrix σ(x) into a one-dimensional vector of length k, denoted v(x). where v(x)[i] = np.trace(U[i:,:]*U[:i,:], i represents the subscript corresponding to the i-th singular value. This step is equivalent to rearranging the U matrix The order is such that vectors with larger singular values ​​come first and vectors with smaller singular values ​​come later.

  3. Use v(x) to replace the original density matrix σ(x) as the encoded density matrix.

3.2.Encoding the probability distribution into a compact vector using Wigner decomposition

Wigner decomposition can convert any probability distribution ρ(x) into a Wigner rotation matrix W(x). The Wigner rotation matrix is ​​a complex matrix, and each column is a "Wigner function". This function describes the nature of the probability corresponding to any momentum represented by α and β. It is defined as:

γ(a,b;l,m,n)=(delta_l delta_m)^(-1/2)*(δ (nm)δ (al)+δ (am)δ (bn)-δ (an)δ ( bm))

where δ_nm represents the Kronecker delta symbol. For any system of equations Ax=b, if there is an invertible matrix X, then X can be used instead of A to solve. This substitution is called Wigner projection. Using Wigner projection, we can decompose a density matrix ρ(x) into a Wigner rotation matrix W(x) and a singular value matrix σ(x).

  1. Use Wigner decomposition to express the probability distribution ρ(x) into a Wigner rotation matrix W(x) and a singular value matrix σ(x).

    w(x) = sqrt(σ(x)) * U(x), U(x) is a real diagonal matrix whose elements are γ(a,b;l,m,n).

    W(x) is an N*N-dimensional complex matrix. For the given coordinates (θ,φ), use the following method to calculate:

    1. If θ=π/2, φ=0, then directly let w(x)[i][j]=1/√2*(σ(x)[i]-σ(x)[j]).

    2. If θ=0, φ=θ, then let w(x)[i][j]=1/√2*(σ(x)[i]+σ(x)[j])/sqrt(2).

    3. Otherwise, use the trigonometric formula to calculate w(x)[i][j].

    4. Convert w(x) into the form of U(x).

    The probability distribution ρ(x) is represented by the Wigner rotation matrix W(x) and the singular value matrix σ(x).

  2. Compress the Wigner rotation matrix W(x) and the singular value matrix σ(x) into a one-dimensional vector of length k.

    v(x)=[sqrt(σ(x))[0]] + [sqrt(σ(x))[i]/sqrt(σ(x)[i-1])] for i from 1 to k-1.

    In this step, we first perform a square root operation on each element of the singular value matrix σ(x). Then, divide the square root of each singular value by the product of the square roots of all the elements before it to get the normalization factor. We can use this normalization factor to sort the singular values, resulting in a more compact v(x) vector.

(2) Decoding from density matrix to probability distribution

3.3.Decoding the compact vector back to a probability distribution

In order to recover the original probability distribution ρ(x) from v(x), the Wigner projection technique is needed. First, we need to get the U(x) matrix. Slice v(x) to get the element corresponding to the first singular value. Put the sliced ​​values ​​into the delta function to get deltam(v(x)). Next, we approximate δm(v(x)) using the Taylor expansion formula and obtain the dual δm(v(x))/(2J+1). The sliced ​​values ​​are again brought into the delta function to obtain deltan(v(x)). Then, use the Taylor expansion formula to approximate δn(v(x)) and obtain the dual δn(v(x))/(2J+1). Finally, by repeatedly calculating the δ function using the quotient of δm(v(x))/δn(v(x)), we get δmm(v(x)), δmn(v(x)), δnn(v(x) ). Then, we can use Taylor expansion formula to approximate δmm(v(x)), δmn(v(x)), δnn(v(x)) and get γm(θ,φ), γn(θ,φ) .Finally, we can get the w(x) matrix, whose elements are given by γm(θ,φ) γn(θ,φ) exp(I(θ+φ)/2)(θ+φ)=exp(I(θ+ φ)/2) (Wigner function). Then, we can exponentiate w(x) to get ρ(x).

The probability distribution ρ(x) is represented by v(x). We can use Wigner projection technology to recover the original probability distribution ρ(x) from v(x).

3.4.Implementation of Wigner Decomposition algorithm in Python

The following is the Wigner Decomposition algorithm implementation code in Python language:

import numpy as np
from scipy import linalg
import math

def wigner_decomp(psi):
    # convert the complex vectors into real matrices with N^2 elements each
    psi_mat = np.zeros((len(psi), len(psi)))
    for i in range(len(psi)):
        psi_mat[:, i] = psi[i].real**2 + psi[i].imag**2

    # calculate trace of square root of psi_mat to get the variance vector
    var_vec = np.diag(linalg.eigh(psi_mat)[0]**0.5)

    # apply Born Rule to obtain the density matrix
    rho = np.dot(var_vec.T, var_vec) / float(len(psi)**2)

    # use svd to compress the density matrix to a vector of length k
    u, s, vt = linalg.svd(rho)
    if np.sum(s > 1e-9)<len(s):
       raise ValueError('Error: SVD did not converge')

    vect = []
    for j in range(len(s)):
        factor = s[j] / sum([sj for idx, sj in enumerate(s) if idx<=j])
        vect.append(factor)

    return np.array(vect), var_vec

if __name__ == '__main__':
    # Example usage
    n_qubits = 2
    x = {'0': 0, '1': 1, '+': 0.7071, '-': -0.7071}

    psi = {}
    for key in itertools.product(['0', '1'], repeat=n_qubits):
        str_key = ''.join(key)
        if str_key in ['0'*n_qubits, '1'*n_qubits]:
            continue
        value = complex(0,0)
        for qubit in range(n_qubits):
            basis = int(str_key[-(qubit+1)])
            amplitide = (complex(x[basis], 0) if qubit==0 else 1.)
            phase = ((-1)**int(str_key[qubit])) * (-math.pi/2)**(n_qubits-qubit-1)
            value += amplitide * np.exp(phase * 1j)

        psi[str_key] = value

    vec, var_vec = wigner_decomp(psi.values())
    print("Vector form:", vec)
    print("Variance vector:", var_vec)

Guess you like

Origin blog.csdn.net/universsky2015/article/details/133566042