# Displacement¶

Module: pennylane

class Displacement(a, phi, wires)[source]

Phase space displacement.

$D(a,\phi) = D(\alpha) = \exp(\alpha \ad -\alpha^* \a) = \exp\left(-i\sqrt{\frac{2}{\hbar}}(\re(\alpha) \hat{p} -\im(\alpha) \hat{x})\right).$

where $$\alpha = ae^{i\phi}$$ has magnitude $$a\geq 0$$ and phase $$\phi$$. The result of applying a displacement to the vacuum is a coherent state $$D(\alpha)\ket{0} = \ket{\alpha}$$.

Details:

• Number of wires: 1

• Number of parameters: 2

• Gradient recipe: $$\frac{d}{da}f(D(a,\phi)) = \frac{1}{2s} \left[f(D(a+s, \phi)) - f(D(a-s, \phi))\right]$$, where $$s$$ is an arbitrary real number ($$0.1$$ by default) and $$f$$ is an expectation value depending on $$D(a,\phi)$$.

• Heisenberg representation:

$\begin{split}M = \begin{bmatrix} 1 & 0 & 0 \\ 2a\cos\phi & 1 & 0 \\ 2a\sin\phi & 0 & 1\end{bmatrix}\end{split}$
Parameters: a (float) – displacement magnitude $$a=|\alpha|$$ phi (float) – phase angle $$\phi$$ wires (Sequence[int] or int) – the wire the operation acts on