Qubit quantum expectations

Module name: pennylane.expval.qubit

This section contains the available built-in discrete-variable quantum operations supported by PennyLane, as well as their conventions.

Note

Currently, all expectation commands return scalars.

Summary

PauliX(wires) Expectation value of PauliX.
PauliY(wires) Expectation value of PauliY.
PauliZ(wires) Expectation value of PauliZ.
Hadamard(wires) Expectation value of the Hadamard observable.
Hermitian(A, wires) Expectation value of an arbitrary Hermitian observable.
Identity(wires) Expectation value of the identity observable \(\I\).

Code details

class PauliX(wires)[source]

Expectation value of PauliX.

This expectation command returns the value

\[\braket{\sigma_z} = \braketT{\psi}{\cdots \otimes I\otimes \sigma_x\otimes I\cdots}{\psi}\]

where \(\sigma_x\) acts on the requested wire.

Details:

  • Number of wires: 1
  • Number of parameters: 0
Parameters:wires (Sequence[int] or int) – the wire the operation acts on
class PauliY(wires)[source]

Expectation value of PauliY.

This expectation command returns the value

\[\braket{\sigma_z} = \braketT{\psi}{\cdots \otimes I\otimes \sigma_y\otimes I\cdots}{\psi}\]

where \(\sigma_y\) acts on the requested wire

Details:

  • Number of wires: 1
  • Number of parameters: 0
Parameters:wires (Sequence[int] or int) – the wire the operation acts on
class PauliZ(wires)[source]

Expectation value of PauliZ.

This expectation command returns the value

\[\braket{\sigma_z} = \braketT{\psi}{\cdots \otimes I\otimes \sigma_z\otimes I\cdots}{\psi}\]

where \(\sigma_z\) acts on the requested wire.

Details:

  • Number of wires: 1
  • Number of parameters: 0
Parameters:wires (Sequence[int] or int) – the wire the operation acts on
class Hadamard(wires)[source]

Expectation value of the Hadamard observable.

This expectation command returns the value

\[\braket{H} = \braketT{\psi}{\cdots \otimes I\otimes H\otimes I\cdots}{\psi}\]

where \(H\) acts on the requested wire.

Details:

  • Number of wires: 1
  • Number of parameters: 0
Parameters:wires (Sequence[int] or int) – the wire the operation acts on
class Hermitian(A, wires)[source]

Expectation value of an arbitrary Hermitian observable.

For a Hermitian matrix \(A\), this expectation command returns the value

\[\braket{A} = \braketT{\psi}{\cdots \otimes I\otimes A\otimes I\cdots}{\psi}\]

where \(A\) acts on the requested wire.

Parameters:
  • A (array) – square hermitian matrix.
  • wires (Sequence[int] or int) – the wire the operation acts on
class Identity(wires)[source]

Expectation value of the identity observable \(\I\).

The expectation of this observable

\[E[\I] = \text{Tr}(\I \rho)\]

corresponds to the trace of the quantum state, which in exact simulators should always be equal to 1.

Note

Can be used to check normalization in approximate simulators.