Home Algorithms Commercialization Data Science Information Theories Quantum Theories Lab Linear Algebra
<< Bloch Sphere Orthonormality PDF Eigenstate of Multi-Qubits >>

$\require{cancel} \newcommand{\Ket}[1]{\left|{#1}\right\rangle} \newcommand{\Bra}[1]{\left\langle{#1}\right|} \newcommand{\Braket}[1]{\left\langle{#1}\right\rangle} \newcommand{\Rsr}[1]{\frac{1}{\sqrt{#1}}} \newcommand{\RSR}[1]{1/\sqrt{#1}} \newcommand{\Verti}{\rvert} \newcommand{\HAT}[1]{\hat{\,#1~}} \DeclareMathOperator{\Tr}{Tr}$

Bloch Vector

First created in July 2018

The Bloch Vector is composed of the expectation values of $\Ket\psi$ on the three Pauli axes: $\{\Braket{X}_\psi,\Braket{Y}_\psi,\Braket{Z}_\psi\}.$

The Kous Delta Operator $~B_\psi=\Braket{X}_\psi X+\Braket{Y}_\psi Y+\Braket{Z}_\psi Z~$ rotates a state vector by $\pi$ about $\Ket\psi$. (Note: $B_\psi^2=I.$)

The (pure) state of $\Ket\psi$ in density matrix form is $\rho =\Ket\psi\Bra\psi ={1\over2}\big(I+B_\psi\big) ={1\over2}\big(I+\Braket{X}_\psi X+\Braket{Y}_\psi Y+\Braket{Z}_\psi Z\big) .$

In other words, $\rho$ is the average of $I$ and $B_\psi$.


Given an arbitrary state $\Ket\phi,~ B_\psi\Ket\phi=\Braket{X}_\psi X\Ket\phi+\Braket{Y}_\psi Y\Ket\phi+\Braket{Z}_\psi Z\Ket\phi.$


A density matrix is also a projector, so $\rho\Ket\phi$ can be interpreted as rotating $\Ket\phi$ by $\pi$ about $\Ket\psi$ by applying the Bloch Operator then taking an "average" on $\Ket\phi$ itself (the identity matrix), hence the sum divided by two.

Note: $R_\psi(\theta) =e^{-i\frac{\theta}{2}B_\psi} =I\cos\frac{\theta}{2}-iB_\psi\sin\frac{\theta}{2} .~~$ For details, please refer to the Rotation: Matrix Exponential articles.


Let $\Ket\psi=\alpha\Ket0+\beta\Ket1,~~\alpha,\beta\in\mathbb{C}.~~$ So $\rho=\Ket\psi\Bra\psi =\begin{bmatrix}\alpha\alpha^*&\alpha\beta^*\\\alpha^*\beta&\beta\beta^*\end{bmatrix},~~$ and $\Braket{\psi\Verti\psi}=\alpha\alpha^*+\beta\beta^*=1$.

$\Braket{X}_\psi =\Braket{\psi\lvert X\rvert\psi} =(\alpha^*\Bra0+\beta^*\Bra1)~(\Ket0\Bra1+\Ket1\Bra0)~(\alpha\Ket0+\beta\Ket1) =\alpha^*\beta+\alpha\beta^* .$

$\Braket{Y}_\psi =\Braket{\psi\lvert Y\rvert\psi} =(\alpha^*\Bra0+\beta^*\Bra1)~(-i\Ket0\Bra1+i\Ket1\Bra0)~(\alpha\Ket0+\beta\Ket1) =-i\alpha^*\beta+i\alpha\beta^* .$

$\Braket{Z}_\psi =\Braket{\psi\lvert Z\rvert\psi} =(\alpha^*\Bra0+\beta^*\Bra1)~(\Ket0\Bra0-\Ket1\Bra1)~(\alpha\Ket0+\beta\Ket1) =\alpha^*\alpha-\beta^*\beta .$

$I+\Braket{X}_\psi X+\Braket{Y}_\psi Y+\Braket{Z}_\psi Z$

$=\begin{bmatrix}(\alpha\alpha^*+\beta\beta^*)&0\\0&(\alpha\alpha^*+\beta\beta^*)\end{bmatrix} +\begin{bmatrix}0&(\alpha^*\beta+\alpha\beta^*)\\(\alpha^*\beta+\alpha\beta^*)&0\end{bmatrix} +\begin{bmatrix}0&-i(-i\alpha^*\beta+i\alpha\beta^*)\\i(-i\alpha^*\beta+i\alpha\beta^*)&0\end{bmatrix} +\begin{bmatrix}(\alpha\alpha^*-\beta\beta^*)&0\\0&-(\alpha\alpha^*-\beta\beta^*)\end{bmatrix}$

$=\begin{bmatrix} (\alpha\alpha^*+\beta\beta^*)+(\alpha\alpha^*-\beta\beta^*) & (\alpha^*\beta+\alpha\beta^*)-i(-i\alpha^*\beta+i\alpha\beta^*)\\ (\alpha^*\beta+\alpha\beta^*)+i(-i\alpha^*\beta+i\alpha\beta^*) & (\alpha\alpha^*+\beta\beta^*)-(\alpha\alpha^*-\beta\beta^*) \end{bmatrix} =\begin{bmatrix}2\alpha\alpha^* & 2\alpha\beta^*\\ 2\alpha^*\beta & 2\beta\beta^* \end{bmatrix} =2\rho .$

In [5]:
# quantum_phase_bloch.py
import numpy as np

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute
from qiskit.tools.visualization import plot_bloch_vector

# Define the Quantum and Classical Registers
q = QuantumRegister(1)
c = ClassicalRegister(1)

# Build the circuits
pre = QuantumCircuit(q, c)
pre.h(q)
pre.barrier()

meas_x = QuantumCircuit(q, c)
meas_x.barrier()
meas_x.h(q)
meas_x.measure(q, c)

meas_y = QuantumCircuit(q, c)
meas_y.barrier()
meas_y.s(q).inverse()
meas_y.h(q)
meas_y.measure(q, c)

meas_z = QuantumCircuit(q, c)
meas_z.barrier()
meas_z.measure(q, c)

bloch_vector = ['x', 'y', 'z']
exp_vector = range(0, 21)
circuits = []
for exp_index in exp_vector:
    middle = QuantumCircuit(q, c)
    phase = 2*np.pi*exp_index/(len(exp_vector)-1)
    middle.u1(phase, q)
    circuits.append(pre + middle + meas_x)
    circuits.append(pre + middle + meas_y)
    circuits.append(pre + middle + meas_z)

#print(len(circuits))
#print(exp_vector)

# Execute the circuit
job = execute(circuits, backend = 'local_qasm_simulator', shots=1024)
result = job.result()

# Plot the result
for exp_index in exp_vector:
    bloch = [0, 0, 0]
    for bloch_index in range(len(bloch_vector)):
        data = result.get_counts(circuits[3*exp_index+bloch_index])
        print(data)
        try:
            p0 = data['0']/1024.0
        except KeyError:
            p0 = 0
        try:
            p1 = data['1']/1024.0
        except KeyError:
            p1 = 0
        bloch[bloch_index] = p0-p1
    plot_bloch_vector(bloch)
{'0': 1024}
{'0': 503, '1': 521}
{'0': 484, '1': 540}
{'0': 994, '1': 30}
{'0': 674, '1': 350}
{'0': 557, '1': 467}
{'0': 916, '1': 108}
{'0': 812, '1': 212}
{'0': 500, '1': 524}
{'0': 808, '1': 216}
{'0': 934, '1': 90}
{'0': 512, '1': 512}
{'0': 664, '1': 360}
{'0': 1005, '1': 19}
{'0': 500, '1': 524}
{'0': 501, '1': 523}
{'0': 1024}
{'0': 507, '1': 517}
{'0': 335, '1': 689}
{'0': 997, '1': 27}
{'0': 507, '1': 517}
{'0': 206, '1': 818}
{'0': 937, '1': 87}
{'0': 493, '1': 531}
{'0': 77, '1': 947}
{'0': 809, '1': 215}
{'0': 514, '1': 510}
{'0': 33, '1': 991}
{'0': 701, '1': 323}
{'0': 519, '1': 505}
{'1': 1024}
{'0': 499, '1': 525}
{'0': 541, '1': 483}
{'0': 24, '1': 1000}
{'0': 357, '1': 667}
{'0': 489, '1': 535}
{'0': 82, '1': 942}
{'0': 230, '1': 794}
{'0': 533, '1': 491}
{'0': 228, '1': 796}
{'0': 93, '1': 931}
{'0': 508, '1': 516}
{'0': 360, '1': 664}
{'0': 19, '1': 1005}
{'0': 520, '1': 504}
{'0': 526, '1': 498}
{'1': 1024}
{'0': 501, '1': 523}
{'0': 667, '1': 357}
{'0': 26, '1': 998}
{'0': 468, '1': 556}
{'0': 816, '1': 208}
{'0': 79, '1': 945}
{'0': 504, '1': 520}
{'0': 936, '1': 88}
{'0': 218, '1': 806}
{'0': 515, '1': 509}
{'0': 1001, '1': 23}
{'0': 337, '1': 687}
{'0': 493, '1': 531}
{'0': 1024}
{'0': 487, '1': 537}
{'0': 537, '1': 487}

 

<< Bloch Sphere Orthonormality Top Eigenstate of Multi-Qubits >>