Gaussian State#

class GaussianState(d: int, calculator: piquasso.api.calculator.BaseCalculator, config: Optional[piquasso.api.config.Config] = None)#

Class to represent a Gaussian state.

Parameters

d (int) – The number of modes.

property d: int#

The number of modes.

reset() None#

Resets the state to a vacuum.

validate() None#

Validates the state.

Raises

InvalidState – Raised if the underlying Gaussian state is invalid, which could mean - ill-shaped mean and covariance; - non-symmetric covariance matrix; - the covariance matrix doesn’t fulfill the Robertson-Schrödinger uncertainty relations.

property xxpp_mean_vector: numpy.ndarray#

The state’s mean in the xxpp-ordered basis.

The expectation value of the quadrature operators in xxpp basis, i.e. \(\operatorname{Tr} \left ( \rho Y \right )\), where \(Y = (x_1, \dots, x_d, p_1, \dots, p_d)^T\).

Returns

A \(2d\)-vector where \(d\) is the number of modes.

Return type

numpy.ndarray

property xxpp_covariance_matrix: numpy.ndarray#

The xxpp-ordered coveriance matrix of the state.

The xxpp-ordered covariance matrix \(\sigma_{xp}\) is defined by

\[\sigma_{xp, ij} := \langle Y_i Y_j + Y_j Y_i \rangle_\rho - 2 \langle Y_i \rangle_\rho \langle Y_j \rangle_\rho,\]

where

\[Y = (x_1, \dots, x_d, p_1, \dots, p_d)^T,\]

and \(\rho\) is the density operator of the currently represented state.

Returns

The \(2d \times 2d\) xp-ordered covariance matrix.

Return type

numpy.ndarray

property xxpp_correlation_matrix: numpy.ndarray#

The state’s correlation matrix in the xxpp basis.

Let \(M_{(xxpp)}\) be the correlation matrix in the xxpp basis. Then

\[M_{ij (xxpp)} = \langle Y_i Y_j + Y_j Y_i \rangle_\rho,\]

where \(M_{ij (xxpp)}\) denotes the matrix element in the \(i\)-th row and \(j\)-th column,

\[Y = (x_1, \dots, x_d, p_1, \dots, p_d)^T,\]

and \(\rho\) is the density operator of the currently represented state.

Returns

The \(2d \times 2d\) correlation matrix in the xxpp-basis.

Return type

numpy.ndarray

property xxpp_representation: Tuple[numpy.ndarray, numpy.ndarray]#

The state’s mean and correlation matrix ordered in the xxpp basis.

Returns

xxpp_mean_vector(), xxpp_correlation_matrix().

Return type

tuple

property xpxp_mean_vector: numpy.ndarray#

Returns the xpxp-ordered mean of the state.

Returns

A \(2d\)-vector. The expectation value of the quadrature operators in xxpp-ordering, i.e. \(\operatorname{Tr} \rho R\), where \(R = (x_1, p_1, \dots, x_d, p_d)^T\).

Return type

numpy.ndarray

property xpxp_covariance_matrix: numpy.ndarray#

The xpxp-ordered coveriance matrix of the state.

The xpxp-ordered covariance matrix \(\sigma\) is defined by

\[\sigma_{ij} := \langle R_i R_j + R_j R_i \rangle_\rho - 2 \langle R_i \rangle_\rho \langle R_j \rangle_\rho,\]

where

\[R = (x_1, p_1, \dots, x_d, p_d)^T,\]

and \(\rho\) is the density operator of the currently represented state.

Returns

The \(2d \times 2d\) xpxp-ordered covariance matrix in xpxp-ordered basis.

Return type

numpy.ndarray

property xpxp_correlation_matrix: numpy.ndarray#

The xpxp-ordered correlation matrix of the state.

Let \(M\) be the correlation matrix in the xpxp basis. Then

\[M_{ij} = \langle R_i R_j + R_j R_i \rangle_\rho,\]

where \(M_{ij}\) denotes the matrix element in the \(i\)-th row and \(j\)-th column,

\[R = (x_1, p_1, \dots, x_d, p_d)^T,\]

and \(\rho\) is the density operator of the currently represented state.

Returns

The \(2d \times 2d\) xpxp-ordered correlation matrix.

Return type

numpy.ndarray

property xpxp_representation: Tuple[numpy.ndarray, numpy.ndarray]#

The state’s mean and correlation matrix ordered by the xpxp basis.

Returns

mean(), corr().

Return type

tuple

property complex_displacement: numpy.ndarray#

The complex displacement of the state.

The complex displacement is defined by

\[\mu_{c} := \begin{bmatrix} \langle a_1 \rangle_{\rho}, \dots, \langle a_d \rangle_{\rho}, \langle a^\dagger_1 \rangle_{\rho}, \dots, \langle a^\dagger_d \rangle_{\rho} \end{bmatrix}.\]

Equivalently, one can write

\[\mu_{c} := W \mu_{xxpp},\]

where \(\mu_{xxpp}\) is the xxpp-ordered mean vector xxpp_mean_vector and

\[\begin{split}W = \frac{1}{\sqrt{2}} \begin{bmatrix} I_{d} & i I_{d} \\ I_{d} & -i I_{d} \end{bmatrix}.\end{split}\]
Returns

The complex displacement.

Return type

numpy.ndarray

property complex_covariance: numpy.ndarray#

The complex covariance of the state.

The complex covariance is defined by

\[\sigma_{c, ij} = \langle \xi_i \xi^\dagger_j + \xi_j \xi^\dagger_i \rangle_{\rho} - 2 \langle \xi_i \rangle_{\rho} \langle \xi^\dagger_j \rangle_{\rho},\]

where

\[\xi = \begin{bmatrix} a_1, \dots a_d, a^\dagger_1, \dots, a^\dagger_d \end{bmatrix}.\]

Equivalently, one can write

\[\sigma_{c} = \frac{1}{\hbar} W \sigma_{xxpp} W^{\dagger},\]

where \(\sigma_{xxpp}\) is the xxpp-ordered covariance matrix xxpp_cov and

\[\begin{split}W = \frac{1}{\sqrt{2}} \begin{bmatrix} I_{d} & i I_{d} \\ I_{d} & -i I_{d} \end{bmatrix}.\end{split}\]
Returns

The complex covariance.

Return type

numpy.ndarray

rotated(phi: float) piquasso._backends.gaussian.state.GaussianState#

Returns a copy of the current Gaussian state, rotated by an angle phi.

Let \(\phi \in [ 0, 2 \pi )\). Let us define the following:

\[x_{i, \phi} = \cos\phi~x_i + \sin\phi~p_i,\]

which is a generalized quadrature operator. One could rotate the state by a simple complex phase, which can be shown by using the transformation rules between the ladder operators and quadrature operators, i.e.

\[\begin{split}x_i &= \sqrt{\frac{\hbar}{2}} (a_i + a_i^\dagger) \\ p_i &= -i \sqrt{\frac{\hbar}{2}} (a_i - a_i^\dagger),\end{split}\]

which we could rewrite \(x_{i, \phi}\) to

\[x_{i, \phi} = \sqrt{\frac{\hbar}{2}} \left( a_i \exp(-i \phi) + a_i^\dagger \exp(i \phi) \right),\]

meaning that e.g. the annihilation operators \(a_i\) are transformed just by multiplying it with a phase factor \(\exp(-i \phi)\) i.e.

\[\begin{split}(\langle a_i \rangle_{\rho} =: )~m_i &\mapsto \exp(-i \phi) m_i \\ (\langle a^\dagger_i a_j \rangle_{\rho} =: )~C_{ij} &\mapsto C_{ij} \\ (\langle a_i a_j \rangle_{\rho} =: )~G_{ij} &\mapsto \exp(-i 2 \phi) G_{ij}.\end{split}\]
Parameters

phi (float) – The angle to rotate the state with.

Returns

The rotated GaussianState instance.

Return type

GaussianState

reduced(modes: Tuple[int, ...]) piquasso._backends.gaussian.state.GaussianState#

Returns a copy of the current state, reduced to the given modes.

This method essentially preserves the modes specified from the representation of the Gaussian state, but cuts out the other modes.

Parameters

modes (tuple[int]) – The modes to reduce the state to.

Returns

The reduced GaussianState instance.

Return type

GaussianState

xpxp_reduced_rotated_mean_and_covariance(modes: Tuple[int, ...], phi: float) Tuple[numpy.ndarray, numpy.ndarray]#

The mean and covariance on a rotated and reduced state.

Let the index set \(\vec{i}\) correspond to modes, and the angle \(\phi\) correspond to phi. The current GaussianState instance is reduced to modes and rotated by phi in a new instance, and let that state be denoted by \(\rho_{\vec{i}, \phi}\).

Then the xpxp-ordered mean and covariance can be calculated by

\[\begin{split}\mu_{\vec{i}, \phi} &:= \langle R_{\vec{i}} \rangle_{\rho_{\vec{i}, \phi}}, \\ \sigma_{\vec{i}, \phi} &:= \langle R_{\vec{i}} R_{\vec{i}}^T \rangle_{\rho_{\vec{i}, \phi}} - \mu_{\vec{i}, \phi} \mu_{\vec{i}, \phi}^T,\end{split}\]

where

\[R = (x_1, p_1, \dots, x_d, p_d)^T,\]

and \(R_{\vec{i}}\) is just the same vector, reduced to a subsystem specified by \(\vec{i}\).

Parameters
  • modes (tuple[int]) – The modes to reduce the state to.

  • phi (float) – The angle to rotate the state with.

Returns

xpxp-ordered mean and covariance of the reduced and rotated version of the current GaussianState.

Return type

(numpy.ndarray, numpy.ndarray)

mean_photon_number(modes: Tuple[int, ...]) float#

This method returns the mean photon number of the given modes. The mean photon number \(\bar{n} = \langle \hat{n} \rangle\) can be calculated in terms of the ladder operators by the following expression

\[\sum_{i=1}^{d} \langle a_{i}^\dagger a_{i} \rangle = \operatorname{Tr}(\rho \hat{n}),\]

where \(a\), \(a ^\dagger\) are the annihilation and the creation operators respectively, \(\rho\) is the density operator of the currently represented state and \(d\) is the number of modes. For a general displaced squeezed gaussian state, the mean photon number is

\[\langle \hat{n} \rangle = \operatorname{Tr}(\langle a^\dagger a \rangle) + \mu_{c}^ \dagger \cdot \mu_{c},\]

where \(\mu_{c}\) is the complex_displacement.

Note

This method can also be used to return the summation of the mean photon number for multiple modes if the mode parameter contains more than one integer e.g \((0,1,...)\).

Parameters

modes (tuple[int]) – The correspoding modes at which the mean photon number is calculated.

Returns

The expectation value of the photon number.

Return type

float

variance_photon_number(modes: Tuple[int, ...]) float#

This method calculates the variance of the photon number operator as follows:

\[\operatorname{\textit{Var(n)}} = \frac{1}{2} \operatorname{Tr}( \sigma_{ij}/2\hbar)^2 + \det (\sigma_{ij}/2\hbar) + \frac{1}{2} \left \langle Q \right \rangle (\sigma_{ij}/2\hbar) \left \langle Q \right \rangle - 0.25\]

where \(\sigma_{ij}\) is the reduced xpxp_covariance_matrix since \(i = j\) i.e. the covariance matrix of the reduced Gaussian state and \(\left \langle Q \right \rangle\) is the xpxp_mean_vector.

For more details please see this article.

Parameters

modes (Tuple[int, ...]) – The correspoding modes at which the variance of the photon number is calculated.

Returns

Variance of the photon number operator

Return type

float

fidelity(state: piquasso._backends.gaussian.state.GaussianState) float#

Calculates the state fidelity between two quantum states.

The state fidelity \(F\) between two density matrices \(\rho_1, \rho_2\) is given by:

\[\operatorname{F}(\rho_1, \rho_2) = \operatorname{Tr}(\sqrt{\sqrt{\rho_1} \rho_2\sqrt{\rho_1}})^2\]

A gaussian state can be represented by its Covariance matrix and the vector of Means. Hence, the above equation can be rewritten as:

\[\operatorname{F} = \operatorname{F_0}(V_1, V_2) \exp( -\frac{1}{2} \delta_u^T(V_1 + V_2)^{-1}\delta_u^T)\]

where \(V\) is the xpxp_covariance_matrix of the gaussian state, \(\delta_u\) is the difference between mean vectors of the two gaussian states represented by xpxp_mean_vector, and \(F_0\) is given by:

\[\operatorname{F_0} = \sqrt{\det{[2(\sqrt{I + \frac{(V_{aux}\Omega)^-2}{4}} + I)V_{aux}]} \det{[(V_1 + V_2)^{-1}]}}\]

where \(V_{aux}\) is given by

\[\Omega^T (V_1 + V_2)^{-1} (\frac{\Omega}{4} V_2 \Omega V_1)\]

and \(\Omega\) is a symplectic matrix of shape \(2*d \times 2*d\). For more details please check: https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.115.260501.

Parameters

state – A gaussian state GaussianState that can be used to calculate the fidelity aganist it.

Returns

The calculated fidelity.

Return type

float

quadratic_polynomial_expectation(A: numpy.ndarray, b: numpy.ndarray, c: float = 0.0, phi: float = 0.0) float#

The expectation value of the specified quadratic polynomial.

A quadratic polynomial can be written as

\[f(R) = R^T A R + R \cdot b + c,\]

where \(R = (x_1, p_1, \dots, x_d, p_d)^T\) is the vector of the quadrature operators where \(d\) is the number of modes, \(A \in \mathbb{R}^{2d \times 2d}\) is a symmetric matrix, \(b \in \mathbb{R}^{2d}\), and \(c\in\mathbb{R}\).

This method returns the expectation value \(E[f(R)]\) using the following equation:

\[\operatorname{E}[f(R)] = \operatorname{Tr}[ A\sigma ] + \mu^T A \mu + \mu^T b + c,\]

where \(\sigma\) is the covariance matrix, \(\mu = E[R]\) is the mean of the quadrature operators and

\[\operatorname{E}[\cdot] = \operatorname{Tr}[\cdot \rho],\]

where \(\rho\) is the density matrix of the state.

Parameters
  • A (numpy.ndarray) – A \(2d \times 2d\) real symmetric matrix corresponding to the quadratic coefficients, where \(d\) is the number of modes.

  • b (numpy.ndarray) – A one-dimensional \(2d\)-length real-valued vector that corresponds to the first order terms of the quadratic polynomial.

  • c (float) – The constant term in the quadratic polynomial. Defaults to 0.

  • phi (float) – Rotation angle, by which the state is rotated. Defaults to 0.

Returns

The expectation value of the quadratic polynomial.

Return type

float

wigner_function(positions: List[List[float]], momentums: List[List[float]], modes: Optional[Tuple[int, ...]] = None) numpy.ndarray#

This method calculates the Wigner function values at the specified position and momentum vectors, according to the following equation:

\[W(r) = \frac{1}{\pi^d \sqrt{\mathrm{det} \sigma}} \exp \big ( - (r - \mu)^T \sigma^{-1} (r - \mu) \big ).\]
Parameters
  • positions (list[list[float]]) – List of position vectors.

  • momentums (list[list[float]]) – List of momentum vectors.

  • modes (tuple[int], optional) – Modes where Wigner function should be calculcated.

Returns

The Wigner function values in the shape of a grid specified by the input.

Return type

numpy.ndarray

get_particle_detection_probability(occupation_number: Tuple[int, ...]) float#

Returns the particle number detection probability using the occupation number specified as a parameter.

Parameters

occupation_number (tuple) – Tuple of natural numbers representing the number of particles in each mode.

Returns

The probability of detection.

Return type

float

property fock_probabilities: numpy.ndarray#

Returns the particle detection probabilities.

Note

The ordering of the Fock basis is increasing with particle numbers, and in each particle number conserving subspace, lexicographic ordering is used.

Returns

The particle detection probabilities.

Return type

numpy.ndarray