Observable (Obserbable class)

In the context of quantum mechanics, physical values including Hamiltonian etc are called ‘observable’. Unlike classical mechanics, the observalble is expressed by an operator mapping complex vector to complex vector (or a complex matrix), and an observed physical value in the actual measuring device is regarded to an eigenvalue of the operator. Since this eigenvalue must be a real number (It is strange that the measured value is complex number, isn’t it?), the observable operator must be a ‘Hermitian operator’ (see the standard textbook of quantum mechanics for details).

Observalbles often seen in quantum mechanics and quantum information theory are expressed in linear sum of products of pauli operators X, Y and Z.

Qlazy allows you to perform some calculations related to the observables that are represented by the linear sum of the pauli operators. The following calculation can be made for the quantum state of the ‘Qstate’ class.

  • Expectation value of the observable

  • Time development of quantum state of the system with Hamiltonian expressed by the observable

In addtion, the following calculations can be made for the quantum state of the ‘MPState’ class.

  • Expectation value of observable

However, this document does not mention these details. Please refer to the ‘Qstate’ class and the ‘MPState’ class documentation for it. This document describes the method of creating an observable and calculating between the obserbables created like this.

Create observalble

First, for creating observable, import the ‘Observable’ class and the ‘Observable’ related functions X, Y, Z.

>>> from qlazy import Observable
>>> from qlazy.Observable import X,Y,Z

There are three ways to create an observable.

  • Method by specifying a string

  • Method by adding weighted pauli products sequentially

  • Method by specifing a linear sum of pauli products

Method by specifying a string

For example, observable “3.0 Z(0) Z(1) + 4.0 X(2) X(3) 5 Y(4) - 2.0” can be created as follows.

>>> ob = Observable("3.0*Z_0*Z_1+4.0*X_2*X_3+5*Y_4-2.0")

It allowed that there is space before and after ‘+’, ‘-‘ and ‘*’, X, Y, Z can be lowercase letters.

>>> ob = Observable("3.0 * z_0 * z_1 + 4.0 * x_2 * x_3 + 5 * y_4 - 2.0")

You can check the observable using print statements.

>>> print(ob)
3.0 Z(0) Z(1) + 4.0 X(2) X(3) + 5.0 Y(4) - 2.0

Here, there is an important point to describe. Last term of the above example ‘-2.0’ means ‘-2.0 * I’ (‘I’ is an identity operator). In qlazy, a term including identity operator is specified without explicitly describing the identity operator ‘I’, only specified constant real number. Of course, it performs calculations including identity operators.

Method by adding weighted pauli products sequentially

The same observable as the previous section can be created as follows. First, create an empty observable instance.

>>> ob = Observable()

Then, add pauli product and the coefficient (weight) for it by applying the ‘ad_wpp’ method (means add weighted pauli product method) to the created instance.

>>> ob.add_wpp(weight=3.0, pp=PauliProduct('ZZ', [0,1]))
>>> ob.add_wpp(weight=4.0, pp=PauliProduct('XX', [2,3]))
>>> ob.add_wpp(weight=5.0, pp=PauliProduct('Y', [4]))
>>> ob.add_wpp(weight=-2.0)
>>> print(ob)
3.0 Z(0) Z(1) + 4.0 X(2) X(3) + 5.0 Y(4) - 2.0

Method by specifing a linear sum of pauli products

When creating in this method, the X, Y and Z function must be imported.

>>> from qlazy.Qbservable import X, Y, Z

Then, the observable of the previous section can be created as follows.

>>> ob = 3.0 * Z(0) * Z(1) + 4.0 * X(2) * X(3) + 5.0 * Y(4) - 2.0
>>> print(ob)
3.0 Z(0) Z(1) + 4.0 X(2) X(3) + 5.0 Y(4) - 2.0