Quantum density matrix in the computational basis.
This function accepts no observables and instead instructs the QNode to return its density matrix or reduced density matrix. The
wiresargument gives the possibility to trace out a part of the system. It can result in obtaining a mixed state, which can be only represented by the reduced density matrix.
wires (Sequence[int] or int) – the wires of the subsystem
Measurement process instance
- Return type
dev = qml.device("default.qubit", wires=2) @qml.qnode(dev) def circuit(): qml.PauliY(wires=0) qml.Hadamard(wires=1) return qml.density_matrix()
Executing this QNode:
>>> circuit() array([[0.+0.j 0.+0.j] [0.+0.j 1.+0.j]])
The returned matrix is the reduced density matrix, where system 1 is traced out.
Calculating the derivative of
density_matrix()is currently only supported when using the classical backpropagation differentiation method (
diff_method="backprop") with a compatible device.
- What is PennyLane?
- Quantum circuits
- Gradients and training
- Quantum operators
- Inspecting circuits
- Compiling circuits
- Quantum Chemistry
- Quantum Datasets
- QNode returns