Module: pennylane

class PolyXP(q, wires)[source]

An arbitrary second-order polynomial observable.

Represents an arbitrary observable \(P(\x,\p)\) that is a second order polynomial in the basis \(\mathbf{r} = (\I, \x_0, \p_0, \x_1, \p_1, \ldots)\).

For first-order observables the representation is a real vector \(\mathbf{d}\) such that \(P(\x,\p) = \mathbf{d}^T \mathbf{r}\).

For second-order observables the representation is a real symmetric matrix \(A\) such that \(P(\x,\p) = \mathbf{r}^T A \mathbf{r}\).

Used by QNode._pd_analytic() for evaluating arbitrary order-2 CV expectation values.


  • Number of wires: Any
  • Number of parameters: 1
  • Observable order: 2nd order in the quadrature operators
  • Heisenberg representation: \(A\)
Parameters:q (array[float]) – expansion coefficients