Quantum Measurements and Observables in Qutip

Mihirsinh Chauhan
2 min readSep 12, 2023

--

Welcome to Day 12 of our journey into the world of quantum computing with Qutip. Today, we’ll delve into quantum measurements and observables using Qutip. Understanding how to perform measurements and work with observables is essential for quantum algorithms and quantum information processing.

Quantum Measurements and Observables:

In quantum mechanics, measurements play a crucial role in obtaining information about a quantum system. Observable quantities are represented by Hermitian operators, and the expectation values of these operators provide the probabilities of measurement outcomes.

Let’s explore quantum measurements and observables using Qutip:

Defining Observables:

Observables in quantum mechanics are represented by Hermitian operators. Qutip allows us to define and work with these operators easily. For example, to define a Pauli-X operator (σx​):

import qutip as qt

# Define the Pauli-X operator
sigma_x = qt.sigmax()

You can similarly define σy​, σz​, or custom observables.

Calculating Expectation Values:

To calculate the expectation value of an observable for a given quantum state, you can use the qt.expect() function. Here's an example of calculating the expectation value of σz​ for a qubit in the state ∣0⟩:

# Define the observable (σz) and the state (|0⟩)
sigma_z = qt.sigmaz()
psi = qt.basis(2, 0) # |0⟩

# Calculate the expectation value <σz>
expectation_value = qt.expect(sigma_z, psi)
print(expectation_value)

output:

1.0

expectation_value now contains the expectation value of σz​ for the state ∣0⟩.

Performing Quantum Measurements:

Qutip allows you to simulate quantum measurements using the qt.measure() function. This function returns the outcome of a measurement and the post-measurement state. Here's an example:

# Define a qubit in a superposition state
psi = (qt.basis(2, 0) + qt.basis(2, 1)).unit()

# Perform a measurement in the Z-basis
outcome, post_measurement_state = qt.measurement.measure(psi,qt.sigmaz())
print(outcome,post_measurement_state)

output:

1.0 Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket
Qobj data =
[[-1.]
[ 0.]]

outcome contains the measurement outcome (0 or 1), and post_measurement_state contains the state after measurement.

Simulating Repeated Measurements:

You can simulate a series of measurements by repeatedly applying qt.measure(). This is useful for studying how measurement statistics evolve over time.

# Define a qubit in a superposition state
psi = (qt.basis(2, 0) + qt.basis(2, 1)).unit()

# Simulate 10 measurements in the Z-basis
measurement_results = [qt.measurement.measure(psi, qt.sigmaz())[0] for _ in range(10)]

output:

[-1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0]

measurement_results contains a list of 10 measurement outcomes.

Conclusion:

In Day 12, we’ve explored quantum measurements and observables using Qutip. You’ve learned how to define observables, calculate expectation values, perform quantum measurements, and simulate repeated measurements. These concepts are fundamental for quantum algorithms, quantum error correction, and quantum information theory. As we continue our journey, we’ll delve into more advanced quantum topics. Stay tuned for more quantum adventures!

#day12 of #quantum30 day challenge

--

--

Mihirsinh Chauhan

《Quantum computing Enthusiast |Future Innovator》《Under grad at SVNIT | ML| Buisness Amateur》