Download Notebook

Quantum System, State, Measurement, and Gate

Here we explain how to treat quatum system, state, measurement, and gate in Quara.

Quantum System

In Quara, a quantum system is treated by a class, CompositeSystem, which consists of multiple ElementalSystem.

[1]:
from quara.objects.composite_system_typical import generate_composite_system
[2]:
mode_sys = 'qubit'
num_sys = 1
c_sys = generate_composite_system(mode=mode_sys, num=num_sys)
print('type(c_sys)=', type(c_sys))
print('\nc_sys:\n',c_sys)
type(c_sys)= <class 'quara.objects.composite_system.CompositeSystem'>

c_sys:
 elemental_systems:
[0] 0 (system_id=4587542032)

dim: 2
basis:
(array([[0.70710678+0.j, 0.        +0.j],
       [0.        +0.j, 0.70710678+0.j]]), array([[0.        +0.j, 0.70710678+0.j],
       [0.70710678+0.j, 0.        +0.j]]), array([[0.+0.j        , 0.-0.70710678j],
       [0.+0.70710678j, 0.+0.j        ]]), array([[ 0.70710678+0.j,  0.        +0.j],
       [ 0.        +0.j, -0.70710678+0.j]]))

The composite system includes information of dimension of the system and orthonormal matrix basis on the system.

State

State is treated by a class State.

[3]:
from quara.objects.qoperation_typical import generate_qoperation
[4]:
mode_qoperation = 'state'
name_state = 'z0'
state = generate_qoperation(mode=mode_qoperation, name=name_state, c_sys=c_sys)
print('type(state)=', type(state))
print('\nstate:\n', state)
type(state)= <class 'quara.objects.state.State'>

state:
 Type:
State

Dim:
2

Vec:
[0.70710678 0.         0.         0.70710678]

The State class contains the vectorized density matrix with respect to the matrix basis in c_sys.

Measurement (POVM)

Quantum measurement has two mathematical treatments. One is positive operator-valued measure (POVM), which can describe the effect of quantum measurement on the probability distribution of its measurement outcome only. The other is measurement apparatus, which can describe both of the effect on the probability distribution and states after the measurement. Current version of quara prepare a class for POVM only. A class for measurement apparatus will be added in the near future.

[5]:
mode_qoperation = 'povm'
name_povm = 'z'
povm = generate_qoperation(mode=mode_qoperation, name=name_povm, c_sys=c_sys)
print('type(povm)=', type(povm))
print('\npovm:\n', povm)
type(povm)= <class 'quara.objects.povm.Povm'>

povm:
 Type:
Povm

Dim:
2

Number of outcomes:
2

Vecs:
[[ 0.70710678  0.          0.          0.70710678]
 [ 0.70710678  0.          0.         -0.70710678]]

The Povm class contains the list of vectorized POVM elements with respect to the matrix basis in c_sys.

Gate

Mathematically a quantum gate is a linear trace-preserving and completely positive (L-TPCP) map on the space of quantum states, and there are several different matrix representations for quantum gate. In Quara, a class Gate is based on the Hilbert-Schmidt matrix representation of a gate with respect to the matrix basis in the CompositeSystem.

[6]:
mode_qoperation = 'gate'
name_gate = 'hadamard'
gate = generate_qoperation(mode=mode_qoperation, name=name_gate, c_sys=c_sys)
print('type(gate)=', type(gate))
print('\ngate:\n', gate)
type(gate)= <class 'quara.objects.gate.Gate'>

gate:
 Type:
Gate

Dim:
2

HS:
[[ 1.  0.  0.  0.]
 [ 0.  0.  0.  1.]
 [ 0.  0. -1.  0.]
 [ 0.  1.  0.  0.]]
[ ]:

Download Notebook