# Simulate matrix multiplication using coherent state inputs

Hi, I’m very new to continuous variable quantum computing (I am already familiar with discrete variable qc). I am trying to simulate a matrix vector operation (between some unitary U and a vector A to get an output vector B) using a 4-mode optical interferometer with coherent states as the input but I am frankly completely lost at this point. This is straightforward to do when I initialize each mode to Fock states but I cannot figure it out when I initialize the modes with coherent states. The steps I have taken to solve this problem so far are:

1. Encode the input vector A=(a_0, a_1, a_2, a_3) into the 4 input coherent modes using displacement encoding (setting \alpha=a_j \text{ for } j=0,1,2,3). This was done using ops.Coherent(a_j) | q[j] for each qmode j.

2. Apply the unitary U to the qmode register via an optical interferometer i.e. ops.Interferometer(U) | q

3. Running the circuit on the Fock backend and then extracting \alpha from the final state vector using (np.sqrt(finalstate.mean_photon(j))). I do this because the mean photon number of each coherent mode is \alpha^2 and can thus just take the square root of this to get the resulting vector B.

I have tested this on the Fock backend using U=CNOT and varying A vectors and it seems to work as expected though I am not too sure why. It is not clear to me why the unitary U being applied to coherent states encoded with some \alpha values and then extracting these \alpha values from each mode should be the same as applying U directly to the input vector A. I tried to work it out on paper how applying the unitary U to the 4 mode coherent states (encoded with the entries a_j) but got nowhere because I am unsure how to write out each qmode as a column vector with some cutoff Fock dimension and then multiply that to the 4x4 matrix U. Moreover, my implementation only works when the output vector contains only positive real values as the information of the state is extracted through the mean photon number (\alpha^2) measured from each coherent state mode.

I have thought of using alternative encoding schemes like somehow encoding the vector A into the quadratures of the coherent state and then performing homodyne measurements but again do not know how to design the algorithm to work with this encoding.

I apologize in advance for the long message but I would definitely appreciate some direction on this if possible.

Hi @litc, welcome to the forum!

Continuous variable quantum computing can indeed be puzzling, especially coming from discrete variable qc.

I’m not sure I understand all of your questions but let me attempt to answer them:

CV states look like an integral as opposed to a discrete set of coefficients. This page is an excellent place to start understanding the theory. This may be why the math is unclear or unexpected to you.

Coherent states are Gaussian while Fock states are not, so it’s good to make the distinction between them. You will find some great info on states here.

If you want to encode a matrix differently into an interferometer you can use GraphEmbed.

Finally, you can use different measurements. This tutorial can help you get a full picture on how to build circuits using Strawberry Fields. It can also give you a sense of the math for everything.

Please let me know if this helps, if not please let me know and I’ll happy to answer.

Hey @litc,

Welcome to the forum! It is a nice project to port your implementation of vector matrix multiplication from the DV case to the CV scenario. The port, although straightforward, is not direct. Let me state some facts and give you some resources:

• The most natural basis (or representation) to describe operations in the CV case is phase space — contrary to the DV case where you use the Fock basis.
• The action of a unitary Gaussian transformation on a state \hat \rho \mapsto \hat U\hat \rho \hat U^{\dagger} in phase space is described by the mapping \vec{d} \mapsto \mathbf{S} \vec{d} and \boldsymbol{\sigma} \mapsto \mathbf{S}\boldsymbol{\sigma}\mathbf{S}^\mathrm{T}. Here \boldsymbol{\sigma} is a covariance matrix (the spread of your states in phase space) and \vec{d} is a vector of means (the location of the center of your states in phase space) describing your states.
• Not all unitary transformations are Gaussian. However, an interferometer is a Gaussian transformation (specifically a passive Gaussian transformation) so the point above applies.

Here is what you’re doing for your vector-matrix multiplication: when you encode your input vector into some coherent states you are effectively encoding that vector in to \vec{d}. Your interferometer will apply the mapping \vec{d} \mapsto \mathbf{S} \vec{d} which is the vector-matrix multiplication you want. Now, your task is to

• Understand how some unitary \hat U is related to a symplectic matrix \mathbf{S}. Then, find how to encode your matrix of interest into \mathbf{S} by implementing some unitary \hat U such that you can perform your vector-matrix operation in some quantum device.
• Find the observables (measurements) that would allow you to extract \vec{d} from your output quantum state, that is, the new location of your states in phase space.

For a quick overview of CV quantum information check the article Continuous Variable Quantum Information: Gaussian States and Beyond. For an in-depth theoretical analysis go to A. Serafini, Quantum Continuous Variables.