# sf.ops.Dgate¶

class Dgate(r, phi=0.0)[source]

Bases: strawberryfields.ops.Gate

Phase space displacement gate.

$D(\alpha) = \exp(\alpha a^\dagger -\alpha^* a) = \exp\left(-i\sqrt{2}(\re(\alpha) \hat{p} -\im(\alpha) \hat{x})/\sqrt{\hbar}\right)$

where $$\alpha = r e^{i\phi}$$ has magnitude $$r\geq 0$$ and phase $$\phi$$.

The gate is parameterized so that a user can specify a single complex number $$a=\alpha$$ or use the polar form $$a = r, \phi$$ and still get the same result.

Parameters
• r (float) – displacement magnitude $$|\alpha|$$

• phi (float) – displacement angle $$\phi$$

Definition

$D(\alpha) = \exp( \alpha \ad -\alpha^* \a) = \exp(r (e^{i\phi}\ad -e^{-i\phi}\a)), \quad D^\dagger(\alpha) \a D(\alpha)=\a +\alpha\I$

where $$\alpha=r e^{i \phi}$$ with $$r \geq 0$$ and $$\phi \in [0,2 \pi)$$.

We obtain for the position and momentum operators

$\begin{split}D^\dagger(\alpha) \x D(\alpha) = \x +\sqrt{2 \hbar } \re(\alpha) \I,\\ D^\dagger(\alpha) \p D(\alpha) = \p +\sqrt{2 \hbar } \im(\alpha) \I.\end{split}$

The matrix elements of the displacement operator in the Fock basis were derived by Cahill and Glauber [26]:

$\bra{m}\hat D(\alpha) \ket{n} = \sqrt{\frac{n!}{m!}} \alpha^{m-n} e^{-|\alpha|^2/2} L_n^{m-n}\left( |\alpha|^2 \right)$

where $$L_n^{m}(x)$$ is a generalized Laguerre polynomial [27].

 H Returns a copy of the gate with the self.dagger flag flipped. measurement_deps Extra dependencies due to parameters that depend on measurements. ns
H

Returns a copy of the gate with the self.dagger flag flipped.

H stands for hermitian conjugate.

Returns

formal inverse of this gate

Return type

Gate

measurement_deps

Extra dependencies due to parameters that depend on measurements.

Returns

dependencies

Return type

set[RegRef]

ns = 1
 apply(reg, backend, **kwargs) Ask a backend to execute the operation on the current register state right away. decompose(reg, **kwargs) Decompose the operation into elementary operations supported by the backend API. merge(other) Merge the operation with another (acting on the exact same set of subsystems).
apply(reg, backend, **kwargs)

Ask a backend to execute the operation on the current register state right away.

Like Operation.apply(), but takes into account the special nature of p[0] and applies self.dagger.

Returns

Gates do not return anything, return value is None

Return type

None

decompose(reg, **kwargs)

Decompose the operation into elementary operations supported by the backend API.

Like Operation.decompose(), but applies self.dagger.

merge(other)

Merge the operation with another (acting on the exact same set of subsystems).

Note

For subclass overrides: merge may return a newly created object, or self, or other, but it must never modify self or other because the same Operation objects may be also used elsewhere.

Parameters

other (Operation) – operation to merge this one with

Returns

other * self. The return value None represents the identity gate (doing nothing).

Return type

Operation, None

Raises

MergeFailure – if the two operations cannot be merged