Module: pennylane

class Hermitian(A, wires)[source]

An arbitrary Hermitian observable.

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

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

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

If acting on \(N\) wires, then the matrix \(A\) must be of size \(2^N\times 2^N\).


  • Number of wires: Any
  • Number of parameters: 1
  • Gradient recipe: None
  • A (array) – square hermitian matrix
  • wires (Sequence[int] or int) – the wire(s) the operation acts on